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
"use strict";
cc._RF.push(module, '615e39yOiJIQY27u6DmUAVT', 'chat_friend');
// Scripts/mod/chat/view/chat_friend.js
 
"use strict";
 
var CommonAlert = require("commonalert");
 
var ChatItem = cc.Class({
  "extends": BaseView,
  properties: {
    friend_vo: null,
    // 好友数据
    parent: null,
    // 父节点
    select_cb: null,
    // 选择回调
    delete_cb: null,
    // 关闭回调
    index: "",
    is_select: false,
    head_path: null
  },
  ctor: function ctor() {
    this.friend_vo = arguments[0];
    this.parent = arguments[1];
    this.is_select = arguments[2];
    this.index = this.friend_vo.srv_id + this.friend_vo.rid;
    this.initRootWind();
  },
  initRootWind: function initRootWind() {
    var prefab_path = PathTool.getPrefabPath("chat", "chat_friend");
    LoaderManager.getInstance().loadRes(prefab_path, function (res_object) {
      this.root_wnd = res_object;
      this.parent.addChild(this.root_wnd);
      this.initWidget();
    }.bind(this));
  },
  initWidget: function initWidget() {
    this.head_sp = this.seekChild("head_icon", cc.Sprite);
    this.level_lb = this.seekChild("level", cc.Label);
    this.close_nd = this.seekChild("close_btn");
    this.bg_nd = this.seekChild("bg_nd");
    this.name_lb = this.seekChild("name", cc.Label);
    this.mask_bg_nd = this.seekChild("mask_bg");
 
    if (this.is_select) {
      this.mask_bg_nd.active = false;
    } else {
      this.mask_bg_nd.active = true;
    }
 
    this.close_nd.on(cc.Node.EventType.TOUCH_END, this.deleteItem.bind(this));
    this.bg_nd.on(cc.Node.EventType.TOUCH_END, this.selectItem.bind(this));
    this.updateWidget();
  },
  updateWidget: function updateWidget() {
    this.head_path = PathTool.getHeadRes(this.friend_vo.face_id);
    LoaderManager.getInstance().loadRes(this.head_path, function (res_object) {
      this.head_sp.spriteFrame = res_object;
    }.bind(this));
    this.level_lb.string = this.friend_vo.lev || "";
    this.name_lb.string = this.friend_vo.name || "";
  },
  setSelectCallback: function setSelectCallback(s_cb) {
    this.select_cb = s_cb;
  },
  setDeleteCallBack: function setDeleteCallBack(d_cb) {
    this.delete_cb = d_cb;
  },
  selectItem: function selectItem() {
    if (this.select_cb) this.select_cb(this.index, this.friend_vo);
  },
  cancelSelcet: function cancelSelcet() {
    this.mask_bg_nd.active = true;
  },
  setSelectStatus: function setSelectStatus() {
    this.mask_bg_nd.active = false;
  },
  deleteItem: function deleteItem() {
    // LoaderManager.getInstance().loadRes(this.head_path);
    var str = Utils.TI18N("确定要删除该好友的所有聊天记录吗?");
 
    var fun = function () {
      if (this.delete_cb) this.delete_cb(this.index, this.friend_vo);
      this.root_wnd.destroy();
    }.bind(this);
 
    CommonAlert.show(str, Utils.TI18N("确认"), fun, Utils.TI18N("取消"), null, 2, null);
  }
});
 
cc._RF.pop();