index.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. Name: "一年级",
  49. Name2: "语文一年级",
  50. Select: "Select",
  51. List: [{
  52. ID: 1,
  53. Type: "Shizi",
  54. Name: "语文识字",
  55. Name2: "上学期",
  56. Finish: 0,
  57. Total: 12,
  58. Image: "../images/examine_subject_a001.png"
  59. }, {
  60. ID: 2,
  61. Type: "Shizi",
  62. Name: "语文识字",
  63. Name2: "下学期",
  64. Finish: 0,
  65. Total: 14,
  66. Image: "../images/examine_subject_a002.png"
  67. }, ]
  68. },
  69. {
  70. Name: "二年级",
  71. Name2: "语文二年级",
  72. Select: "",
  73. List: [{
  74. ID: 3,
  75. Type: "Shizi",
  76. Name: "语文识字",
  77. Name2: "上学期",
  78. Finish: 0,
  79. Total: 16,
  80. Image: "../images/examine_subject_a003.png"
  81. }, {
  82. ID: 4,
  83. Type: "Shizi",
  84. Name: "语文识字",
  85. Name2: "下学期",
  86. Finish: 0,
  87. Total: 16,
  88. Image: "../images/examine_subject_a004.png"
  89. }, ]
  90. },
  91. {
  92. Name: "三年级",
  93. Name2: "语文三年级",
  94. Select: "",
  95. List: [{
  96. ID: 5,
  97. Type: "Shizi",
  98. Name: "语文识字",
  99. Name2: "上学期",
  100. Finish: 0,
  101. Total: 16,
  102. Image: "../images/examine_subject_a005.png"
  103. }, {
  104. ID: 6,
  105. Type: "Shizi",
  106. Name: "语文识字",
  107. Name2: "下学期",
  108. Finish: 0,
  109. Total: 16,
  110. Image: "../images/examine_subject_a006.png"
  111. }, ]
  112. },
  113. {
  114. Name: "四年级",
  115. Name2: "语文四年级",
  116. Select: "",
  117. List: [{
  118. ID: 7,
  119. Type: "Shizi",
  120. Name: "语文识字",
  121. Name2: "上学期",
  122. Finish: 0,
  123. Total: 16,
  124. Image: "../images/examine_subject_a007.png"
  125. }, ]
  126. },
  127. {
  128. Name: "五年级",
  129. Name2: "语文五年级",
  130. Select: "",
  131. List: [{
  132. ID: 9,
  133. Type: "Shizi",
  134. Name: "语文识字",
  135. Name2: "上学期",
  136. Finish: 0,
  137. Total: 16,
  138. Image: "../images/examine_subject_a009.png"
  139. }, ]
  140. },
  141. {
  142. Name: "六年级",
  143. Name2: "语文六年级",
  144. Select: "",
  145. List: [
  146. {
  147. ID: 11,
  148. Type: "Shizi",
  149. Name: "语文识字",
  150. Name2: "上学期",
  151. Finish: 0,
  152. Total: 16,
  153. Image: "../images/examine_subject_a011.png"
  154. },
  155. ]
  156. },
  157. // {
  158. // Name: "英语常用词",
  159. // Name2: "英语常用词",
  160. // Select: "",
  161. // List: [
  162. // {
  163. // ID: 13,
  164. // Type: "Word",
  165. // Name: "常用词1",
  166. // Name2: "词汇1~220",
  167. // Finish: 0,
  168. // Total: 22,
  169. // Image: "../images/examine_subject_b001.png"
  170. // },
  171. // {
  172. // ID: 14,
  173. // Type: "Word",
  174. // Name: "常用词2",
  175. // Name2: "词汇221~500",
  176. // Finish: 0,
  177. // Total: 28,
  178. // Image: "../images/examine_subject_b002.png"
  179. // },
  180. // {
  181. // ID: 15,
  182. // Type: "Word",
  183. // Name: "常用词3",
  184. // Name2: "词汇500~1000",
  185. // Finish: 0,
  186. // Total: 25,
  187. // Image: "../images/examine_subject_b003.png"
  188. // },
  189. // ]
  190. // },
  191. ],
  192. })
  193. var userid = app.globalData.userInfo.UserID;
  194. main.getData('GetTestReportList?UserID=' + userid, function (data) {
  195. if (data) {
  196. var dataTemp = [];
  197. for (var i = 0; i < data.length; i++) {
  198. for (var j = 0; j < dataTemp.length; j++) {
  199. if (dataTemp[j].Name[0] == data[i].Name[0] &&
  200. dataTemp[j].Name[1] == data[i].Name[1] &&
  201. dataTemp[j].TestType == data[i].TestType &&
  202. data[i].IsFinished == 1
  203. ) {
  204. dataTemp.splice(j, 1);
  205. break;
  206. }
  207. }
  208. dataTemp.push(data[i]);
  209. }
  210. for (var i = 0; i < dataTemp.length; i++) {
  211. var name = dataTemp[i].Name[0].split(" ");
  212. for (var j = 0; j < that.data.GradeArr.length; j++) {
  213. var item = that.data.GradeArr[j];
  214. if (name[0] == item.Name) {
  215. for (var k = 0; k < item.List.length; k++) {
  216. if (name[1] == item.List[k].Name && name[2] == item.List[k].Name2) {
  217. if (dataTemp[i].IsFinished == 1)
  218. item.List[k].Finish++;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. for (var j = 0; j < that.data.GradeArr.length; j++) {
  225. var item = that.data.GradeArr[j];
  226. for (var k = 0; k < item.List.length; k++) {
  227. item.List[k].Finished = Math.round(100 * item.List[k].Finish / item.List[k].Total);
  228. }
  229. }
  230. that.setData({
  231. TestReport: data,
  232. GradeArr: that.data.GradeArr,
  233. });
  234. wx.setStorageSync("UserTestReport", data);
  235. common.getStorageValue(that, "TestSelectGrade", 0, function () {
  236. that.onSelectGrade({
  237. currentTarget: {
  238. dataset: {
  239. value: that.data.TestSelectGrade
  240. }
  241. }
  242. });
  243. });
  244. }
  245. });
  246. },
  247. onSelectGrade: function (e) {
  248. var index = e.currentTarget.dataset.value;
  249. for (var i = 0; i < this.data.GradeArr.length; i++)
  250. this.data.GradeArr[i].Select = "";
  251. this.data.GradeArr[index].Select = "Select";
  252. this.setData({
  253. TestSelectGrade: index,
  254. GradeArr: this.data.GradeArr,
  255. });
  256. this.closeSelectGrade();
  257. wx.setStorageSync("TestSelectGrade", index);
  258. },
  259. gotoTestReportInfo: function (e) {
  260. var id = e.currentTarget.dataset.id;
  261. var userid = app.globalData.userInfo.UserID;
  262. //todo
  263. // main.getData('GetTestReportInfo?UserID=' + userid+'&ID='+id, function (data) {
  264. // if (data) {
  265. // wx.setStorageSync("TestTask", data);
  266. // wx.navigateTo({
  267. // url: "./report?type=edit",
  268. // });
  269. // }
  270. // });
  271. main.GetTestReportInfo(id,function(data){
  272. wx.setStorageSync("TestTask", data);
  273. wx.navigateTo({
  274. url: "./report?type=edit",
  275. });
  276. });
  277. },
  278. onUnload: function () {
  279. wx.removeStorageSync("UserTestReport");
  280. },
  281. onShareAppMessage: function () {
  282. return {
  283. title: app.globalData.ShareTitle,
  284. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  285. imageUrl: app.globalData.ShareImage,
  286. }
  287. },
  288. })