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
"use strict";
cc._RF.push(module, 'ac7b6iPf7tISZqIdVtqvk8p', 'commonitemalertwin');
// Scripts/common/commonitemalertwin.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
//      通用提示框
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var CommonItemAlertWin = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("common", "common_alert");
    this.viewTag = arguments[0] || SCENE_TAG.dialogue;
    this.item_list = {};
  },
  openCallBack: function openCallBack() {
    this.main_panel = this.root_wnd.getChildByName("main_panel");
    this.seekChild("title_label", cc.Label).string = Utils.TI18N("奖励");
    this.background = this.seekChild("background");
    this.background.scale = FIT_SCALE;
    this.ok_btn = this.main_panel.getChildByName("ok_btn");
    this.ok_btn_lb = this.seekChild("ok_txt", cc.Label);
    this.cancel_btn = this.main_panel.getChildByName("cancel_btn");
    this.cancel_btn_lb = this.seekChild("cancel_txt", cc.Label);
    this.close_btn = this.main_panel.getChildByName("close_btn");
    this.title_lb = this.seekChild("title_label", cc.Label);
    this.cancel_btn.active = false;
    this.ok_btn.x = 0;
    this.aler_des_rt = this.seekChild("aler_des", cc.RichText);
    this.ok_btn.on(cc.Node.EventType.TOUCH_END, this.didClickOkBtn, this);
    this.cancel_btn.on(cc.Node.EventType.TOUCH_END, this.didClickCancleBtn, this);
  },
  registerEvent: function registerEvent() {
    this.close_btn.on(cc.Node.EventType.TOUCH_END, function (event) {
      this.close();
    }.bind(this));
  },
  openRootWnd: function openRootWnd(params) {
    this.aler_des_rt.string = params.str;
 
    if (params.margin) {
      this.aler_des_rt.node.y = this.aler_des_rt.node.y + params.margin.off_y;
 
      if (params.margin.close_off == true) {
        this.close_btn.active = false;
      }
    } else {
      this.aler_des_rt.node.y = this.aler_des_rt.node.y + 57;
    } // var resArr = [];
    // if(params.other_args && params.other_args.resArr){
    //     resArr = params.other_args.resArr;
    // }
    // if(resArr && resArr.length>0){
    //     for(var i in resArr){
    //         this.loadRes(resArr[i], (function(resObject){
    //             this.aler_des_rt.addSpriteFrame(resObject);
    //         }).bind(this));
    //     }
    // }
 
 
    if (params.list) {
      this.createItem(params.list);
    }
 
    if (params.title_str) {
      this.title_lb.string = params.title_str;
    }
 
    if (params.confirm_label) this.ok_btn_lb.string = params.confirm_label;
    if (params.cancel_label) this.cancel_btn_lb.string = params.cancel_label;
    this.confirm_callback = params.confirm_callback;
    this.cancel_callback = params.cancel_callback;
    this.main_panel.runAction(cc.scaleTo(0.1, 1));
  },
  createItem: function createItem(list) {
    var arr = [];
 
    for (var i in list) {
      var v = list[i];
      var data = {};
      data.bid = v[0];
      data.num = v[1];
      arr.push(data);
    }
 
    for (var i in arr) {
      var data = arr[i];
 
      if (this.item_list[i] == null) {
        var item = ItemsPool.getInstance().getItem("backpack_item");
        item.initConfig(false, 0.9, false, true);
        item.setParent(this.main_panel);
        item.show();
        item.setPosition(140 * i - 70 * (arr.length - 1), 0);
        this.item_list[i] = item;
      }
 
      this.item_list[i].setData(data);
    }
  },
  didClickOkBtn: function didClickOkBtn() {
    if (this.confirm_callback) this.confirm_callback();
    this.close();
  },
  didClickCancleBtn: function didClickCancleBtn() {
    if (this.cancel_callback) this.cancel_callback();
    this.close();
  },
  closeCallBack: function closeCallBack() {
    // this.close();
    if (this.item_list) {
      for (var i in this.item_list) {
        if (this.item_list[i]) {
          this.item_list[i].deleteMe();
          this.item_list[i] = null;
        }
      }
 
      this.item_list = null;
    }
  }
});
module.exports = CommonItemAlertWin;
 
cc._RF.pop();