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
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-02-27 16:04:44
// --------------------------------------------------------------------
var PathTool = require("pathtool");
var VipController = require("vip_controller");
 
var Vip_panel_itemPanel = cc.Class({
    extends: BasePanel,
    ctor: function () {
        this.prefabPath = PathTool.getPrefabPath("vip", "vip_panel_item");
    },
 
    // 可以初始化声明一些变量的
    initConfig: function () {
        this.role_vo = require("role_controller").getInstance().getRoleVo();
        this.ctrl = VipController.getInstance();
        this.select_index = null;
    },
 
    // 初始化一些配置数据,可以用于声明一些变量之类的
    initPanel: function () {
        this.container_nd = this.seekChild("container");
        this.text_vip_lb = this.seekChild(this.container_nd, "VIP", cc.Label);
        this.text_reward_lb = this.seekChild(this.container_nd, "text_reward", cc.Label);
 
        this.normal_nd = this.seekChild(this.container_nd, "normal");
        this.select_nd = this.seekChild(this.container_nd, "select");
        this.select_nd.active = false;
 
        this.red_point_nd = this.seekChild(this.container_nd, "red_point");
        this.red_point_nd.active = false;
 
        this.select_index = this.role_vo.vip_lev;
 
        if(this.data){
            if (this.role_vo.vip_lev == this.data.lev) {
                this.setSelect(true);
                this.setNormal(false);
                this.setTextColor(new cc.Color(0xa9, 0x5f, 0x0f, 0xff), new cc.Color(0x68, 0x45, 0x2a, 0xff))
            } else {
                this.setTextColor(new cc.Color(0xff, 0xe6, 0xc9, 0xff), new cc.Color(0xff, 0xdf, 0xb7, 0xff))
            }
    
            var status = this.ctrl.getPrivilegeRedpoint(this.data.lev + 1);
            if (status == true) {
                status = true;
            } else {
                status = false
            }
            var isBuy = this.ctrl.getModel().checkGiftList(this.data.lev);
            if (this.data.lev == this.role_vo.vip_lev || isBuy == true) {
                status = false
            }
            this.setVisibleRedStatus(status);
        }
    },
 
    // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
    registerEvent: function () {
        this.root_wnd.on(cc.Node.EventType.TOUCH_END, function () {
            if (this.callback) {
                this.callback(this);
            }
        }, this)
    },
 
    setData: function (data) {
        this.data = data;
        if (this.root_wnd)
            this.onShow()
    },
 
    // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
    onShow: function () {
        if (this.data == null) return
        var data = this.data;
        
        if (this.select_index != null) {
            if (this.select_index == this.data.lev) {
                this.setSelect(true);
                this.setNormal(false);
                this.setTextColor(new cc.Color(0xa9, 0x5f, 0x0f, 0xff), new cc.Color(0x68, 0x45, 0x2a, 0xff))
            } else {
                this.setSelect(false);
                this.setNormal(true);
                this.setTextColor(new cc.Color(0xff, 0xe6, 0xc9, 0xff), new cc.Color(0xff, 0xdf, 0xb7, 0xff))
            }
        }
        this.text_vip_lb.string = "VIP" + data.lev;
        if (data.desc) {
            this.text_reward_lb.string = data.desc;
        }else{
            this.text_reward_lb.string = "";
        }
    },
 
    setNormal: function (_bool) {
        this.normal_nd.active = _bool;
    },
 
    setSelect: function (_bool) {
        this.select_nd.active = _bool;
    },
 
    setTextColor: function (color1, color2) {
        this.text_vip_lb.node.color = color1;
        this.text_reward_lb.node.color = color2;
    },
 
    // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
    onHide: function () {
 
    },
 
    addCallBack: function (value) {
        this.callback = value;
    },
 
    getData: function () {
        return this.data
    },
 
    setVisibleRedStatus: function (status) {
        this.red_point_nd.active = status;
    },
 
    // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
    onDelete: function () {
 
    },
})