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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
"use strict";
cc._RF.push(module, '7bddarY3iNOOrtTBMbEXoYE', 'vip_main_tab_panel');
// Scripts/mod/vip/view/vip_main_tab_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-02-27 17:21:55
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var Vip_main_tabPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("vip", "vip_tab_btn");
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.size = cc.size(155, 130);
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    var container = this.seekChild("container");
    this.tips_nd = this.seekChild(container, "tab_tips");
    this.tips_nd.active = false;
    this.red_num_lb = this.seekChild(container, "red_num", cc.Label);
    this.red_num_lb.node.active = false;
    this.select_bg_sp = this.seekChild(container, "select_bg", cc.Sprite);
    this.select_bg_sp.node.active = false;
    this.unselect_bg_sp = this.seekChild(container, "unselect_bg", cc.Sprite);
    this.title_lb = this.seekChild(container, "title", cc.Label);
    this.title_img_sp = this.seekChild(container, "title_img", cc.Sprite);
    this.title_img_sp.node.active = false;
 
    if (this.status != null) {
      this.setSelect(this.status);
    }
 
    if (this.red_status != null) {
      this.showRedTips(this.red_status, this.num);
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.root_wnd.on(cc.Node.EventType.TOUCH_END, function () {
      if (this.tab_type && this.callback) {
        this.callback(this.tab_type);
      }
    }, this);
  },
  setData: function setData(data) {
    this.data = data;
    if (this.root_wnd) this.onShow();
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow() {
    if (this.data == null) return;
    this.tab_type = this.data.index;
    this.title_lb.string = this.data.label; // self:setTouchEnabled(self.data.status)
 
    var unselect_res, select_res, title_res;
 
    if (this.tab_type == VIPTABCONST.CHARGE) {
      unselect_res = PathTool.getUIIconPath("vip", "vip_tab10");
      select_res = PathTool.getUIIconPath("vip", "vip_tab1");
      title_res = PathTool.getUIIconPath("vip", "txt_cn_vip_tab1");
    } else if (this.tab_type == VIPTABCONST.ACC_CHARGE) {
      unselect_res = PathTool.getUIIconPath("vip", "vip_tab20");
      select_res = PathTool.getUIIconPath("vip", "vip_tab2");
      title_res = PathTool.getUIIconPath("vip", "txt_cn_vip_tab2");
    } else if (this.tab_type == VIPTABCONST.VIP) {
      unselect_res = PathTool.getUIIconPath("vip", "vip_tab30");
      select_res = PathTool.getUIIconPath("vip", "vip_tab3");
      title_res = PathTool.getUIIconPath("vip", "txt_cn_vip_tab3");
    } else if (this.tab_type == VIPTABCONST.DAILY_GIFT) {
      unselect_res = PathTool.getUIIconPath("vip", "vip_tab40");
      select_res = PathTool.getUIIconPath("vip", "vip_tab4");
      title_res = PathTool.getUIIconPath("vip", "txt_cn_vip_tab4");
    } else if (this.tab_type == VIPTABCONST.PRIVILEGE) {
      unselect_res = PathTool.getUIIconPath("vip", "vip_tab50");
      select_res = PathTool.getUIIconPath("vip", "vip_tab5");
      title_res = PathTool.getUIIconPath("vip", "txt_cn_vip_tab5");
    }
 
    if (unselect_res) {
      this.loadRes(unselect_res, function (sf_obj) {
        this.unselect_bg_sp.spriteFrame = sf_obj;
      }.bind(this));
    }
 
    if (select_res) {
      this.loadRes(select_res, function (sf_obj) {
        this.select_bg_sp.spriteFrame = sf_obj;
      }.bind(this));
    }
 
    if (title_res) {
      this.loadRes(title_res, function (sf_obj) {
        this.title_img_sp.spriteFrame = sf_obj;
      }.bind(this));
    }
  },
  setSelect: function setSelect(status) {
    this.status = status;
    if (this.root_wnd == null) return;
    this.select_bg_sp.node.active = status;
    this.unselect_bg_sp.node.active = !status;
    this.title_img_sp.node.active = status;
    this.title_lb.node.active = !status;
  },
  showRedTips: function showRedTips(status, num) {
    this.red_status = status;
    this.num = num;
    if (this.root_wnd == null) return;
    this.red_tips_status = status;
    this.tips_nd.active = status;
 
    if (num && num > 0) {
      this.red_num_lb.node.active = true;
      this.red_num_lb.string = num;
    } else {
      this.red_num_lb.node.active = false;
    }
  },
  getRedTipsStatus: function getRedTipsStatus() {
    return this.red_tips_status;
  },
  addCallBack: function addCallBack(callback) {
    this.callback = callback;
  },
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {}
});
 
cc._RF.pop();