// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html import AppConfig from "../FrameWork/Config/AppConfig"; import AesTools from "../FrameWork/NetWork/AesTools"; import HttpUnit, { requestData } from "../FrameWork/NetWork/HttpUnit"; import User from "../FrameWork/User/User"; import AppPlatform from "../FrameWork/Util/AppPlatform"; import Common5 from "../Platform/th/Common5"; const {ccclass, property} = cc._decorator; @ccclass export default class CheckLayer extends cc.Component { // LIFE-CYCLE CALLBACKS: @property(cc.EditBox) UUIDEdit: cc.EditBox = null; // onLoad () {} start () { console.log('isOtherGame+++++++++===000') if (AppPlatform.isOtherGame()){ this.node.active = false return console.log('isOtherGame+++++++++===111') this.schedule(this.checkWhiteList,5,cc.macro.REPEAT_FOREVER,0.1) // this.node.active = true }else{ this.node.active = false } } public getCurSecond(){ return Date.parse(new Date().toString())/1000; } checkWhiteList(){ let tmpUUID = ""; if (User.getUUID() == ""){ tmpUUID = Common5.getRandomNum(10000,99999) + "-" + Common5.getRandomNum(100000,999999) + "-" + Common5.getRandomNum(10000,99999) + "-" + Math.round(this.getCurSecond()); this.UUIDEdit.string = tmpUUID; User.setUUID(tmpUUID); } else { tmpUUID = this.UUIDEdit.string = User.getUUID(); } let rd = new requestData(); rd.data_custom.uuid = tmpUUID; rd.meth_custom = "GET"; rd.url_custom = "https://dy.ioe-times.com/gamewhitelist/checkwhitelist?devid="+tmpUUID rd.onSuccess_custom = (res)=>{ console.log(res); } let headers = {}; let time = "time=" + String(Date.now()); //headers["Access-Control-Allow-Origin"] = "*"; headers["Content-Type"] = "application/jsonp"; headers["state"] = AppConfig.state_custom; headers["gameid"] = AppConfig.gameid_custom; headers["sign"] = AesTools.encrypt_custom(time); if (User.token_custom) { headers["token"] = User.token_custom; } HttpUnit.sendHttpUrl_custom(rd,"{}",(res)=>{ if (res){ console.log('isOtherGame+++++++++===222') console.log("true"); this.node.active = false; this.unschedule(this.checkWhiteList); } else{ console.log('isOtherGame+++++++++===333') this.node.active = true; console.log("false"); } },(err)=>{ console.log(err); },headers); } // update (dt) {} }