list.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import common from '../../utils/util';
  2. import server from '../../utils/main';
  3. const app = getApp();
  4. var categoryID = "";
  5. var categoryName = "";
  6. var categoryNum = "";
  7. var SelectID = 0;
  8. var arrDifficult = ["", "", "简单", "普通", "困难"];
  9. Page({
  10. data: {
  11. version: app.globalData.Version,
  12. filter: 'all',
  13. CategoryID: 1,
  14. CategoryNum: 1,
  15. },
  16. onLoad: function (options) {
  17. var that = this;
  18. categoryID = options.id;
  19. categoryName = options.name;
  20. categoryNum = options.num;
  21. //console.log(category);
  22. common.getStorageValue(this, "HelpHidden2", false, function () {
  23. that.showHelp();
  24. });
  25. this.setData({
  26. CategoryNum: categoryNum,
  27. CategoryID: categoryID,
  28. Containnerheight: server.getWindowHeight(),
  29. });
  30. },
  31. onShow: function(){
  32. if (app.globalData.IsRefresh) {
  33. wx.showLoading({
  34. title: '请稍候',
  35. mask: true,
  36. });
  37. setTimeout(function () {
  38. wx.hideLoading();
  39. }, 3000);
  40. app.globalData.IsRefresh = false;
  41. }
  42. this.getList();
  43. },
  44. onUnload: function () {
  45. this.closeHelp();
  46. },
  47. getList: function () {
  48. this.buildList();
  49. },
  50. gotoDetail: function (e) {
  51. server.playSound("/sounds/click.mp3");
  52. var locked = e.currentTarget.dataset.locked;
  53. if (locked) {
  54. wx.navigateTo({
  55. url: '../../package4/main/buyad',
  56. });
  57. }
  58. else {
  59. SelectID = e.currentTarget.dataset.id;
  60. var arr = wx.getStorageSync('SelectIDArray');
  61. if (!arr)
  62. arr = [];
  63. for (var i = 0; i < arr.length; i++) {
  64. if (arr[i] == SelectID) {
  65. arr.splice(i, 0);
  66. break;
  67. }
  68. }
  69. arr.push(SelectID);
  70. wx.setStorageSync('SelectIDArray', arr);
  71. this.buildList();
  72. wx.navigateTo({
  73. url: '../main/detail?id=' + SelectID,
  74. });
  75. }
  76. this.closeHelp();
  77. },
  78. buildList: function () {
  79. var that = this;
  80. var arrID = categoryID.split(",");
  81. var list = [];
  82. var data = wx.getStorageSync('QuestionTypeList');
  83. var arr = wx.getStorageSync('SelectIDArray');
  84. for (var i = 0; i < data.length; i++) {
  85. for (var j = 0; j < arrID.length; j++) {
  86. if (data[i].ID == arrID[j]) {
  87. for (var k = 0; k < data[i].List.length; k++) {
  88. data[i].List[k].CategoryLevel = data[i].Name;
  89. data[i].List[k].IconName = app.globalData.fileUrl + data[i].List[k].IconName;
  90. data[i].List[k].SelectItem = "boxCenter";
  91. for (var n = 0; n < arr.length; n++) {
  92. if (arr[n] == data[i].List[k].ID) {
  93. data[i].List[k].SelectItem = "boxLeft";
  94. }
  95. }
  96. data[i].List[k].DifficultyName = arrDifficult[Number(data[i].List[k].Difficulty)];
  97. data[i].List[k].Select = false;
  98. if (SelectID == data[i].List[k].ID)
  99. data[i].List[k].Select = true;
  100. if (k > 0 && app.globalData.userInfo.IsShow == 1 && app.globalData.IsLocked==1 && app.globalData.userInfo.IsMember==0) {
  101. data[i].List[k].IsLocked = true;
  102. data[i].List[k].LockCSS = "desaturate";
  103. }
  104. if (this.data.filter == "vertical") {
  105. if (data[i].List[k].QuestionNumber3 > 0)
  106. list.push(data[i].List[k]);
  107. }
  108. else {
  109. list.push(data[i].List[k]);
  110. }
  111. }
  112. break;
  113. }
  114. }
  115. }
  116. for (var j = 0; j < list.length; j++) {
  117. var item = list[j];
  118. switch (item.ID){
  119. case 167:
  120. case 174:
  121. case 166:
  122. case 190:
  123. case 191:
  124. case 192:
  125. case 193:
  126. case 164:
  127. case 165:
  128. case 195:
  129. item.CategoryLevel="乘除运算3级"
  130. break;
  131. }
  132. }
  133. this.setData({
  134. QuestionTypeList: list,
  135. });
  136. },
  137. openMenu: function (e) {
  138. this.data.filter = e.currentTarget.dataset.filter;
  139. this.setData({
  140. filter: this.data.filter,
  141. });
  142. this.buildList();
  143. },
  144. showHelp: function () {
  145. if (!this.data.HelpHidden2) {
  146. this.audioCtx = wx.createAudioContext('myAudio');
  147. var str = "这里是仓库,每一层货架的箱子里都有一个知识点,很有意思吧!如果看到一个叫“有竖式”的标签,说明该题型可以打印竖式计算题,想要快速定位所有竖式题目的话,点击顶层货架就能帮你筛选。请选一只箱子继续。";
  148. server.playAudio(this.audioCtx, str);
  149. }
  150. },
  151. closeHelp: function () {
  152. this.setData({
  153. HelpHidden2: true,
  154. });
  155. wx.setStorageSync("HelpHidden2", true);
  156. this.audioCtx = wx.createAudioContext('myAudio');
  157. this.audioCtx.pause();
  158. },
  159. onShareAppMessage: function () {
  160. return {
  161. title: app.globalData.ShareTitle,
  162. path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
  163. imageUrl: app.globalData.ShareImage,
  164. }
  165. },
  166. })