Activity.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. for (var i = 0; i < DataList.length; i++) {
  52. DataList[i][0] = i;
  53. this.m_ListCtrl.InsertListInfo(0, DataList[i]); //.push(i == 0)
  54. }
  55. //设置俱乐部公告标签
  56. if (ClubID) {
  57. var strTag = KindID > 1 ? '聯盟公告' : '俱樂部公告';
  58. var DataArr = [100, strTag, ClubID, '', 100];
  59. this.m_ListCtrl.InsertListInfo(0, DataArr); //.push(i == 0)
  60. }
  61. if (KindID) {
  62. var DataArr = [101, '專屬公告', ClubID, '', 100];
  63. this.m_ListCtrl.InsertListInfo(0, DataArr); //.push(i == 0)
  64. }
  65. }.bind(this));
  66. },
  67. OnChangeView: function (m_DataArr) {
  68. // if (Type == 1) {
  69. // this.$('ScrollView/view/content/RichText').active = true;
  70. // this.$('ScrollView/view/content/Sprite').active = false;
  71. // this.$('ScrollView/view/content/RichText@RichText').string = Url;
  72. // } else {
  73. // this.$('ScrollView/view/content/RichText').active = false;
  74. // this.$('ScrollView/view/content/Sprite').active = true;
  75. // var ImgUrl = window.PHP_HOME + '/HeadImage.php?url=' + Url;
  76. // this.$('ScrollView/view/content/Sprite@CustomImage').SetImageUrl(ImgUrl);
  77. // }
  78. if(m_DataArr[3]){this.$('ScrollView/view/content/RichText').active = true;}
  79. else {this.$('ScrollView/view/content/RichText').active = false;}
  80. if(m_DataArr[2]=='http://127.0.0.1:8081/') {this.$('ScrollView/view/content/Sprite').active = false;}
  81. else {this.$('ScrollView/view/content/Sprite').active = true;}
  82. this.$('ScrollView/view/content/RichText@RichText').string = m_DataArr[3];
  83. var ImgUrl = window.PHP_HOME + '/HeadImage.php?url=' + m_DataArr[2];
  84. this.$('ScrollView/view/content/Sprite@CustomImage').SetImageUrl(ImgUrl);
  85. },
  86. OnShowClubNotice: function (ClubID, type) {
  87. this.$('ScrollView/view/content/RichText').active = false;
  88. this.$('ScrollView/view/content/Sprite').active = false;
  89. this.ShowPrefabDLG("ClubNotice", null, function (Js) {
  90. Js.OnShowNotice(ClubID, type);
  91. });
  92. },
  93. ///////////////////////////////////////////////////////////////////
  94. //Pre js
  95. InitPre: function () {},
  96. SetPreInfo: function (ParaArr) { //
  97. this.m_DataArr = ParaArr;
  98. this.$('Background/Label@Label').string = ParaArr[1];
  99. this.$('Background/checkmark/Label@Label').string = ParaArr[1];
  100. if (ParaArr[0] == 0) {
  101. this.$('@Toggle').isChecked = false;
  102. this.$('@Toggle').check();
  103. }
  104. },
  105. OnClick_ShowData: function () {
  106. //加载联盟公告
  107. if (this.m_DataArr[4] == 100) {
  108. this.m_Hook.OnShowClubNotice(this.m_DataArr[2], this.m_DataArr[0] == 100 ? 0 : 1);
  109. return;
  110. }
  111. if (this.m_Hook['m_JsClubNotice']) this.m_Hook['m_JsClubNotice'].node.active = false;
  112. // var ViewIndex = 2;
  113. // if (this.m_DataArr[4] == 1) ViewIndex = 3;
  114. // this.m_Hook.OnChangeView(this.m_DataArr[ViewIndex], this.m_DataArr[4]);
  115. this.m_Hook.OnChangeView(this.m_DataArr);
  116. },
  117. });