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
var StrongerController = require("stronger_controller")
var StrongerPanelItem = cc.Class({
    extends: BasePanel,
    ctor: function () {
        this.prefabPath = PathTool.getPrefabPath("stronger", "stronger_panel_item");
        this.ctrl = StrongerController.getInstance()
    },
    initConfig:function(){
    },
    initPanel(){
        var self = this
        self.name_lb = this.seekChild("name",cc.Label)
        self.desc_lb = this.seekChild("desc_label",cc.Label)
        self.goods_icon_sp = this.seekChild("goods_icon",cc.Sprite)
    
        self.loadingbar = this.seekChild("loadingbar")
        self.loadingbar_exp_lb = this.seekChild("loadingbar_exp",cc.Label)
        
        self.go_btn = this.seekChild("go_btn")
 
        this.loading_bg_pb = this.seekChild("loading_bg",cc.ProgressBar)
        if (this.data) {
            this.setData(this.data);
        }
    },
    registerEvent(){
        this.go_btn.on('click',this._onClickGoBtn,this)
    },
    _onClickGoBtn(){
        Utils.playButtonSound(1)
        if (this.data && this.data.evt_type){ 
            this.ctrl.clickCallBack(this.data.evt_type)
        }
    },
    setData( data ){
        var self = this
        this.data = data
        if(!this.root_wnd) return
        if (data) {
            self.go_btn.name = "go_btn_" + this.data.id;
            
            // -- 引导需要
            if (data._index){
                // self.go_btn:setName("go_btn_" .. data._index)
            }
 
            self.data = data
            self.name_lb.string = data.name
            self.desc_lb.string = data.desc
            let percent = data.score_val/data.max_val
            // self.loadingbar:setPercent(percent)
            this.loading_bg_pb.progress = percent
            self.loadingbar_exp_lb.string =data.score_val + "/" + data.max_val
 
            let res = PathTool.getIconPath("strongericon","stronger_"+data.icon)
            this.loadRes(res, function(sf_obj){
                this.goods_icon_sp.spriteFrame = sf_obj;
            }.bind(this))
        }
    },
})
module.exports = StrongerPanelItem;