index.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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. ID: 10,
  153. Type: "Shizi",
  154. Name: "语文识字",
  155. Name2: "下学期",
  156. Finish: 0,
  157. Total: 16,
  158. Image: "../images/examine_subject_a010.png"
  159. },
  160. ]
  161. },
  162. {
  163. Name: "六年级",
  164. Name2: "语文六年级",
  165. Select: "",
  166. List: [
  167. {
  168. ID: 11,
  169. Type: "Shizi",
  170. Name: "语文识字",
  171. Name2: "上学期",
  172. Finish: 0,
  173. Total: 16,
  174. Image: "../images/examine_subject_a011.png"
  175. }, {
  176. ID: 12,
  177. Type: "Shizi",
  178. Name: "语文识字",
  179. Name2: "下学期",
  180. Finish: 0,
  181. Total: 16,
  182. Image: "../images/examine_subject_a012.png"
  183. },
  184. ]
  185. },
  186. {
  187. Name: "英语常用单词",
  188. Name2: "英语常用单词",
  189. Select: "",
  190. List: [
  191. {
  192. ID: 13,
  193. Type: "Word",
  194. Name: "常用单词1",
  195. Name2: "词汇1~220",
  196. Finish: 0,
  197. Total: 22,
  198. Image: "../images/examine_subject_b001.png"
  199. },
  200. {
  201. ID: 14,
  202. Type: "Word",
  203. Name: "常用单词2",
  204. Name2: "词汇221~500",
  205. Finish: 0,
  206. Total: 28,
  207. Image: "../images/examine_subject_b002.png"
  208. },
  209. {
  210. ID: 15,
  211. Type: "Word",
  212. Name: "常用单词3",
  213. Name2: "词汇500~1000",
  214. Finish: 0,
  215. Total: 50,
  216. Image: "../images/examine_subject_b003.png"
  217. },
  218. {
  219. ID: 16,
  220. Type: "Word",
  221. Name: "常用单词4",
  222. Name2: "词汇1001~1500",
  223. Finish: 0,
  224. Total: 50,
  225. Image: "../images/examine_subject_b004.png"
  226. },
  227. {
  228. ID: 17,
  229. Type: "Word",
  230. Name: "常用单词5",
  231. Name2: "词汇1501~2000",
  232. Finish: 0,
  233. Total: 50,
  234. Image: "../images/examine_subject_b005.png"
  235. },
  236. ]
  237. },
  238. ],
  239. })
  240. var userid = app.globalData.userInfo.UserID;
  241. main.getData('GetTestReportList?UserID=' + userid, function (data) {
  242. if (data) {
  243. var dataTemp = [];
  244. for (var i = 0; i < data.length; i++) {
  245. for (var j = 0; j < dataTemp.length; j++) {
  246. if (dataTemp[j].Name[0] == data[i].Name[0] &&
  247. dataTemp[j].Name[1] == data[i].Name[1] &&
  248. dataTemp[j].TestType == data[i].TestType &&
  249. data[i].IsFinished == 1
  250. ) {
  251. dataTemp.splice(j, 1);
  252. break;
  253. }
  254. }
  255. dataTemp.push(data[i]);
  256. if (data[i].Name[0].indexOf("英语")>=0){
  257. if (data[i].TestRightStr){
  258. data[i].TestRightStr=data[i].TestRightStr.split(",");
  259. }
  260. if (data[i].TestWrongStr){
  261. data[i].TestWrongStr=data[i].TestWrongStr.split(",");
  262. }
  263. if (data[i].TestSkipStr){
  264. data[i].TestSkipStr=data[i].TestSkipStr.split(",");
  265. }
  266. if (data[i].TestExistStr){
  267. data[i].TestExistStr=data[i].TestExistStr.split(",");
  268. }
  269. }
  270. if (!data[i].TestRightStr)
  271. data[i].TestRightStr="";
  272. if (!data[i].TestWrongStr)
  273. data[i].TestWrongStr="";
  274. if (!data[i].TestSkipStr)
  275. data[i].TestSkipStr="";
  276. if (!data[i].TestExistStr)
  277. data[i].TestExistStr="";
  278. }
  279. for (var i = 0; i < dataTemp.length; i++) {
  280. var name = dataTemp[i].Name[0].split(" ");
  281. for (var j = 0; j < that.data.GradeArr.length; j++) {
  282. var item = that.data.GradeArr[j];
  283. if (name[0] == item.Name) {
  284. for (var k = 0; k < item.List.length; k++) {
  285. if (name[1] == item.List[k].Name && name[2] == item.List[k].Name2) {
  286. if (dataTemp[i].IsFinished == 1)
  287. item.List[k].Finish++;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. for (var j = 0; j < that.data.GradeArr.length; j++) {
  294. var item = that.data.GradeArr[j];
  295. for (var k = 0; k < item.List.length; k++) {
  296. item.List[k].Finished = Math.round(100 * item.List[k].Finish / item.List[k].Total);
  297. }
  298. }
  299. that.setData({
  300. TestReport: data,
  301. GradeArr: that.data.GradeArr,
  302. });
  303. wx.setStorageSync("UserTestReport", data);
  304. common.getStorageValue(that, "TestSelectGrade", 0, function () {
  305. that.onSelectGrade({
  306. currentTarget: {
  307. dataset: {
  308. value: that.data.TestSelectGrade
  309. }
  310. }
  311. });
  312. });
  313. }
  314. });
  315. },
  316. onSelectGrade: function (e) {
  317. var index = e.currentTarget.dataset.value;
  318. for (var i = 0; i < this.data.GradeArr.length; i++)
  319. this.data.GradeArr[i].Select = "";
  320. this.data.GradeArr[index].Select = "Select";
  321. this.setData({
  322. TestSelectGrade: index,
  323. GradeArr: this.data.GradeArr,
  324. });
  325. this.closeSelectGrade();
  326. wx.setStorageSync("TestSelectGrade", index);
  327. },
  328. gotoTestReportInfo: function (e) {
  329. var id = e.currentTarget.dataset.id;
  330. var userid = app.globalData.userInfo.UserID;
  331. main.GetTestReportInfo(id,function(data){
  332. wx.setStorageSync("TestTask", data);
  333. wx.navigateTo({
  334. url: "./report?type=edit",
  335. });
  336. });
  337. },
  338. onUnload: function () {
  339. wx.removeStorageSync("UserTestReport");
  340. },
  341. onShareAppMessage: function () {
  342. return {
  343. title: app.globalData.ShareTitle,
  344. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  345. imageUrl: app.globalData.ShareImage,
  346. }
  347. },
  348. })