xinxiDataConfig.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { _decorator, Component, Node } from 'cc';
  2. import { item_type, shop_item_type, xiaoxi_haoyou_status_type, xiaoxi_item_type } from '../constant';
  3. import { GameMng } from '../GameMng';
  4. import { Tools } from '../Tools';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('xinxiDataConfig')
  7. export default class xinxiDataConfig {
  8. private static _instance: xinxiDataConfig | null = null;
  9. public static get Instance() {
  10. if (xinxiDataConfig._instance === null){
  11. xinxiDataConfig._instance = new xinxiDataConfig();
  12. xinxiDataConfig._instance.initItem()
  13. }
  14. return xinxiDataConfig._instance;
  15. }
  16. public getItemById(id:string):xiaoxiData{
  17. return xinxiDataConfig.Instance.item_config.get(id)
  18. }
  19. public getItems():xiaoxiData[]{
  20. let array = []
  21. if(GameMng._userData!=null){
  22. for (let index = 0; index < GameMng._userData.online_friend_list.length; index++) {
  23. const firend = GameMng._userData.online_friend_list[index];
  24. let firend_xiaoxi = new xiaoxiData()
  25. firend_xiaoxi.id = firend.userid+"";
  26. firend_xiaoxi.name = firend.user_name;
  27. firend_xiaoxi.status = Tools.getUserStatusNameByStatus(firend.cur_status)
  28. firend_xiaoxi.status_type = firend.cur_status
  29. firend_xiaoxi.type = xiaoxi_item_type.haoyou
  30. firend_xiaoxi.user_avatar = firend.user_avatar
  31. xinxiDataConfig.Instance.item_config.set(firend_xiaoxi.id,firend_xiaoxi)
  32. array.push(firend_xiaoxi)
  33. }
  34. }
  35. for (let j = 2; j <= 4; j++) {
  36. array.push(xinxiDataConfig.Instance.getItemById((1000+j).toString()))
  37. }
  38. for (let j = 2; j <= 4; j++) {
  39. array.push(xinxiDataConfig.Instance.getItemById((1000+j).toString()))
  40. }
  41. return array
  42. }
  43. public item_config = new Map();
  44. initItem(){
  45. let _1002 = new xiaoxiData()
  46. _1002.id = "1002";
  47. _1002.name = "视频课程"
  48. _1002.des = "好口碑!买年卡返100元京东卡!"
  49. _1002.jump_des = "【招生】当肥冬季特训2月11日开课!"
  50. _1002.time = "一分钟以内"
  51. _1002.type = xiaoxi_item_type.shipin
  52. xinxiDataConfig.Instance.item_config.set(_1002.id,_1002)
  53. let _1004 = new xiaoxiData()
  54. _1004.id = "1004";
  55. _1004.name = "视频课程"
  56. _1004.des = "人机小白不服气,请大侠赐教!"
  57. _1004.jump_des = "【人机挑战】"
  58. _1004.time = "一分钟以内"
  59. _1004.type = xiaoxi_item_type.shipin
  60. xinxiDataConfig.Instance.item_config.set(_1004.id,_1004)
  61. let _1003 = new xiaoxiData()
  62. _1003.id = "1003";
  63. _1003.name = "残局挑战"
  64. _1003.des = "伦敦市仅1289人能破"
  65. _1003.jump_des = "【残局挑战】"
  66. _1003.time = "一分钟以内"
  67. _1003.type = xiaoxi_item_type.canju
  68. xinxiDataConfig.Instance.item_config.set(_1003.id,_1003)
  69. }
  70. }
  71. export class xiaoxiData{
  72. public name:string="";
  73. public url:string ="";
  74. public type:number= 0;
  75. public status_type:number= xiaoxi_haoyou_status_type._null;
  76. public status:string="";
  77. public des:string="";
  78. public jump_des:string="";
  79. public user_avatar:string ="";
  80. public time:string="";
  81. public id:string="";
  82. public num:number=0;
  83. }