difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"use strict";
cc._RF.push(module, '18d1aokvrRCn4kG1MXDJ+5/', 'bind_phone_panel');
// Scripts/mod/welfare/view/bind_phone_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-04-23 17:39:08
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var WelfareConst = require("welfare_const");
 
var WelfareEvent = require("welfare_event");
 
var Bind_phonePanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("welfare", "bind_phone_panel");
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.ctrl = require("welfare_controller").getInstance();
    this.bind_phone_status = 0;
    this.item_list = [];
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.ok_btn = this.seekChild("ok_btn");
    this.ok_btn_lb = this.seekChild(this.ok_btn, "label", cc.Label);
    this.item_container = this.seekChild("item_container");
    this.bg_sp = this.seekChild("bg", cc.Sprite);
    this.loadRes(PathTool.getBigBg("welfare/txt_cn_bind_phone"), function (res) {
      this.bg_sp.spriteFrame = res;
    }.bind(this));
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.ok_btn, function () {
      if (this.bind_phone_status == 0) {
        //前往绑定
        if (PLATFORM_TYPR == "SH_RH" && SH_RH_IS_SHOW_BINDPHONE == true && PLATFORM_NAME == "shmix") {
          SDK.bindphone({
            apiType: 'askShow'
          });
        } else {
          this.ctrl.openCertifyBindPhoneWindow(true);
        }
      } else if (this.bind_phone_status == 1) {
        //已发送奖励
        message(Utils.TI18N("奖励已发送"));
      }
    }.bind(this), 1);
    this.addGlobalEvent(WelfareEvent.UpdateBindPhoneStatus, function () {
      this.updateBindPhoneStatus();
    }, this);
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {
    this.updateBindPhoneStatus();
    this.setItemList();
    this.ctrl.setWelfareStatus(WelfareConst.WelfareIcon.bindphone, false);
  },
  //设置绑定状态
  updateBindPhoneStatus: function updateBindPhoneStatus() {
    var bind_data = this.ctrl.getBindPhoneData();
    if (bind_data == null) return;
 
    if (this.bind_phone_status != bind_data.code) {
      this.bind_phone_status = bind_data.code;
 
      if (bind_data.code == 0) {
        this.ok_btn_lb.string = Utils.TI18N("前往绑定");
      } else if (bind_data.code == 1) {
        this.ok_btn_lb.string = Utils.TI18N("已发送");
      }
    }
  },
  setItemList: function setItemList() {
    var bind_data = this.ctrl.getBindPhoneData();
    if (bind_data == null || bind_data.items == null) return;
    var index = 0;
 
    for (var i in bind_data.items) {
      var v = bind_data.items[i];
 
      if (!this.item_list[i]) {
        var item = ItemsPool.getInstance().getItem("backpack_item");
        item.initConfig(false, 1, false, true);
        item.show();
        item.setParent(this.item_container);
        item.setData({
          bid: v.bid,
          num: v.num
        });
        item.setPosition(index * 134 + 60, 0);
        this.item_list[i] = item;
        index = index + 1;
      }
    }
  },
  setVisibleStatus: function setVisibleStatus(status) {
    this.setVisible(status);
  },
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.item_list) {
      for (var k in this.item_list) {
        this.item_list[k].deleteMe();
        this.item_list[k] = null;
      }
 
      this.item_list = null;
    }
  }
});
 
cc._RF.pop();