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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
"use strict";
cc._RF.push(module, '9dba3YeOMhNGIl+Q+tytrf5', 'friend_check_info_winodw');
// Scripts/mod/friend/view/friend_check_info_winodw.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: @syg.com(必填, 创建模块的人员)
// @description:
//      竖版查看好友
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var FriendConst = require("friend_const");
 
var RoleEvent = require("role_event");
 
var PlayerHead = require("playerhead");
 
var RoleController = require("role_controller");
 
var HeroVo = require("hero_vo");
 
var BattleController = require("battle_controller");
 
var ChatController = require("chat_controller");
 
var ChatConst = require("chat_const");
 
var FriendCheckInfoWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("friend", "friend_check_info");
 
    var FriendController = require("friend_controller");
 
    this.viewTag = SCENE_TAG.dialogue; //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
 
    this.win_type = WinType.Mini; //是否是全屏窗体  WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
 
    this.ctrl = FriendController.getInstance();
    this.model = this.ctrl.getModel();
    this.item_list = {};
  },
  openCallBack: function openCallBack() {
    this.main_panel = this.root_wnd.getChildByName("main_panel");
    this.close_btn = this.main_panel.getChildByName("close_btn");
    this.friend_btn = this.main_panel.getChildByName("friend_btn");
    this.black_btn = this.main_panel.getChildByName("black_btn");
    this.pk_btn = this.main_panel.getChildByName("pk_btn");
    this.pk_btn_label = this.pk_btn.getChildByName("Label").getComponent(cc.Label);
    this.friend_btn_label = this.friend_btn.getChildByName("Label").getComponent(cc.Label);
    this.black_btn_label = this.black_btn.getChildByName("Label").getComponent(cc.Label);
    this.report_btn = this.main_panel.getChildByName("report_btn");
    this.pk_btn_label.string = Utils.TI18N("切磋");
    this.background = this.seekChild("background");
    this.background.scale = FIT_SCALE;
    this.info_con = this.main_panel.getChildByName("info_con");
    this.name_lb = this.info_con.getChildByName("name").getComponent(cc.Label);
    this.rank_lb = this.info_con.getChildByName("rank").getComponent(cc.Label);
    this.rank_lb.string = Utils.TI18N("暂无");
    this.guild_lb = this.info_con.getChildByName("guild").getComponent(cc.Label);
    this.guild_lb.string = Utils.TI18N("暂无");
    this.glory_btn = this.info_con.getChildByName("glory_btn");
    this.at_btn = this.info_con.getChildByName("at_btn");
    this.at_btn.active = false;
    this.country = this.info_con.getChildByName("country");
    this.main_container = this.main_panel.getChildByName("main_container"); //头像
 
    if (this.head == null) {
      this.head = new PlayerHead();
      this.head.setParent(this.info_con);
      this.head.show();
      this.head.setPosition(-227, 50);
    }
 
    this.vip_label_cr = this.seekChild(this.main_panel, "vip_label").getComponent("CusRichText");
    this.fight_label_cr = this.seekChild(this.main_container, "fight_label").getComponent("CusRichText");
    this.scrollCon_nd = this.seekChild("scrollCon");
    this.scrollCon_content_nd = this.seekChild(this.scrollCon_nd, "content");
    this.scroll_view_size = this.scrollCon_nd.getContentSize();
    this.scroll_view_sv = this.scrollCon_nd.getComponent(cc.ScrollView); // this.scrollCon_content_nd.setContentSize(cc.size(this.scroll_view_size.width - 10,this.scroll_view_size.height))
  },
  registerEvent: function registerEvent() {
    if (this.close_btn) {
      this.close_btn.on(cc.Node.EventType.TOUCH_END, function () {
        this.ctrl.openFriendCheckPanel(false);
        Utils.playButtonSound(2);
      }.bind(this));
    }
 
    if (this.glory_btn) {
      this.glory_btn.on(cc.Node.EventType.TOUCH_END, function () {
        Utils.playButtonSound(1);
        this.ctrl.openFriendGloryWindow(true, this.data);
      }.bind(this));
    }
 
    if (this.friend_btn) {
      this.friend_btn.on(cc.Node.EventType.TOUCH_END, function () {
        Utils.playButtonSound(1);
 
        if (this.model.isFriend(this.data.srv_id, this.data.rid)) {
          ChatController.getInstance().openChatPanel(ChatConst.Channel.Friend, "friend", this.data);
          this.ctrl.openFriendCheckPanel(false);
        } else {
          this.ctrl.openFriendCheckPanel(false);
          this.ctrl.addOther(this.data.srv_id, this.data.rid);
        }
      }.bind(this));
    }
 
    if (this.pk_btn) {
      this.pk_btn.on(cc.Node.EventType.TOUCH_END, function () {
        Utils.playButtonSound(1);
 
        if (this.data) {
          if (!BattleController.getInstance().getWatchReplayStatus() && !BattleController.getInstance().getModel().getFightStatus()) {
            BattleController.getInstance().csBattlePk(this.data.rid, this.data.srv_id);
          } else {
            message(Utils.TI18N("正在观看录像或者切磋中,请先退出"));
          }
        }
      }.bind(this));
    }
 
    if (this.black_btn) {
      this.black_btn.on(cc.Node.EventType.TOUCH_END, function () {
        Utils.playButtonSound(1);
 
        if (this.model.isBlack(this.data.rid, this.data.srv_id)) {
          ChatController.getInstance().closeChatPanel();
          this.ctrl.openFriendCheckPanel(false);
          this.ctrl.openFriendWindow(true, FriendConst.Type.BlackList);
        } else {
          this.ctrl.addToBlackList(this.data.rid, this.data.srv_id);
          this.ctrl.openFriendCheckPanel(false);
        }
      }.bind(this));
    }
 
    if (this.report_btn) {
      this.report_btn.on("click", function () {
        Utils.playButtonSound(1);
        this.onClickReportBtn();
      }.bind(this));
    } //接受数据
 
 
    cc.log(this.updateEvent, "this.updateEvent");
 
    if (this.updateEvent == null) {
      this.updateEvent = gcore.GlobalEvent.bind(RoleEvent.DISPATCH_PLAYER_VO_EVENT, function (data) {
        if (data.rid == this.rid && data.srv_id == this.srv_id) {
          this.updateData(data);
        }
      }.bind(this));
    }
 
    if (this.at_btn) {
      this.at_btn.on(cc.Node.EventType.TOUCH_END, function () {
        Utils.playButtonSound(1);
 
        if (this.data && this.data.name) {
          ChatController.getInstance().chatAtPeople(this.data.name, this.data.srv_id);
          this.ctrl.openFriendCheckPanel(false);
        }
      }.bind(this));
    }
  },
  openRootWnd: function openRootWnd(data) {
    if (data == null) return;
    this.rid = data.rid;
    this.srv_id = data.srv_id;
    this.flag = data.flag;
    this.channel = data.channel; //从聊天窗口打开时需要显示@按钮
 
    if (data && data.rid != null && data.srv_id != null) {
      RoleController.getInstance().requestRoleInfo(data.rid, data.srv_id);
    }
 
    if (data.channel) this.at_btn.active = true;
  },
  updateData: function updateData(data) {
    this.data = data;
    this.name_lb.string = Utils.transformNameByServ(data.name, data.srv_id);
    this.country.x = this.name_lb.node.x + this.name_lb.node.width + 5;
    this.head.setHeadRes(data.face_id);
    this.head.setLev(data.lev);
    this.head.setSex(data.sex, cc.v2(20, -50));
    if (data.gname != "") this.guild_lb.string = data.gname; //头像框
 
    var vo = gdata("avatar_data", "data_avatar", [data.avatar_bid]);
 
    if (vo) {
      var res_id = vo.res_id || 0;
      var res = PathTool.getHeadcircle(res_id);
      this.head.setFrameRes(res);
    }
 
    this.vip_label_cr.setNum(data.vip_lev);
    this.fight_label_cr.setNum(data.power);
    if (this.model.isFriend(data.srv_id, data.rid)) this.friend_btn_label.string = Utils.TI18N("私聊");else this.friend_btn_label.string = Utils.TI18N("加为好友");
    if (this.model.isBlack(data.rid, data.srv_id)) this.black_btn_label.string = Utils.TI18N("黑名单");else this.black_btn_label.string = Utils.TI18N("加黑名单");
    this.createPartnerList(data.partner_list);
  },
  createPartnerList: function createPartnerList(list) {
    var temp = [];
 
    for (var k in list) {
      var v = list[k];
      var vo = new HeroVo();
      vo.updateHeroVo(v);
      temp.push(vo);
    }
 
    var p_list_size = temp.length;
    var total_width = p_list_size * 104 + (p_list_size - 1) * 6;
    var start_x = 8;
    var partner_item = null;
    var max_width = Math.max(total_width, this.scroll_view_size.width);
    this.scrollCon_content_nd.setContentSize(cc.size(max_width, this.scroll_view_size.height));
 
    for (var i = 0; i < temp.length; ++i) {
      var v = temp[i];
 
      if (this.item_list[i] == null) {
        partner_item = ItemsPool.getInstance().getItem("hero_exhibition_item");
        partner_item.setRootScale(0.8);
        partner_item.show();
        partner_item.setPosition(start_x + 104 * 0.5 + i * (104 + 6), this.scroll_view_size.height * 0.5);
        partner_item.setData(v);
        partner_item.setParent(this.scrollCon_content_nd);
        this.item_list[i] = partner_item;
        partner_item.addCallBack(function (item) {
          var vo = item.getData();
 
          if (vo && Utils.next(vo) != null) {
            var partner_id = vo.partner_id;
 
            if (partner_id == 0) {
              partner_id = vo.id;
            }
 
            var rid = this.data.rid;
            var srv_id = this.data.srv_id;
 
            require("look_controller").getInstance().sender11061(rid, srv_id, partner_id);
          }
        }.bind(this));
      }
    }
  },
  onClickReportBtn: function onClickReportBtn() {
    if (!this.data) return;
    var role_lv_cfg = Config.role_data.data_role_const.role_reported_lev_limit;
    var role_vo = RoleController.getInstance().getRoleVo() || {};
    var lev = role_vo.lev || 0;
 
    if (role_lv_cfg && lev < role_lv_cfg.val) {
      message(role_lv_cfg.val + Utils.TI18N("级开放举报功能"));
      return;
    }
 
    RoleController.getInstance().openRoleReportedPanel(true, this.data.rid, this.data.srv_id, this.data.name);
  },
  closeCallBack: function closeCallBack() {
    for (var k in this.item_list) {
      var v = this.item_list[k];
      v.deleteMe();
      v = null;
    }
 
    this.item_list = null;
    if (this.head) this.head.deleteMe();
    this.head = null;
 
    if (this.updateEvent) {
      gcore.GlobalEvent.unbind(this.updateEvent);
      this.updateEvent = null;
    }
 
    this.ctrl.openFriendCheckPanel(false);
  }
});
module.exports = FriendCheckInfoWindow;
 
cc._RF.pop();