| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- import { EVENT_TYPE } from "../../game/data/GameData";
- import GameConst from "../data/GameConst";
- import PlayerConst from "../data/PlayerConst";
- import GameMgr, { UI_NAME } from "../mgr/GameMgr";
- import GameLogic from "../util/GameLogic";
- import Util from "../util/Util";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class PlayerInfoUI extends cc.Component {
- @property(cc.Node)
- node_rectBg: cc.Node = null;
- @property(cc.Node)
- node_closeBtn: cc.Node = null;
- @property(cc.Sprite)
- spr_head: cc.Sprite = null;
- @property(cc.Label)
- label_nickName: cc.Label = null;
- @property(cc.Label)
- label_inviteCode: cc.Label = null;
- @property(cc.Node)
- node_copyInviteCodeBtn: cc.Node = null;
- @property(cc.Node)
- node_inputInviteCodeBtn: cc.Node = null;
- @property(cc.Label)
- label_cashNum: cc.Label = null;
- @property(cc.Node)
- node_caseOutBtn: cc.Node = null;
- @property(cc.Node)
- node_inviteBtn: cc.Node = null;
- @property(cc.Node)
- node_serviceBookBtn: cc.Node = null;
- @property(cc.Node)
- node_privacyRuleBtn: cc.Node = null;
- @property(cc.Node)
- node_gameRuleBtn: cc.Node = null;
- @property(cc.Node)
- node_contactBtn: cc.Node = null;
- @property(cc.Node)
- node_serviceBookUI: cc.Node = null;
- @property(cc.Node)
- node_privacyRuleUI: cc.Node = null;
- @property(cc.Node)
- node_gameRuleUI: cc.Node = null;
- @property(cc.Node)
- node_contactUI: cc.Node = null;
- @property(cc.Label)
- label_version: cc.Label = null;
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {}
- start() {
- this.addapt();
- this.initView();
- this.initEvent();
- }
- // update (dt) {}
- onEnable() {
- GameMgr.Inst.sendEvent(UI_NAME.PlayerInfoUI, "进入玩家信息界面");
- // //显示广告
- // AdMgr.Inst.showNativeAd(4, true);
- this.initCaseNum();
- this.initHead();
- this.initNickName();
- }
- onDisable() {
- // //显示广告
- // AdMgr.Inst.destroyNativeAd();
- }
- addapt() {
- this.node_rectBg.setContentSize(cc.winSize.width, cc.winSize.height);
- }
- initView() {
- this.initHead();
- this.initNickName();
- this.initInviteCode();
- this.label_version.string = `v${GameConst.appVersion}`;
- }
- initEvent() {
- this.node_closeBtn.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
- this.node_copyInviteCodeBtn.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
- this.node_inputInviteCodeBtn.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
- this.node_caseOutBtn.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
- this.node_inviteBtn.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
- this.node_serviceBookBtn.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
- this.node_privacyRuleBtn.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
- this.node_gameRuleBtn.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
- this.node_contactBtn.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
- if (!GameConst.isAuth) {
- mk.event.register(EVENT_TYPE.BACK_WxAuth, this.onWxAuthBack, this);
- }
- }
- onClick(event: cc.Event.EventTouch) {
- // AudioMgr.Inst.playEffect(AUDIO_CLIP_NAME.buttonClick);
- mk.audio.playEffect("button");
- switch (event.currentTarget) {
- case this.node_closeBtn:
- this.onClickCloseBtn();
- break;
- case this.node_copyInviteCodeBtn:
- this.onClickCopyInviteCodeBtn();
- break;
- case this.node_inviteBtn:
- this.onClickInviteBtn();
- break;
- case this.node_serviceBookBtn:
- this.onClickServiceBookBtn();
- break;
- case this.node_privacyRuleBtn:
- this.onClickPrivacyRuleBtn();
- break;
- case this.node_gameRuleBtn:
- this.onClickGameRuleBtn();
- break;
- case this.node_contactBtn:
- this.onClickContactBtn();
- break;
- }
- }
- initHead() {
- GameLogic.loadHeadImg("" + "?aaa=aa.jpg", this.spr_head, 95);
- }
- initNickName() {
- this.label_nickName.string = "PlayerConst.nickName";
- }
- initInviteCode() {
- this.label_inviteCode.string = Util.cutStr(GameConst.uin, 8);
- }
- initCaseNum() {
- // let num = Util.numberFixed(PlayerConst.cashNum, 2);
- // this.label_cashNum.string = `¥ ${num}`;
- }
- onClickCloseBtn() {
- GameMgr.Inst.sendEvent(UI_NAME.PlayerInfoUI, "点击关闭按钮");
- // this.node.active = false;
- mk.ui.closePanel("PlayerInfoUI")
- }
- onClickCopyInviteCodeBtn() {
- }
- onClickInviteBtn() {
- }
- onClickServiceBookBtn() {
- this.node_serviceBookUI.active = true;
- }
- onClickPrivacyRuleBtn() {
- this.node_privacyRuleUI.active = true;
- }
- onClickGameRuleBtn() {
- this.node_gameRuleBtn.active = true;
- }
- onClickContactBtn() {
- // GameMgr.Inst.sendEvent(UI_NAME.PlayerInfoUI, "点击提现按钮");
- this.node_contactBtn.active = true;
- }
- //自定义事件------------------------------------------------------------------------
- /**微信授权返回 */
- onWxAuthBack() {
- this.initHead();
- this.initNickName();
- mk.event.remove(EVENT_TYPE.BACK_WxAuth, this.onWxAuthBack, this);
- }
- }
|