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
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-02-26 21:07:32
// --------------------------------------------------------------------
var VipEvent = require("vip_event");
 
var VipModel = cc.Class({
    extends: BaseClass,
    ctor: function () {
    },
 
    properties: {
    },
 
    initConfig: function () {
        this.get_list = {};
        this.daily_gift = {};
        this.privilege_list = {};
    },
 
    //vip礼包信息
    setGetGiftList:function(list){
        if(list && Utils.getArrLen(list) > 0){
            for(var k in list){
                var v = list[k];
                this.get_list[v.lev] = v.lev;
            }
        }
        gcore.GlobalEvent.fire(VipEvent.UPDATE_GET_LIST);
    },
 
    getGetGiftList:function(){
        return this.get_list || {};
    },
 
    //累充信息
    setAccList:function(list){
        this.acc_list = list;
    },
 
    getAccList:function(){
        return this.acc_list
    },
 
    checkGiftList:function(vip_lev){
        for(var i in this.get_list){
            var v = this.get_list[i];
            if(v==vip_lev){
                return true
            }
        }
        return false
    },
 
    getGiftListVip:function(){
        var vip_lev = 1;
        var list = [];
        if(Config.vip_data.data_vip_icon){
            for (var i in Config.vip_data.data_vip_icon){
                var v = gdata("vip_data","data_vip_icon",[i]);
                list.push(v);
            }
        }
        list.sort(Utils.tableLowerSorter(["vip_lev"]));
        for(var i in list){
            var v = list[i];
            var is_get = this.checkGiftList(v.vip_lev);
            if(!is_get){
                vip_lev = v.vip_lev;
                break
            }
        }
        return vip_lev
    },
 
    //是否有未领取累充礼包
    getIsGetAcc:function(){
        if(this.acc_lsit && Utils.next(this.acc_list)!= null){
            var index = 0;
            for (var k in this.acc_list){
                var v = this.acc_list[k];
                if(v.status == 1){  //可领取
                    return true
                }else if (v.status == 0 || v.status == 2){  //未达成/已领取
                    index = index + 1;
                }
            }
            if(index == Utils.getArrLen(this.acc_list)){
                return false
            }
        }
        return false
    },
 
    //每日礼包数据
    setDailyGiftData:function(data){
        this.daily_gift = data || {};
    },
 
    //获取每日礼包已购数量
    getDailyGiftBuyCountById:function(id){
        var count = 0;
        for(var k in this.daily_gift){
            var v = this.daily_gift[k]
            if(v.id == id){
                count = v.count;
                break
            }
        }
        return count
    },
 
    //特权礼包数据
    setPrivilegeList:function(data){
        this.privilege_list = data || {};
    },
 
    //获取特权礼包数据
    getPrivilegeDataById:function(id){
        for (var k in this.privilege_list){
            if(this.privilege_list[k].id == id){
                return this.privilege_list[k]
            }
        }
    },
 
    //获取特权礼包红点
    getPrivilegeRedStatus:function(){
        var privelege_red = false;
        //登陆时未购买过vip特权礼包的需要显示红点
        if(!this.privilege_flag){
            privelege_red = true;
            for(var k in this.privilege_list){
                if(this.privilege_list[k].status == 1){
                    privelege_red = false;
                    break
                }
            }
        }
        return privelege_red
    },
 
    //记录打开过vip特权礼包界面
    setPrivilegeOpenFlag:function(flag){
        this.privilege_flag = flag;
    },
 
    //月卡领取
    setMonthCard:function(status){
        this.monthCard = status
    },
 
    getMonthCard:function(){
        var status = false;
        this.monthCard = this.monthCard || 0;
        if(this.monthCard == 1){
            status = true;
        }else{
            status = false
        }
        return status
    },
 
    //赠送Vip数据
    setGiveVipInfo:function(data){
        this.giveVipInfo = data;
    },
 
    //获取赠送Vip数据
    getGiveVipInfo:function(){
        return this.giveVipInfo;
    },
 
    //赠送Vip的状态
    setGiveVipStatus(){
        var vipGiveInfo = this.getGiveVipInfo();
        var status = false;
        if(vipGiveInfo){
            var refresh = vipGiveInfo.time -gcore.SmartSocket.getTime();
            if(vipGiveInfo.state == 0 && refresh<=0){
                status = true;
            }
        }
        this.giveVipRedStatus = status;
        var MainuiController    = require("mainui_controller");
        var MainuiConst = require("mainui_const");
        MainuiController.getInstance().setFunctionTipsStatus(MainuiConst.icon.give_vip, status)
    },
 
    getGiveVipStatus(){
        if(this.giveVipRedStatus == null)return false;
        return this.giveVipRedStatus;
    },
 
});