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
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-04-16 15:45:17
// --------------------------------------------------------------------
var PromptEvent = require("prompt_event")
var PromptModel = cc.Class({
    extends: BaseClass,
    ctor: function () {
    },
 
    properties: {
    },
 
    initConfig: function () {
        this.prompt_list = [];
        this.auto_id = 0;
    },
    addPromptData(data){
        let config = Config.notice_data.data_get[data.type]
        if(config == null){
            cc.log("==============> 添加小图标失败, 未配置该小图标数据, 类型为 ", data.type)
            return 
        }
        let prompt_vo = null
        let obj = this.getSridByData(data)
        let cur_rid = obj.rid 
        let cur_srv_id = obj.srv_id
        if(this.checkIsInList(data.type, cur_rid, cur_srv_id) == true) return;
        this.auto_id = this.auto_id + 1
        let PromptVo = require("prompt_vo")
        if(config.can_overly == 1){
            prompt_vo = this.getPromptVoByType(data.type)
            if(prompt_vo == null){
                prompt_vo = new PromptVo(data.type, this.auto_id)
                this.prompt_list.push(prompt_vo)
            }
            prompt_vo.update(data)
        }else{
            prompt_vo = new PromptVo(data.type, this.auto_id)
            prompt_vo.update(data)
            this.prompt_list.push(prompt_vo)
        }
        gcore.GlobalEvent.fire(PromptEvent.ADD_PROMPT_DATA, prompt_vo);
    },
    getPromptVoByType(type){
        for(let i=0;i<this.prompt_list.length;++i){
            let v = this.prompt_list[i]
            if(v.type == type){
                return v
            }
        }
    },
    checkIsInList(type, rid, srv_id){
        for(let i=0;i<this.prompt_list.length;++i){
            let vo = this.prompt_list[i]
            if(vo.type == type){
                for(let k=0;k<vo.list.length;++k){
                    let v = vo.list[k]
                    let obj = vo.getSridByData(v.data)
                    let _rid = obj.rid
                    let _srv_id = obj.srv_id
                    let _rolename = obj.role_name
                    if(Utils.getNorKey(_rid, _srv_id) == Utils.getNorKey(rid, srv_id)){
                        return true
                    }
                }
            }
        }
        return false
    },
    getSridByData(data){
        let rid = 0, srv_id = "", role_name = "";
        let bbs_id = 0
        if(data && data.arg_uint32 && data.arg_uint32.length > 0){
            for(let i=0;i<data.arg_uint32.length;++i){
                let temp = data.arg_uint32[i]
                if(temp){
                    if(temp.key == 1){
                        rid = temp.value
                    }else if(temp.key == 2){
                        bbs_id = temp.value //留言板那边的..表示留言id
                    }
                }
            }    
        }
 
        if(data && data.arg_str && data.arg_str.length > 0){
            for(let i=0;i<data.arg_str.length;++i){
                let temp = data.arg_str[i]
                if(temp){
                    if(temp.key == 1){
                        srv_id = temp.value
                    }else if(temp.key == 2){
                        role_name = temp.value
                    }
                }
            }
        }
        return {rid:rid, srv_id:srv_id, role_name:role_name, bbs_id:bbs_id}
    },
    getPromptList(){
        return this.prompt_list
    },
    // -- 获取列表中是否有未气泡提示的消息
    getNotBubblePrompt(  ){
        for(let k=0;k<this.prompt_list.length;++k){
            let data = this.prompt_list[k]
            if(data.is_show_bubble == false){
                return data
            }
        }
    },
    //移除一个提示数据,根据类型和id移除
    removePromptData(type, id){
        if(this.prompt_list.length > 0){
            for(let i=0;i<this.prompt_list.length;++i){
                if(vo.type == type && vo.id == id){
                    this.prompt_list.splice(i,1)
                    break
                }
            }
            gcore.GlobalEvent.fire(PromptEvent.REMOVE_PROMPT_DATA)
        }
    },
    //根据类型去删除提示数据【例如通过好友图标打开好友界面时候去清理提示数据】
    removePromptDataByTpye(_type){
        if(this.prompt_list.length > 0){
            for(let i=0;i<this.prompt_list.length;++i){
                let vo = this.prompt_list[i]
                if(vo.type == _type){
                    this.prompt_list.splice(i,1)
                    break
                }
            }
            gcore.GlobalEvent.fire(PromptEvent.REMOVE_PROMPT_DATA)
        }
    },
 
    //检测类型是有灯泡
    checkPromptDataByTpye(_type){
        if(this.prompt_list.length > 0){
            for(let i=0;i<this.prompt_list.length;++i){
                let vo = this.prompt_list[i]
                if(vo.type == _type){
                    return true
                }
            }
        }
        return false
    },
});