index.js 11 KB

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