index.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. },
  131. {
  132. Name: "五年级",
  133. Name2: "语文五年级",
  134. Select: "",
  135. List: [{
  136. ID: 9,
  137. Type: "Shizi",
  138. Name: "语文识字",
  139. Name2: "上学期",
  140. Finish: 0,
  141. Total: 16,
  142. Image: "../images/examine_subject_a009.png"
  143. }, ]
  144. },
  145. {
  146. Name: "六年级",
  147. Name2: "语文六年级",
  148. Select: "",
  149. List: [
  150. {
  151. ID: 11,
  152. Type: "Shizi",
  153. Name: "语文识字",
  154. Name2: "上学期",
  155. Finish: 0,
  156. Total: 16,
  157. Image: "../images/examine_subject_a011.png"
  158. },
  159. ]
  160. },
  161. {
  162. Name: "英语常用单词",
  163. Name2: "英语常用单词",
  164. Select: "",
  165. List: [
  166. {
  167. ID: 13,
  168. Type: "Word",
  169. Name: "常用单词1",
  170. Name2: "词汇1~220",
  171. Finish: 0,
  172. Total: 22,
  173. Image: "../images/examine_subject_b001.png"
  174. },
  175. {
  176. ID: 14,
  177. Type: "Word",
  178. Name: "常用单词2",
  179. Name2: "词汇221~500",
  180. Finish: 0,
  181. Total: 28,
  182. Image: "../images/examine_subject_b002.png"
  183. },
  184. {
  185. ID: 15,
  186. Type: "Word",
  187. Name: "常用单词3",
  188. Name2: "词汇500~1000",
  189. Finish: 0,
  190. Total: 50,
  191. Image: "../images/examine_subject_b003.png"
  192. },
  193. ]
  194. },
  195. ],
  196. })
  197. var userid = app.globalData.userInfo.UserID;
  198. main.getData('GetTestReportList?UserID=' + userid, function (data) {
  199. if (data) {
  200. var dataTemp = [];
  201. for (var i = 0; i < data.length; i++) {
  202. for (var j = 0; j < dataTemp.length; j++) {
  203. if (dataTemp[j].Name[0] == data[i].Name[0] &&
  204. dataTemp[j].Name[1] == data[i].Name[1] &&
  205. dataTemp[j].TestType == data[i].TestType &&
  206. data[i].IsFinished == 1
  207. ) {
  208. dataTemp.splice(j, 1);
  209. break;
  210. }
  211. }
  212. dataTemp.push(data[i]);
  213. if (data[i].Name[0].indexOf("英语")>=0){
  214. if (data[i].TestRightStr){
  215. data[i].TestRightStr=data[i].TestRightStr.split(",");
  216. }
  217. if (data[i].TestWrongStr){
  218. data[i].TestWrongStr=data[i].TestWrongStr.split(",");
  219. }
  220. if (data[i].TestSkipStr){
  221. data[i].TestSkipStr=data[i].TestSkipStr.split(",");
  222. }
  223. if (data[i].TestExistStr){
  224. data[i].TestExistStr=data[i].TestExistStr.split(",");
  225. }
  226. }
  227. if (!data[i].TestRightStr)
  228. data[i].TestRightStr="";
  229. if (!data[i].TestWrongStr)
  230. data[i].TestWrongStr="";
  231. if (!data[i].TestSkipStr)
  232. data[i].TestSkipStr="";
  233. if (!data[i].TestExistStr)
  234. data[i].TestExistStr="";
  235. }
  236. for (var i = 0; i < dataTemp.length; i++) {
  237. var name = dataTemp[i].Name[0].split(" ");
  238. for (var j = 0; j < that.data.GradeArr.length; j++) {
  239. var item = that.data.GradeArr[j];
  240. if (name[0] == item.Name) {
  241. for (var k = 0; k < item.List.length; k++) {
  242. if (name[1] == item.List[k].Name && name[2] == item.List[k].Name2) {
  243. if (dataTemp[i].IsFinished == 1)
  244. item.List[k].Finish++;
  245. }
  246. }
  247. }
  248. }
  249. }
  250. for (var j = 0; j < that.data.GradeArr.length; j++) {
  251. var item = that.data.GradeArr[j];
  252. for (var k = 0; k < item.List.length; k++) {
  253. item.List[k].Finished = Math.round(100 * item.List[k].Finish / item.List[k].Total);
  254. }
  255. }
  256. that.setData({
  257. TestReport: data,
  258. GradeArr: that.data.GradeArr,
  259. });
  260. wx.setStorageSync("UserTestReport", data);
  261. common.getStorageValue(that, "TestSelectGrade", 0, function () {
  262. that.onSelectGrade({
  263. currentTarget: {
  264. dataset: {
  265. value: that.data.TestSelectGrade
  266. }
  267. }
  268. });
  269. });
  270. }
  271. });
  272. },
  273. onSelectGrade: function (e) {
  274. var index = e.currentTarget.dataset.value;
  275. for (var i = 0; i < this.data.GradeArr.length; i++)
  276. this.data.GradeArr[i].Select = "";
  277. this.data.GradeArr[index].Select = "Select";
  278. this.setData({
  279. TestSelectGrade: index,
  280. GradeArr: this.data.GradeArr,
  281. });
  282. this.closeSelectGrade();
  283. wx.setStorageSync("TestSelectGrade", index);
  284. },
  285. gotoTestReportInfo: function (e) {
  286. var id = e.currentTarget.dataset.id;
  287. var userid = app.globalData.userInfo.UserID;
  288. main.GetTestReportInfo(id,function(data){
  289. wx.setStorageSync("TestTask", data);
  290. wx.navigateTo({
  291. url: "./report?type=edit",
  292. });
  293. });
  294. },
  295. onUnload: function () {
  296. wx.removeStorageSync("UserTestReport");
  297. },
  298. onShareAppMessage: function () {
  299. return {
  300. title: app.globalData.ShareTitle,
  301. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  302. imageUrl: app.globalData.ShareImage,
  303. }
  304. },
  305. })