import { _decorator, Component, Node } from 'cc'; import { item_type, shop_item_type, xiaoxi_haoyou_status_type, xiaoxi_item_type } from '../constant'; import { GameMng } from '../GameMng'; import { Tools } from '../Tools'; const { ccclass, property } = _decorator; @ccclass('xinxiDataConfig') export default class xinxiDataConfig { private static _instance: xinxiDataConfig | null = null; public static get Instance() { if (xinxiDataConfig._instance === null){ xinxiDataConfig._instance = new xinxiDataConfig(); xinxiDataConfig._instance.initItem() } return xinxiDataConfig._instance; } public getItemById(id:string):xiaoxiData{ return xinxiDataConfig.Instance.item_config.get(id) } public getItems():xiaoxiData[]{ let array = [] if(GameMng._userData!=null){ for (let index = 0; index < GameMng._userData.online_friend_list.length; index++) { const firend = GameMng._userData.online_friend_list[index]; let firend_xiaoxi = new xiaoxiData() firend_xiaoxi.id = firend.userid+""; firend_xiaoxi.name = firend.user_name; firend_xiaoxi.status = Tools.getUserStatusNameByStatus(firend.cur_status) firend_xiaoxi.status_type = firend.cur_status firend_xiaoxi.type = xiaoxi_item_type.haoyou firend_xiaoxi.user_avatar = firend.user_avatar xinxiDataConfig.Instance.item_config.set(firend_xiaoxi.id,firend_xiaoxi) array.push(firend_xiaoxi) } } for (let j = 2; j <= 4; j++) { array.push(xinxiDataConfig.Instance.getItemById((1000+j).toString())) } for (let j = 2; j <= 4; j++) { array.push(xinxiDataConfig.Instance.getItemById((1000+j).toString())) } return array } public item_config = new Map(); initItem(){ let _1002 = new xiaoxiData() _1002.id = "1002"; _1002.name = "视频课程" _1002.des = "好口碑!买年卡返100元京东卡!" _1002.jump_des = "【招生】当肥冬季特训2月11日开课!" _1002.time = "一分钟以内" _1002.type = xiaoxi_item_type.shipin xinxiDataConfig.Instance.item_config.set(_1002.id,_1002) let _1004 = new xiaoxiData() _1004.id = "1004"; _1004.name = "视频课程" _1004.des = "人机小白不服气,请大侠赐教!" _1004.jump_des = "【人机挑战】" _1004.time = "一分钟以内" _1004.type = xiaoxi_item_type.shipin xinxiDataConfig.Instance.item_config.set(_1004.id,_1004) let _1003 = new xiaoxiData() _1003.id = "1003"; _1003.name = "残局挑战" _1003.des = "伦敦市仅1289人能破" _1003.jump_des = "【残局挑战】" _1003.time = "一分钟以内" _1003.type = xiaoxi_item_type.canju xinxiDataConfig.Instance.item_config.set(_1003.id,_1003) } } export class xiaoxiData{ public name:string=""; public url:string =""; public type:number= 0; public status_type:number= xiaoxi_haoyou_status_type._null; public status:string=""; public des:string=""; public jump_des:string=""; public user_avatar:string =""; public time:string=""; public id:string=""; public num:number=0; }