index.js 9.8 KB

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