index.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. List: [],
  7. IsSelectGrade: false,
  8. TestSelectGrade:0,
  9. },
  10. onLoad: function (options) {
  11. var that = this;
  12. that.setData({
  13. Containnerheight: main.getWindowHeight(),
  14. });
  15. main.getHanzi(function (arr) {
  16. if (!arr) {
  17. wx.removeStorageSync("HanziUpdateTime");
  18. wx.removeStorageSync("HanziAll");
  19. main.getHanzi(function(arr){});
  20. }
  21. });
  22. },
  23. onShow:function(){
  24. this.getTestReportList();
  25. },
  26. showSelectGrade: function () {
  27. var that = this;
  28. that.setData({
  29. IsSelectGrade: true,
  30. });
  31. },
  32. closeSelectGrade: function () {
  33. var that = this;
  34. that.setData({
  35. IsSelectGrade: false,
  36. });
  37. },
  38. goto: function (e) {
  39. var url = e.currentTarget.dataset.url;
  40. wx.navigateTo({
  41. url: url,
  42. });
  43. },
  44. getTestReportList: function () {
  45. var that = this;
  46. that.setData({
  47. GradeArr: [
  48. {
  49. Name: "一年级",
  50. Select: "Select",
  51. List: [
  52. {
  53. ID: 1,
  54. Type: "Shizi",
  55. Name: "语文识字",
  56. Name2: "上学期",
  57. Finish: 0,
  58. Total: 12,
  59. Image: "../images/examine_subject_a001.png"
  60. }, {
  61. ID: 2,
  62. Type: "Shizi",
  63. Name: "语文识字",
  64. Name2: "下学期",
  65. Finish: 0,
  66. Total: 14,
  67. Image: "../images/examine_subject_a002.png"
  68. },
  69. ]
  70. },
  71. {
  72. Name: "二年级",
  73. Select: "",
  74. List: [
  75. {
  76. ID: 3,
  77. Type: "Shizi",
  78. Name: "语文识字",
  79. Name2: "上学期",
  80. Finish: 0,
  81. Total: 16,
  82. Image: "../images/examine_subject_a003.png"
  83. }, {
  84. ID: 4,
  85. Type: "Shizi",
  86. Name: "语文识字",
  87. Name2: "下学期",
  88. Finish: 0,
  89. Total: 16,
  90. Image: "../images/examine_subject_a004.png"
  91. },
  92. ]
  93. },
  94. {
  95. Name: "三年级",
  96. Select: "",
  97. List: [
  98. {
  99. ID: 5,
  100. Type: "Shizi",
  101. Name: "语文识字",
  102. Name2: "上学期",
  103. Finish: 0,
  104. Total: 16,
  105. Image: "../images/examine_subject_a005.png"
  106. }, {
  107. ID: 6,
  108. Type: "Shizi",
  109. Name: "语文识字",
  110. Name2: "下学期",
  111. Finish: 0,
  112. Total: 16,
  113. Image: "../images/examine_subject_a006.png"
  114. },
  115. ]
  116. },
  117. // {
  118. // Name: "四年级",
  119. // Select: "",
  120. // List: [
  121. // {
  122. // ID: 7,
  123. // Type: "Shizi",
  124. // Name: "语文识字",
  125. // Name2: "上学期",
  126. // Finish: 0,
  127. // Total: 16,
  128. // Image: "../images/examine_subject_a005.png"
  129. // },
  130. // ]
  131. // },
  132. // {
  133. // Name: "五年级",
  134. // Select: "",
  135. // List: [
  136. // {
  137. // ID: 9,
  138. // Type: "Shizi",
  139. // Name: "语文识字",
  140. // Name2: "上学期",
  141. // Finish: 0,
  142. // Total: 16,
  143. // Image: "../images/examine_subject_a005.png"
  144. // },
  145. // ]
  146. // },
  147. // {
  148. // Name: "六年级",
  149. // Select: "",
  150. // List: [
  151. // {
  152. // ID: 11,
  153. // Type: "Shizi",
  154. // Name: "语文识字",
  155. // Name2: "上学期",
  156. // Finish: 0,
  157. // Total: 16,
  158. // Image: "../images/examine_subject_a005.png"
  159. // },
  160. // ]
  161. // }
  162. ],
  163. })
  164. var userid = app.globalData.userInfo.UserID;
  165. main.getData('GetTestReportList?UserID=' + userid, function (data) {
  166. if (data) {
  167. var dataTemp=[];
  168. for (var i = 0; i < data.length; i++) {
  169. for(var j=0;j<dataTemp.length;j++){
  170. if (dataTemp[j].Name[0] == data[i].Name[0]
  171. && dataTemp[j].Name[1] == data[i].Name[1]
  172. && dataTemp[j].TestType == data[i].TestType
  173. && data[i].IsFinished==1
  174. ){
  175. dataTemp.splice(j,1);
  176. break;
  177. }
  178. }
  179. dataTemp.push(data[i]);
  180. }
  181. for (var i = 0; i < dataTemp.length;i++){
  182. var name = dataTemp[i].Name[0].split(" ");
  183. for(var j=0;j<that.data.GradeArr.length;j++){
  184. var item = that.data.GradeArr[j];
  185. if (name[0]==item.Name){
  186. for(var k=0;k<item.List.length;k++){
  187. if (name[1] == item.List[k].Name && name[2] == item.List[k].Name2){
  188. if (dataTemp[i].IsFinished==1)
  189. item.List[k].Finish++;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. for (var j = 0; j < that.data.GradeArr.length; j++) {
  196. var item = that.data.GradeArr[j];
  197. for (var k = 0; k < item.List.length; k++) {
  198. item.List[k].Finished = Math.round(100 * item.List[k].Finish / item.List[k].Total);
  199. }
  200. }
  201. that.setData({
  202. TestReport: data,
  203. GradeArr:that.data.GradeArr,
  204. });
  205. wx.setStorageSync("UserTestReport", data);
  206. common.getStorageValue(that, "TestSelectGrade", 0, function () {
  207. that.onSelectGrade({ currentTarget: { dataset: { value: that.data.TestSelectGrade } } });
  208. });
  209. }
  210. });
  211. },
  212. onSelectGrade:function(e){
  213. var index=e.currentTarget.dataset.value;
  214. for (var i = 0; i < this.data.GradeArr.length;i++)
  215. this.data.GradeArr[i].Select = "";
  216. this.data.GradeArr[index].Select="Select";
  217. this.setData({
  218. TestSelectGrade:index,
  219. GradeArr: this.data.GradeArr,
  220. });
  221. this.closeSelectGrade();
  222. wx.setStorageSync("TestSelectGrade", index);
  223. },
  224. gotoTestReportInfo: function (e) {
  225. var id = e.currentTarget.dataset.id;
  226. var userid = app.globalData.userInfo.UserID;
  227. main.getData('GetTestReportInfo?UserID=' + userid+'&ID='+id, function (data) {
  228. if (data) {
  229. wx.setStorageSync("TestTask", data);
  230. wx.navigateTo({
  231. url: "./report?type=edit",
  232. });
  233. }
  234. });
  235. },
  236. onUnload:function(){
  237. wx.removeStorageSync("UserTestReport");
  238. },
  239. onShareAppMessage: function () {
  240. return {
  241. title: app.globalData.ShareTitle,
  242. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  243. imageUrl: app.globalData.ShareImage,
  244. }
  245. },
  246. })