import Util from "../../../before/util/Util"; import JsbSystem from "../../../mk/system/JsbSystem"; import { DataEventId, InterAdType } from "../../data/GameData"; import Rule from "./Rule"; const { ccclass, property } = cc._decorator; /** * 账号设置 * @author 邹勇 */ @ccclass export default class Setting extends cc.Component { @property({ type: cc.Sprite, displayName: "头像" }) img_head: cc.Sprite = null; @property({ type: cc.Label, displayName: "昵称" }) lbl_nickname: cc.Label = null; @property({ type: cc.Label, displayName: "ID" }) lbl_id: cc.Label = null; @property({ type: cc.Sprite, displayName: "音乐开关" }) img_music: cc.Sprite = null; @property({ type: cc.Sprite, displayName: "音效开关" }) img_effect: cc.Sprite = null; @property({ type: cc.Label, displayName: "版本号" }) lbl_version: cc.Label = null; @property({ type: cc.Sprite, displayName: "成就名称" }) sp_achieve: cc.Sprite = null; @property({ type: cc.Label, displayName: '等级' }) lbl_lv: cc.Label = null; @property({ type: cc.Label, displayName: '红包币' }) lbl_redBagCoin: cc.Label = null; @property({ type: cc.Label, displayName: '提现金额' }) lbl_value: cc.Label = null; node_rule: cc.Node = null; onLoad() { } start() { //mk.ad.showNative(4); this.initData(); //gData.adData.checkPopInter(InterAdType.interstitial1_click_11); gData.gameData.popTableScreenADLogic(10); } private async initData() { this.lbl_id.string = "ID:" + mk.string.getNewLimitStr(gData.wechatData.unionid, 10);// 14 this.lbl_nickname.string = gData.wechatData.nickName; this.lbl_version.string = gData.appData.appVersion; this.lbl_lv.string = 'Lv:' + gData.gameData.playerProp.gradeLevel.toString(); this.lbl_redBagCoin.string = (gData.gameData.playerProp.redMoney / 100).toString(); this.lbl_value.string = (gData.gameData.playerProp.redMoney / 1000000).toFixed(3); let music = "module/setting/texture/" + (mk.audio.getSwitchMusic() ? "on" : "off"); let effect = "module/setting/texture/" + (mk.audio.getSwitchEffect() ? "on" : "off"); this.img_music.spriteFrame = await mk.loader.load(music, cc.SpriteFrame); this.img_effect.spriteFrame = await mk.loader.load(effect, cc.SpriteFrame); this.sp_achieve.spriteFrame = await mk.loader.load('module/gradeReward/texture/name' + gData.gameData.playerProp.farmGradeName, cc.SpriteFrame); if (gData.wechatData.avatar != '') { let result = await mk.loader.loadRemote(gData.wechatData.avatar + "?aaa=aa.jpg", null); if (result) { this.img_head.spriteFrame = new cc.SpriteFrame(result); } } } private clickInviteBtn() { mk.audio.playEffect("button"); } clickCopy() { // //test // gData.gameData.playerProp.completeFarmTaskTimes++; // gData.gameData.checkTaskFinishUnLock(); // console.log('gData.gameData.playerProp.completeFarmTaskTimes ', gData.gameData.playerProp.completeFarmTaskTimes); // return mk.audio.playEffect("button"); JsbSystem.setClipboard(gData.wechatData.unionid); mk.tip.pop("复制成功"); } async clickMusic() { mk.audio.playEffect("button"); mk.audio.switchMusicFunc(); let music = "module/setting/texture/" + (mk.audio.getSwitchMusic() ? "on" : "off"); this.img_music.spriteFrame = await mk.loader.load(music, cc.SpriteFrame); } async clickEffect() { mk.audio.switchEffectFunc(); mk.audio.playEffect("button"); let effect = "module/setting/texture/" + (mk.audio.getSwitchEffect() ? "on" : "off"); this.img_effect.spriteFrame = await mk.loader.load(effect, cc.SpriteFrame); } clickUpdate() { mk.audio.playEffect("button"); let installVersion = gData.appData.installVersion let compare = Util.versionCompareHandle(gData.appData.appVersion, installVersion) if (compare < 0) { mk.ui.openPanel('module/forceUpdate/forceUpdate'); } else { mk.tip.pop('当前已是最新版本') } } /** 点击微信授权 */ onClickWxAuth() { if (!gData.loginData.isAuth) { // mk.ui.closePanel(this.node.name); // JsbSystem.WxAuth(); gData.gameData.authUIType = 2; mk.ui.openPanel('module/authUI/authUI'); // this.onClickClose(); } } /**点击分享 */ public onClickShare() { mk.data.sendDataEvent(DataEventId.button_click, "邀请icon"); if (!gData.loginData.isAuth) { // JsbSystem.WxAuth(); gData.gameData.authUIType = 1; mk.ui.openPanel('module/authUI/authUI'); return; } JsbSystem.shareInviteUrl(gData.gameData.shareUrl, gData.gameData.shareTitle, gData.gameData.shareDes, gData.gameData.shareImgUrl); } async clickRule(data) { gData.setting.rule_type = parseInt(data); } update() { if (gData.gameData.init_head) { this.initData(); } } onDestroy() { } onClickClose() { //mk.audio.playEffect("closeButton"); mk.ad.destroyNativeAd(); } }