Activity.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {},
  4. ctor: function () {
  5. this.m_ImgArr = new Array();
  6. this.m_nNeedUpdate = 0;
  7. },
  8. OnClicked_Toggle: function (Tag) {
  9. cc.gSoundRes.PlaySound('Button');
  10. this.m_nNeedUpdate = 1;
  11. },
  12. onLoad: function () {
  13. if (!this.m_Toggle) this.m_Toggle = this.$('Toggle@Toggle');
  14. if (this.m_Toggle) this.m_Toggle.node.active = false;
  15. },
  16. update: function () {
  17. if (this.m_nNeedUpdate > 0) {
  18. this.m_nNeedUpdate--;
  19. } else {
  20. return;
  21. }
  22. if (this.m_Toggle.isChecked) {
  23. cc.sys.localStorage.setItem(window.Key_ActivityPop, new Date().getTime());
  24. } else {
  25. cc.sys.localStorage.setItem(window.Key_ActivityPop, 0);
  26. }
  27. },
  28. OnShowData: function (LeagueID, ClubID, KindID) {
  29. if (this.m_Toggle) {
  30. if(LeagueID || ClubID || KindID) {
  31. this.m_Toggle.node.active = false;
  32. } else {
  33. this.m_Toggle.node.active = true;
  34. var ActivityPop = parseInt(cc.sys.localStorage.getItem(window.Key_ActivityPop));
  35. if (!ActivityPop) {
  36. this.m_Toggle.isChecked = false;
  37. } else {
  38. var last = new Date(ActivityPop);
  39. var cur = new Date();
  40. if (last.getFullYear() != cur.getFullYear() || last.getMonth() != cur.getMonth() || last.getDay() != cur.getDay()) {
  41. this.m_Toggle.isChecked = false;
  42. }
  43. }
  44. }
  45. }
  46. if (this.m_ListCtrl == null) this.m_ListCtrl = this.$('@CustomListCtrl');
  47. this.m_ListCtrl.InitList(0, 'Activity', this);
  48. var webUrl = `${window.PHP_HOME}/Activity.php?LeagueID=${LeagueID}&ClubID=${ClubID}`;
  49. WebCenter.GetData(webUrl, 60, function (data) {
  50. var DataList = JSON.parse(data);
  51. //console.log("活动DataList---",DataList)
  52. for (var i = 0; i < DataList.length; i++) {
  53. DataList[i][0] = i;
  54. this.m_ListCtrl.InsertListInfo(0, DataList[i]); //.push(i == 0)
  55. }
  56. //设置俱乐部公告标签
  57. if (ClubID) {
  58. var strTag = KindID > 1 ? '聯盟公告' : '俱樂部公告';
  59. var DataArr = [100, strTag, ClubID, '', 100];
  60. this.m_ListCtrl.InsertListInfo(0, DataArr); //.push(i == 0)
  61. }
  62. if (KindID) {
  63. var DataArr = [101, '專屬公告', ClubID, '', 100];
  64. this.m_ListCtrl.InsertListInfo(0, DataArr); //.push(i == 0)
  65. }
  66. }.bind(this));
  67. },
  68. OnChangeView: function (m_DataArr) {
  69. // if (Type == 1) {
  70. // this.$('ScrollView/view/content/RichText').active = true;
  71. // this.$('ScrollView/view/content/Sprite').active = false;
  72. // this.$('ScrollView/view/content/RichText@RichText').string = Url;
  73. // } else {
  74. // this.$('ScrollView/view/content/RichText').active = false;
  75. // this.$('ScrollView/view/content/Sprite').active = true;
  76. // var ImgUrl = window.PHP_HOME + '/HeadImage.php?url=' + Url;
  77. // this.$('ScrollView/view/content/Sprite@CustomImage').SetImageUrl(ImgUrl);
  78. // }
  79. if(m_DataArr[3]){this.$('ScrollView/view/content/RichText').active = true;}
  80. else {this.$('ScrollView/view/content/RichText').active = false;}
  81. if(m_DataArr[2]=='http://127.0.0.1:8081/') {this.$('ScrollView/view/content/Sprite').active = false;}
  82. else {this.$('ScrollView/view/content/Sprite').active = true;}
  83. this.$('ScrollView/view/content/RichText@RichText').string = m_DataArr[3];
  84. var ImgUrl = window.PHP_HOME + '/HeadImage.php?url=' + m_DataArr[2];
  85. this.$('ScrollView/view/content/Sprite@CustomImage').SetImageUrl(ImgUrl);
  86. },
  87. OnShowClubNotice: function (ClubID, type) {
  88. this.$('ScrollView/view/content/RichText').active = false;
  89. this.$('ScrollView/view/content/Sprite').active = false;
  90. this.ShowPrefabDLG("ClubNotice", null, function (Js) {
  91. Js.OnShowNotice(ClubID, type);
  92. });
  93. },
  94. ///////////////////////////////////////////////////////////////////
  95. //Pre js
  96. InitPre: function () {},
  97. SetPreInfo: function (ParaArr) { //
  98. this.m_DataArr = ParaArr;
  99. this.$('Background/Label@Label').string = ParaArr[1];
  100. this.$('Background/checkmark/Label@Label').string = ParaArr[1];
  101. if (ParaArr[0] == 0) {
  102. this.$('@Toggle').isChecked = false;
  103. this.$('@Toggle').check();
  104. }
  105. },
  106. OnClick_ShowData: function () {
  107. //加载联盟公告
  108. if (this.m_DataArr[4] == 100) {
  109. this.m_Hook.OnShowClubNotice(this.m_DataArr[2], this.m_DataArr[0] == 100 ? 0 : 1);
  110. return;
  111. }
  112. if (this.m_Hook['m_JsClubNotice']) this.m_Hook['m_JsClubNotice'].node.active = false;
  113. // var ViewIndex = 2;
  114. // if (this.m_DataArr[4] == 1) ViewIndex = 3;
  115. // this.m_Hook.OnChangeView(this.m_DataArr[ViewIndex], this.m_DataArr[4]);
  116. this.m_Hook.OnChangeView(this.m_DataArr);
  117. },
  118. });