list.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. Page({
  9. data: {
  10. version: app.globalData.version,
  11. FileUrl: app.globalData.fileUrl,
  12. filter:'all',
  13. IsShowMenu:false,
  14. CategoryID:1,
  15. },
  16. onLoad: function(options) {
  17. categoryID = options.id;
  18. categoryName = options.name;
  19. categoryNum = options.num;
  20. //console.log(category);
  21. this.getList();
  22. this.setData({
  23. CategoryNum:categoryNum,
  24. CategoryID: categoryID,
  25. Containnerheight: server.getWindowHeight(),
  26. });
  27. },
  28. getList: function() {
  29. this.buildList();
  30. wx.setNavigationBarTitle({
  31. title: categoryName + " 题卡仓库",
  32. });
  33. },
  34. gotoDetail:function(e){
  35. SelectID = e.currentTarget.dataset.id;
  36. var arr = wx.getStorageSync('SelectIDArray');
  37. if (!arr)
  38. arr=[];
  39. for(var i=0;i<arr.length;i++){
  40. if (arr[i] == SelectID){
  41. arr.splice(i,0);
  42. break;
  43. }
  44. }
  45. arr.push(SelectID);
  46. wx.setStorageSync('SelectIDArray', arr);
  47. this.buildList();
  48. wx.navigateTo({
  49. url: '../main/detail?id=' + SelectID,
  50. });
  51. },
  52. buildList:function(){
  53. var that=this;
  54. var arrID = categoryID.split(",");
  55. var list = [];
  56. var data = wx.getStorageSync('QuestionTypeList');
  57. var arr = wx.getStorageSync('SelectIDArray');
  58. for (var i = 0; i < data.length; i++) {
  59. for (var j = 0; j < arrID.length; j++) {
  60. if (data[i].ID == arrID[j]) {
  61. for (var k = 0; k < data[i].List.length; k++) {
  62. data[i].List[k].CategoryLevel = data[i].Name;
  63. for (var n = 0; n < arr.length; n++) {
  64. //data[i].List[k].SelectItem = "";
  65. if (arr[n] == data[i].List[k].ID){
  66. data[i].List[k].SelectItem ="boxLeft";
  67. }
  68. }
  69. data[i].List[k].Select = false;
  70. if (SelectID == data[i].List[k].ID)
  71. data[i].List[k].Select = true;
  72. if (this.data.filter == "vertical"){
  73. if (data[i].List[k].QuestionNumber3>0)
  74. list.push(data[i].List[k]);
  75. }
  76. else{
  77. list.push(data[i].List[k]);
  78. }
  79. }
  80. break;
  81. }
  82. }
  83. }
  84. this.setData({
  85. QuestionTypeList: list,
  86. });
  87. setTimeout(function(){
  88. var query = wx.createSelectorQuery();
  89. query.select('.line4').boundingClientRect();
  90. query.exec(function (res) {
  91. //console.log("top2:" + (res[0].top));
  92. var LineLongHeight = Number(res[0].top) * 2-200;
  93. // if (that.data.CategoryNum == 1 )
  94. // LineLongHeight+=430;
  95. // else if (that.data.CategoryNum == 2)
  96. // LineLongHeight += 320;
  97. // else if (that.data.CategoryNum == 3)
  98. // LineLongHeight += 280;
  99. // else if (that.data.CategoryNum == 4)
  100. // LineLongHeight += 30;
  101. console.log("LineLongHeight:" + LineLongHeight);
  102. that.setData({
  103. LineLongHeight: LineLongHeight,
  104. });
  105. });
  106. },200);
  107. },
  108. menuClick:function(e){
  109. this.data.filter = e.currentTarget.dataset.id;
  110. this.setData({
  111. filter: this.data.filter,
  112. IsShowMenu: false,
  113. });
  114. this.buildList();
  115. },
  116. closeMenu: function () {
  117. this.setData({
  118. IsShowMenu: false,
  119. });
  120. },
  121. openMenu: function () {
  122. this.setData({
  123. IsShowMenu: true,
  124. });
  125. },
  126. onShareAppMessage: function() {
  127. return {
  128. title: app.globalData.ShareTitle,
  129. path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
  130. imageUrl: app.globalData.ShareImageUrl,
  131. }
  132. },
  133. })