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
"use strict";
cc._RF.push(module, 'b4d29m3uRlAvKK7Kusktn0z', 'invitecode_controller');
// Scripts/mod/invitecode/invitecode_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-04-27 17:52:15
// --------------------------------------------------------------------
var InviteCodeEvent = require("invitecode_event");
 
var InvitecodeController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var InvitecodeModel = require("invitecode_model");
 
    this.model = new InvitecodeModel();
    this.model.initConfig();
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {},
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    this.RegisterProtocal(19800, this.handle19800);
    this.RegisterProtocal(19801, this.handle19801);
    this.RegisterProtocal(19802, this.handle19802);
    this.RegisterProtocal(19803, this.handle19803);
    this.RegisterProtocal(19804, this.handle19804);
    this.RegisterProtocal(19805, this.handle19805);
    this.RegisterProtocal(19807, this.handle19807);
  },
  requestProto: function requestProto() {
    this.sender19800();
    this.sender19804();
    this.sender19802();
  },
  //个人邀请码
  sender19800: function sender19800() {
    this.SendProtocal(19800, {});
  },
  handle19800: function handle19800(data) {
    this.model.setInviteCode(data.code);
    gcore.GlobalEvent.fire(InviteCodeEvent.Get_InviteCode_Event);
  },
  //绑定邀请码
  sender19801: function sender19801(code) {
    var proto = {};
    proto.code = code;
    this.SendProtocal(19801, proto);
  },
  handle19801: function handle19801(data) {
    message(data.msg);
    gcore.GlobalEvent.fire(InviteCodeEvent.BindCode_Invite_Event, data);
  },
  //奖励信息
  sender19804: function sender19804() {
    this.SendProtocal(19804, {});
  },
  handle19804: function handle19804(data) {
    this.model.setInviteCodeTeskData(data.list); // this.getInviteCodeRepoint(data.list);
 
    gcore.GlobalEvent.fire(InviteCodeEvent.InviteCode_My_Event);
  },
  getInviteCodeRepoint: function getInviteCodeRepoint(data) {
    if (Utils.next(data) == null) return;
    var status = false;
 
    if (SHOW_SINGLE_INVICODE) {
      for (var i in data) {
        if (data[i] && data[i].num > data[i].had) {
          status = true;
          break;
        }
      }
    }
 
    var WelfareConst = require("welfare_const");
 
    require("welfare_controller").getInstance().setWelfareStatus(WelfareConst.WelfareIcon.invicode, status);
  },
  //奖励领取
  sender19805: function sender19805(id) {
    var proto = {};
    proto.id = id;
    this.SendProtocal(19805, proto);
  },
  handle19805: function handle19805(data) {
    message(data.msg);
 
    if (data.code == 1) {
      this.model.setUpdataInviteCodeTeskData(data);
      gcore.GlobalEvent.fire(InviteCodeEvent.InviteCode_My_Event);
    }
  },
  //绑定角色列表(已邀请的好友)
  sender19802: function sender19802() {
    this.SendProtocal(19802, {});
  },
  handle19802: function handle19802(data) {
    this.model.setAlreadyFriendData(data.list);
    gcore.GlobalEvent.fire(InviteCodeEvent.InviteCode_BindRole_Event);
  },
  //绑定角色列表(推送)
  handle19803: function handle19803(data) {
    this.model.setUpdataAlreadyFriendData(data);
    gcore.GlobalEvent.fire(InviteCodeEvent.InviteCode_BindRole_Updata_Event);
  },
  //自己所绑定的角色
  sender19807: function sender19807() {
    this.SendProtocal(19807, {});
  },
  handle19807: function handle19807(data) {
    this.model.addFriendChatData(data);
  }
});
module.exports = InvitecodeController;
 
cc._RF.pop();