index.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. if (options.UserID){
  12. app.globalData.userInfo={};
  13. app.globalData.userInfo.UserID=options.UserID;
  14. }
  15. var that = this;
  16. that.setData({
  17. Containnerheight: main.getWindowHeight(),
  18. });
  19. main.getHanzi(function (arr) {
  20. if (!arr) {
  21. wx.removeStorageSync("HanziUpdateTime");
  22. wx.removeStorageSync("HanziAll");
  23. main.getHanzi(function (arr) {});
  24. }
  25. });
  26. },
  27. onShow: function () {
  28. this.getTestReportList();
  29. },
  30. showSelectGrade: function () {
  31. var that = this;
  32. that.setData({
  33. IsSelectGrade: true,
  34. });
  35. },
  36. closeSelectGrade: function () {
  37. var that = this;
  38. that.setData({
  39. IsSelectGrade: false,
  40. });
  41. },
  42. goto: function (e) {
  43. var url = e.currentTarget.dataset.url;
  44. wx.navigateTo({
  45. url: url,
  46. });
  47. },
  48. getTestReportList: function () {
  49. var that = this;
  50. that.setData({
  51. GradeArr: [{
  52. Name: "一年级",
  53. Name2: "语文一年级",
  54. Select: "Select",
  55. List: [{
  56. ID: 1,
  57. Type: "Shizi",
  58. Name: "语文识字",
  59. Name2: "上学期",
  60. Finish: 0,
  61. Total: 12,
  62. Image: "../images/examine_subject_a001.png"
  63. }, {
  64. ID: 13,
  65. Type: "Shizi",
  66. Name: "语文写字",
  67. Name2: "上学期",
  68. Finish: 0,
  69. Total: 26,
  70. Image: "../images/examine_subject_a001.png"
  71. }, {
  72. ID: 2,
  73. Type: "Shizi",
  74. Name: "语文识字",
  75. Name2: "下学期",
  76. Finish: 0,
  77. Total: 14,
  78. Image: "../images/examine_subject_a002.png"
  79. }, {
  80. ID: 14,
  81. Type: "Shizi",
  82. Name: "语文写字",
  83. Name2: "下学期",
  84. Finish: 0,
  85. Total: 28,
  86. Image: "../images/examine_subject_a002.png"
  87. }]
  88. },
  89. {
  90. Name: "二年级",
  91. Name2: "语文二年级",
  92. Select: "",
  93. List: [{
  94. ID: 3,
  95. Type: "Shizi",
  96. Name: "语文识字",
  97. Name2: "上学期",
  98. Finish: 0,
  99. Total: 16,
  100. Image: "../images/examine_subject_a003.png"
  101. }, {
  102. ID: 15,
  103. Type: "Shizi",
  104. Name: "语文写字",
  105. Name2: "上学期",
  106. Finish: 0,
  107. Total: 28,
  108. Image: "../images/examine_subject_a003.png"
  109. }, {
  110. ID: 4,
  111. Type: "Shizi",
  112. Name: "语文识字",
  113. Name2: "下学期",
  114. Finish: 0,
  115. Total: 16,
  116. Image: "../images/examine_subject_a004.png"
  117. }, {
  118. ID: 16,
  119. Type: "Shizi",
  120. Name: "语文写字",
  121. Name2: "下学期",
  122. Finish: 0,
  123. Total: 29,
  124. Image: "../images/examine_subject_a004.png"
  125. }]
  126. },
  127. {
  128. Name: "三年级",
  129. Name2: "语文三年级",
  130. Select: "",
  131. List: [{
  132. ID: 5,
  133. Type: "Shizi",
  134. Name: "语文识字",
  135. Name2: "上学期",
  136. Finish: 0,
  137. Total: 16,
  138. Image: "../images/examine_subject_a005.png"
  139. }, {
  140. ID: 17,
  141. Type: "Shizi",
  142. Name: "语文写字",
  143. Name2: "上学期",
  144. Finish: 0,
  145. Total: 28,
  146. Image: "../images/examine_subject_a005.png"
  147. }, {
  148. ID: 6,
  149. Type: "Shizi",
  150. Name: "语文识字",
  151. Name2: "下学期",
  152. Finish: 0,
  153. Total: 16,
  154. Image: "../images/examine_subject_a006.png"
  155. }, {
  156. ID: 18,
  157. Type: "Shizi",
  158. Name: "语文写字",
  159. Name2: "下学期",
  160. Finish: 0,
  161. Total: 21,
  162. Image: "../images/examine_subject_a006.png"
  163. }]
  164. },
  165. {
  166. Name: "四年级",
  167. Name2: "语文四年级",
  168. Select: "",
  169. List: [{
  170. ID: 7,
  171. Type: "Shizi",
  172. Name: "语文识字",
  173. Name2: "上学期",
  174. Finish: 0,
  175. Total: 16,
  176. Image: "../images/examine_subject_a007.png"
  177. }, {
  178. ID: 19,
  179. Type: "Shizi",
  180. Name: "语文写字",
  181. Name2: "上学期",
  182. Finish: 0,
  183. Total: 20,
  184. Image: "../images/examine_subject_a007.png"
  185. }, {
  186. ID: 8,
  187. Type: "Shizi",
  188. Name: "语文识字",
  189. Name2: "下学期",
  190. Finish: 0,
  191. Total: 16,
  192. Image: "../images/examine_subject_a008.png"
  193. }, {
  194. ID: 20,
  195. Type: "Shizi",
  196. Name: "语文写字",
  197. Name2: "下学期",
  198. Finish: 0,
  199. Total: 20,
  200. Image: "../images/examine_subject_a008.png"
  201. }]
  202. },
  203. {
  204. Name: "五年级",
  205. Name2: "语文五年级",
  206. Select: "",
  207. List: [{
  208. ID: 9,
  209. Type: "Shizi",
  210. Name: "语文识字",
  211. Name2: "上学期",
  212. Finish: 0,
  213. Total: 16,
  214. Image: "../images/examine_subject_a009.png"
  215. }, {
  216. ID: 21,
  217. Type: "Shizi",
  218. Name: "语文写字",
  219. Name2: "上学期",
  220. Finish: 0,
  221. Total: 21,
  222. Image: "../images/examine_subject_a009.png"
  223. }, {
  224. ID: 10,
  225. Type: "Shizi",
  226. Name: "语文识字",
  227. Name2: "下学期",
  228. Finish: 0,
  229. Total: 16,
  230. Image: "../images/examine_subject_a010.png"
  231. }, {
  232. ID: 22,
  233. Type: "Shizi",
  234. Name: "语文写字",
  235. Name2: "下学期",
  236. Finish: 0,
  237. Total: 16,
  238. Image: "../images/examine_subject_a010.png"
  239. }
  240. ]
  241. },
  242. {
  243. Name: "六年级",
  244. Name2: "语文六年级",
  245. Select: "",
  246. List: [
  247. {
  248. ID: 23,
  249. Type: "Shizi",
  250. Name: "语文写字",
  251. Name2: "上学期",
  252. Finish: 0,
  253. Total: 18,
  254. Image: "../images/examine_subject_a011.png"
  255. }, {
  256. ID: 24,
  257. Type: "Shizi",
  258. Name: "语文写字",
  259. Name2: "下学期",
  260. Finish: 0,
  261. Total: 12,
  262. Image: "../images/examine_subject_a012.png"
  263. },
  264. ]
  265. },
  266. {
  267. Name: "英语常用单词",
  268. Name2: "英语常用单词",
  269. Select: "",
  270. List: [
  271. {
  272. ID: 101,
  273. Type: "Word",
  274. Name: "常用单词1",
  275. Name2: "词汇1~220",
  276. Finish: 0,
  277. Total: 22,
  278. Image: "../images/examine_subject_b001.png"
  279. },
  280. {
  281. ID: 102,
  282. Type: "Word",
  283. Name: "常用单词2",
  284. Name2: "词汇221~500",
  285. Finish: 0,
  286. Total: 28,
  287. Image: "../images/examine_subject_b002.png"
  288. },
  289. {
  290. ID: 103,
  291. Type: "Word",
  292. Name: "常用单词3",
  293. Name2: "词汇500~1000",
  294. Finish: 0,
  295. Total: 50,
  296. Image: "../images/examine_subject_b003.png"
  297. },
  298. {
  299. ID: 104,
  300. Type: "Word",
  301. Name: "常用单词4",
  302. Name2: "词汇1001~1500",
  303. Finish: 0,
  304. Total: 50,
  305. Image: "../images/examine_subject_b004.png"
  306. },
  307. {
  308. ID: 105,
  309. Type: "Word",
  310. Name: "常用单词5",
  311. Name2: "词汇1501~2000",
  312. Finish: 0,
  313. Total: 50,
  314. Image: "../images/examine_subject_b005.png"
  315. },
  316. ]
  317. },
  318. ],
  319. })
  320. var userid = app.globalData.userInfo.UserID;
  321. main.getData('GetTestReportList?UserID=' + userid, function (data) {
  322. if (data) {
  323. var dataTemp = [];
  324. for (var i = 0; i < data.length; i++) {
  325. for (var j = 0; j < dataTemp.length; j++) {
  326. if (dataTemp[j].Name[0] == data[i].Name[0] &&
  327. dataTemp[j].Name[1] == data[i].Name[1] &&
  328. dataTemp[j].TestType == data[i].TestType &&
  329. data[i].IsFinished == 1
  330. ) {
  331. dataTemp.splice(j, 1);
  332. break;
  333. }
  334. }
  335. dataTemp.push(data[i]);
  336. if (data[i].Name[0].indexOf("英语")>=0){
  337. if (data[i].TestRightStr){
  338. data[i].TestRightStr=data[i].TestRightStr.split(",");
  339. }
  340. if (data[i].TestWrongStr){
  341. data[i].TestWrongStr=data[i].TestWrongStr.split(",");
  342. }
  343. if (data[i].TestSkipStr){
  344. data[i].TestSkipStr=data[i].TestSkipStr.split(",");
  345. }
  346. if (data[i].TestExistStr){
  347. data[i].TestExistStr=data[i].TestExistStr.split(",");
  348. }
  349. }
  350. if (!data[i].TestRightStr)
  351. data[i].TestRightStr="";
  352. if (!data[i].TestWrongStr)
  353. data[i].TestWrongStr="";
  354. if (!data[i].TestSkipStr)
  355. data[i].TestSkipStr="";
  356. if (!data[i].TestExistStr)
  357. data[i].TestExistStr="";
  358. }
  359. for (var i = 0; i < dataTemp.length; i++) {
  360. var name = dataTemp[i].Name[0].split(" ");
  361. for (var j = 0; j < that.data.GradeArr.length; j++) {
  362. var item = that.data.GradeArr[j];
  363. if (name[0] == item.Name) {
  364. for (var k = 0; k < item.List.length; k++) {
  365. if (name[1] == item.List[k].Name && name[2] == item.List[k].Name2) {
  366. if (dataTemp[i].IsFinished == 1)
  367. item.List[k].Finish++;
  368. }
  369. }
  370. }
  371. }
  372. }
  373. for (var j = 0; j < that.data.GradeArr.length; j++) {
  374. var item = that.data.GradeArr[j];
  375. for (var k = 0; k < item.List.length; k++) {
  376. item.List[k].Finished = Math.round(100 * item.List[k].Finish / item.List[k].Total);
  377. }
  378. }
  379. that.setData({
  380. TestReport: data,
  381. GradeArr: that.data.GradeArr,
  382. });
  383. wx.setStorageSync("UserTestReport", data);
  384. common.getStorageValue(that, "TestSelectGrade", 0, function () {
  385. that.onSelectGrade({
  386. currentTarget: {
  387. dataset: {
  388. value: that.data.TestSelectGrade
  389. }
  390. }
  391. });
  392. });
  393. }
  394. });
  395. },
  396. onSelectGrade: function (e) {
  397. var index = e.currentTarget.dataset.value;
  398. for (var i = 0; i < this.data.GradeArr.length; i++)
  399. this.data.GradeArr[i].Select = "";
  400. this.data.GradeArr[index].Select = "Select";
  401. this.setData({
  402. TestSelectGrade: index,
  403. GradeArr: this.data.GradeArr,
  404. });
  405. this.closeSelectGrade();
  406. wx.setStorageSync("TestSelectGrade", index);
  407. },
  408. gotoTestReportInfo: function (e) {
  409. var id = e.currentTarget.dataset.id;
  410. var userid = app.globalData.userInfo.UserID;
  411. main.GetTestReportInfo(id,function(data){
  412. wx.setStorageSync("TestTask", data);
  413. wx.navigateTo({
  414. url: "./report?type=edit",
  415. });
  416. });
  417. },
  418. onUnload: function () {
  419. wx.removeStorageSync("UserTestReport");
  420. },
  421. onShareAppMessage: function () {
  422. return {
  423. title: app.globalData.ShareTitle,
  424. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  425. imageUrl: app.globalData.ShareImage,
  426. }
  427. },
  428. })