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
"use strict";
cc._RF.push(module, '3ffd4NULitGMp+Gigbq6EtI', 'chat_input_list');
// Scripts/mod/chat/view/chat_input_list.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-03-30 14:42:55
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var BackPackConst = require("backpack_const");
 
var ChatItemController = require("chat_item_controller");
 
var ItemEnum = {
  "1": {
    source: "face_item",
    width: 60,
    height: 60,
    col: 8
  },
  "2": {
    source: "goods_item",
    width: 100,
    height: 100,
    col: 5
  },
  "3": {
    source: "equip_item",
    width: 100,
    height: 100,
    col: 5
  }
};
var Chat_input_listPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.ctrl = arguments[0];
    this.prefabPath = PathTool.getPrefabPath("chat", "chat_input_list");
    this.chat_item_ctrl = ChatItemController.getInstance();
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.cur_tab = null;
    this.item_lists = {};
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.container_nd = this.seekChild("container");
    var tab_bnts = this.tab_bnts = {};
 
    for (var tab_i = 1; tab_i <= 3; tab_i++) {
      var tab_info = this.tab_bnts[tab_i] = {};
      var tab_btn_nd = this.seekChild("tab_btn_" + tab_i);
      tab_btn_nd.tab_tag = tab_i;
      tab_info["select_nd"] = tab_btn_nd.getChildByName("select");
      tab_btn_nd.on(cc.Node.EventType.TOUCH_END, this.onClickTabBtns, this);
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {},
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {
    this.selectTab(1);
  },
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {},
  setSelectCB: function setSelectCB(select_cb) {
    this.select_cb = select_cb;
  },
  onClickTabBtns: function onClickTabBtns(event) {
    if (event && this.cur_tab !== event.target.tab_tag) this.selectTab(event.target.tab_tag);
  },
  selectTab: function selectTab(tab_index) {
    if (this.cur_tab) this.tab_bnts[this.cur_tab]["select_nd"].active = false;
    this.tab_bnts[tab_index]["select_nd"].active = true;
    this.updateCurPanel(tab_index);
    this.cur_tab = tab_index;
  },
  updateCurPanel: function updateCurPanel(list_index) {
    if (this.cur_tab && this.item_lists[this.cur_tab]) {
      this.item_lists[this.cur_tab].setRootVisible(false);
    }
 
    if (list_index && this.item_lists[list_index]) {
      this.item_lists[list_index].setRootVisible(true);
    } else {
      this.createItemList(list_index);
    }
  },
  createItemList: function createItemList(list_index) {
    var item_info = ItemEnum[list_index];
 
    var CommonScrollView = require("common_scrollview");
 
    var ItemSource = require(item_info.source);
 
    var scroll_view_size = cc.size(this.container_nd.width, this.container_nd.height);
    var setting = {
      item_class: ItemSource,
      // 单元类
      start_x: 0,
      // 第一个单元的X起点
      space_x: 0,
      // x方向的间隔
      start_y: 0,
      // 第一个单元的Y起点
      space_y: 0,
      // y方向的间隔
      item_width: item_info.width,
      // 单元的尺寸width
      item_height: item_info.height,
      // 单元的尺寸height
      col: item_info.col,
      // 列数,作用于垂直滚动类型
      once_num: 1,
      need_dynamic: true
    };
    this.item_lists[list_index] = new CommonScrollView();
    this.item_lists[list_index].createScroll(this.container_nd, cc.v2(0, 0), ScrollViewDir.vertical, ScrollViewStartPos.top, scroll_view_size, setting, cc.v2(0.5, 0.5));
    var list_data = [];
    var select_cb = null;
 
    if (list_index === 1) {
      var face_cfgs = Config.face_data.data_biaoqing;
 
      for (var face_i in face_cfgs) {
        list_data.push(face_cfgs[face_i]);
      }
 
      select_cb = this.selectFaceCB.bind(this);
    } else if (list_index === 2) {
      var BackpackController = require("backpack_controller");
 
      var bag_model = BackpackController.getInstance().getModel();
      list_data = bag_model.getItemListForShare();
      select_cb = this.selectItemCB.bind(this);
    } else if (list_index === 3) {
      var HeroController = require("hero_controller");
 
      var hero_mode = HeroController.getInstance().getModel();
      var hero_list = hero_mode.getHeroList();
 
      for (var hero_i in hero_list) {
        var hero_info = hero_list[hero_i];
 
        for (var equip_i in hero_info.eqm_list) {
          hero_info.partner_data = hero_info;
          list_data.push({
            item_data: hero_info.eqm_list[equip_i],
            hero_info: hero_info
          });
        }
      }
 
      select_cb = this.selectEquipCB.bind(this);
    }
 
    this.item_lists[list_index].setData(list_data, select_cb);
  },
  selectFaceCB: function selectFaceCB(face_text) {
    if (face_text && this.select_cb) {
      this.select_cb(face_text);
    }
  },
  selectItemCB: function selectItemCB(item_data) {
    if (item_data && item_data.config) {
      this.chat_item_ctrl.send10535(1, item_data.id, 0, 1);
    }
 
    ;
  },
  selectEquipCB: function selectEquipCB(data) {
    var equip_data = data.item_data;
    var hero_info = data.hero_info; // 区分装备和符文
 
    if (equip_data && equip_data.config) {
      if (BackPackConst.checkIsEquip(equip_data.config.type)) {
        this.chat_item_ctrl.send10535(4, equip_data.id, hero_info.partner_id, 2);
      } else if (BackPackConst.checkIsArtifact(equip_data.config.type)) {
        this.chat_item_ctrl.send10535(2, equip_data.id, hero_info.partner_id, 2);
      }
    }
  }
});
 
cc._RF.pop();