| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import Util from "../../../before/util/Util";
- /** 引导到微信数据类 */
- const { ccclass } = cc._decorator;
- @ccclass
- export default class GuideToWxData {
- //开关
- public guideToWxSwith = false;
- public guideState: GuideState = GuideState.none;
- public money = '';
- public ghId = '';
- public ghIdPath = '';
- public init_state = false;
- checkPop() {
- if (!this.guideToWxSwith) {
- return;
- }
- if (this.guideState < GuideState.gotMoney) {
- mk.ui.openPanel('module/guideToWx/guideToWx');
- }
- }
- setGhId() {
- let arr = gData.gameData.configs.ServerConfig.ghId.split(';');
- let localId = mk.storage.getStorage('ghId');
- let len = arr.length;
- let ghArr = null;
- if (!localId) {
- let index = Util.rnd(0, len - 1);
- ghArr = arr[index].split(',');
- gData.guideToWxData.ghId = ghArr[0];
- gData.guideToWxData.ghIdPath = ghArr[1];
- mk.storage.setStorage('ghId', gData.guideToWxData.ghId);
- }
- else {
- let has = false;
- for (let i = 0; i < len; i++) {
- ghArr = arr[i].split(',');
- if (ghArr[0] == localId) {
- gData.guideToWxData.ghId = ghArr[0];
- gData.guideToWxData.ghIdPath = ghArr[1];
- has = true;
- break;
- }
- }
- if (!has) {
- let index = Util.rnd(0, len - 1);
- ghArr = arr[index].split(',');
- gData.guideToWxData.ghId = ghArr[0];
- gData.guideToWxData.ghIdPath = ghArr[1];
- mk.storage.setStorage('ghId', gData.guideToWxData.ghId);
- }
- }
- }
- }
- export enum GuideState {
- none = 0,
- addService,
- sendApply,
- waitForPass,
- canGetMoney,
- gotMoney
- }
|