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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
var PathTool = require("pathtool");
var ActionController = require("action_controller")
var ActionConst = require("action_const");
var StrongerController = require("stronger_controller")
var CommonScrollView = require("common_scrollview");
var VipController = require("vip_controller")
var HeroController = require("hero_controller")
var HeroConst      = require("hero_const");
 
var ActionCommonItem = cc.Class({
    extends: BasePanel,
    ctor: function () {
        this.prefabPath = PathTool.getPrefabPath("welfare", "luxury_item");
        this.ctrl = ActionController.getInstance()
    },
 
    // 可以初始化声明一些变量的
    initConfig:function(){
 
    },
 
    // 初始化一些配置数据,可以用于声明一些变量之类的
    initPanel:function(){
        var self = this;
        let main_container = self.root_wnd.getChildByName("main_container")
        self.btn_goto = main_container.getChildByName("btn_goto")
        self.btn_goto_label = self.btn_goto.getChildByName("Text_7_0")
        self.btn_goto_label.getComponent(cc.Label).string = Utils.TI18N("前往")
        self.btn_goto.active = false;
        self.btn_get = main_container.getChildByName("btn_get")
        self.btn_get_label = self.btn_get.getChildByName("Text_7")
        self.btn_get_ui = main_container.getChildByName("btn_get").getComponent(cc.Button)
        self.btn_get.active = false;
        self.has_get = main_container.getChildByName("has_get")
        self.has_get.active = false;
        self.text_tesk = main_container.getChildByName("text_tesk")
        self.text_tesk.getComponent(cc.Label).string = "";
 
        self.goods_con = main_container.getChildByName("good_cons")
        let scroll_view_size = self.goods_con.getContentSize()
        let setting = {
            item_class : "backpack_item",      //-- 单元类
            start_x : 3,                  //-- 第一个单元的X起点
            space_x : 5,                    //-- x方向的间隔
            start_y : 4,                    //-- 第一个单元的Y起点
            space_y : 4,                   //-- y方向的间隔
            item_width : 120*0.80,               //-- 单元的尺寸width
            item_height : 120*0.80,              //-- 单元的尺寸height
            row : 1,                       // -- 行数,作用于水平滚动类型
            col : 0,                         //-- 列数,作用于垂直滚动类型
            scale : 0.80                     //-- 缩放
        }
        self.item_scrollview = new CommonScrollView();
        self.item_scrollview .createScroll(self.goods_con, cc.v2(0,0) , ScrollViewDir.horizontal, ScrollViewStartPos.top, scroll_view_size, setting)
        // self.item_scrollview:setSwallowTouches(false)
        self.title_desc = main_container.getChildByName("title_desc")
        if(this.data){
            this.setData(this.data)
        }
    },
 
    // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
    registerEvent:function() {
        var self = this;
        this.btn_goto.on('click',this.gotoSpecificView,this)
        this.btn_get.on('click',function(){
            Utils.playButtonSound(1)
            if(this.holiday_item_bid && this.data){
                this.ctrl.cs16604(this.holiday_item_bid,this.data.aim)
            }
        },this)
    },
    gotoSpecificView(){
        Utils.playButtonSound(1)
        var self = this;
        // --直接跳转到充值界面的
        if(self.holiday_item_bid && (self.holiday_item_bid == ActionConst.ActionRankCommonType.acc_luxury || self.holiday_item_bid == ActionConst.ActionRankCommonType.totle_charge ||
            self.holiday_item_bid == ActionConst.ActionRankCommonType.limit_charge)){
            VipController.getInstance().openVipMainWindow(true, VIPTABCONST.CHARGE)
        }else if(self.holiday_item_bid && self.holiday_item_bid == ActionConst.ActionRankCommonType.luckly_egg){// --砸蛋的跳转是特殊的
            let id = ActionRankCommonType.smashegg
            let tab_vo = this.ctrl.getActionSubTabVo(id)
            if (tab_vo){
                if(this.ctrl.action_operate){
                    this.ctrl.action_operate.handleSelectedTab(this.ctrl.action_operate.tab_list[id])
                }
            }
        }else if(self.holiday_item_bid && self.holiday_item_bid == ActionConst.ActionRankCommonType.hero_awake){ // --觉醒豪礼特殊处理
                let hero_vo = HeroController.getInstance().getModel().getTopLevHeroInfoByBid(self.cur_bid)
                let all_role_list = HeroController.getInstance().getModel().getAllHeroArray()
                // --无指定英雄则前往限时召唤获取
                if (!hero_vo ||  !all_role_list || all_role_list.size == 0){
                    StrongerController.getInstance().clickCallBack(411)
                }else{
                    HeroController.getInstance().openHeroMainInfoWindow(true, hero_vo, all_role_list.items, {show_model_type : HeroConst.BagTab.eBagHero})
                }
        }else{
            let num
            if (self.holiday_item_bid == ActionConst.ActionRankCommonType.speed_fight || self.holiday_item_bid == ActionConst.ActionRankCommonType.speed_fight1){
                num = 132
            }else if(self.holiday_item_bid == ActionConst.ActionRankCommonType.voyage || self.holiday_item_bid == ActionConst.ActionRankCommonType.voyage1){
                num = 126
            }else if(self.holiday_item_bid == ActionConst.ActionRankCommonType.hero_expedit || self.holiday_item_bid == ActionConst.ActionRankCommonType.hero_expedit1){
                num = 151
            }else if(self.holiday_item_bid == ActionConst.ActionRankCommonType.epoint_gold || self.holiday_item_bid == ActionConst.ActionRankCommonType.epoint_gold1){
                num = 123
            }else if(self.holiday_item_bid == ActionConst.ActionRankCommonType.adventure){
                num = 407
            }else if(self.holiday_item_bid == ActionConst.ActionRankCommonType.updata_star){
                num = 404;
            }
            if(num){
                StrongerController.getInstance().clickCallBack(num)
            }
        }
 
    },
    // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
    onShow:function(params){
    },
 
    // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
    onHide:function(){
 
    },
    setExtendData(tab){
        this.holiday_item_bid = tab.bid
        this.is_activity_end = tab.time_end
        this.finish = tab.finish
    },
    setData(data){
        if(!data) return;
        this.data = data;
        var self = this
        if(this.root_wnd){
            self.getButtonTeskProgress(data)
            self.title_desc.getComponent(cc.RichText).string = StringUtil.parse(data.aim_str) 
            if(self.holiday_item_bid != ActionConst.ActionRankCommonType.longin_gift){
                self.btn_goto.active = (data.status == 0)
            }else{
                if(data.status == 0){
                    self.btn_get.active = (true)
                    self.btn_get_ui.interactable = false
                    self.btn_get_ui.enableAutoGrayEffect = true
                    self.btn_get_label.color = new cc.Color(255,255,255);
                }else{
                    self.btn_get_ui.interactable = true
                    self.btn_get_ui.enableAutoGrayEffect = false
                    self.btn_get_label.color = new cc.Color(113,40,4);
                }
            }
            // self.btn_get.active = (data.status == 1)
            // self.btn_goto.active = (data.status == 0)
            // self.has_get.active = (data.status == 2)
            if (self.is_activity_end == true && data.status == 0){
                self.btn_goto_label.getComponent(cc.Label).string = "已结束";
                self.btn_goto_label.color = new cc.Color(255,255,255);
                Utils.setGreyButton(this.btn_goto.getComponent(cc.Button),true)
            }
 
            // -- 物品列表
            let item_list = data.item_list
            let list = []
            for(let k=0;k<item_list.length;++k){
                let v = item_list[k]
                if (v && v.bid){
                    list.push(v)
                }
            }
            self.item_scrollview.setData(list)
            self.item_scrollview.addEndCallBack(function(){
                self.item_scrollview.scroll_view_compend.enabled = false
                let itemList = self.item_scrollview.getItemList()
                for(let k=0;k<itemList.length;++k){
                    let v = itemList[k]
                    v.setDefaultTip(true,false)
                }
            }.bind(this))
        }
    },
    getButtonTeskProgress(data){
        var self = this;
        let str = ""
        if (self.holiday_item_bid != ActionConst.ActionRankCommonType.longin_gift){
            let totle_count,current_count;
            let totle_list = Utils.keyfind('aim_args_key', 4, data.aim_args) || null;
            if (totle_list){
                totle_count = totle_list.aim_args_val || 0;
            }
            let current_list = Utils.keyfind('aim_args_key', 5, data.aim_args) || null;
            if (current_list){
                current_count = current_list.aim_args_val || 0;
            }
            if (totle_count>=0 && current_count>=0){
                str = "("+current_count + "/"+ totle_count +")";
            }
 
            // --升星有礼、融合祝福、觉醒豪礼
            let count
            let count_list = Utils.keyfind('aim_args_key', 6, data.aim_args) || null
            if (count_list){
                count = count_list.aim_args_val || 0
            }
            if (count>=0 && totle_count>=0){
                str = "("+count + "/"+ totle_count +")";
                if (count >= totle_count && data.status == 0){
                    data.status = 2;
                }
            }
            // --觉醒豪礼所用
            let bid_list = Utils.keyfind('aim_args_key', 18, data.aim_args) || null;
            if (bid_list){
                self.cur_bid = bid_list.aim_args_val || 0
            }
            // --充值类型的
            if (self.holiday_item_bid == ActionConst.ActionRankCommonType.acc_luxury){
                if (data.status == 0){
                    str = "(0/1)"
                }else{
                    str = "(1/1)"
                }
            }else if(self.holiday_item_bid == ActionConst.ActionRankCommonType.totle_charge || self.holiday_item_bid == ActionConst.ActionRankCommonType.totle_consume ||
                self.holiday_item_bid == ActionConst.ActionRankCommonType.limit_charge){// --累充和累消的
                str = "("+self.finish + "/"+ data.aim +")";
            }
        }else{
            str = "("+ self.finish + "/"+ data.aim +")";
        }
        self.text_tesk.getComponent(cc.Label).string = str;
        self.btn_get.active = (data.status == 1);
        self.has_get.active = (data.status == 2);
    },
    // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
    onDelete:function(){
        if(this.item_scrollview){
            this.item_scrollview.deleteMe();
            this.item_scrollview = null;
        }
    },
})