index.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. var that = this;
  12. that.setData({
  13. Containnerheight: main.getWindowHeight(),
  14. });
  15. main.getHanzi(function (arr) {
  16. if (!arr) {
  17. wx.removeStorageSync("HanziUpdateTime");
  18. wx.removeStorageSync("HanziAll");
  19. main.getHanzi(function(arr){});
  20. }
  21. });
  22. },
  23. onShow:function(){
  24. this.getTestReportList();
  25. },
  26. showSelectGrade: function () {
  27. var that = this;
  28. that.setData({
  29. IsSelectGrade: true,
  30. });
  31. },
  32. closeSelectGrade: function () {
  33. var that = this;
  34. that.setData({
  35. IsSelectGrade: false,
  36. });
  37. },
  38. goto: function (e) {
  39. var url = e.currentTarget.dataset.url;
  40. wx.navigateTo({
  41. url: url,
  42. });
  43. },
  44. getTestReportList: function () {
  45. var that = this;
  46. that.setData({
  47. GradeArr: [
  48. {
  49. Name: "一年级",
  50. Name2: "语文一年级",
  51. Select: "Select",
  52. List: [
  53. {
  54. ID: 1,
  55. Type: "Shizi",
  56. Name: "语文识字",
  57. Name2: "上学期",
  58. Finish: 0,
  59. Total: 12,
  60. Image: "../images/examine_subject_a001.png"
  61. }, {
  62. ID: 2,
  63. Type: "Shizi",
  64. Name: "语文识字",
  65. Name2: "下学期",
  66. Finish: 0,
  67. Total: 14,
  68. Image: "../images/examine_subject_a002.png"
  69. },
  70. ]
  71. },
  72. {
  73. Name: "二年级",
  74. Name2: "语文二年级",
  75. Select: "",
  76. List: [
  77. {
  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. {
  97. Name: "三年级",
  98. Name2: "语文三年级",
  99. Select: "",
  100. List: [
  101. {
  102. ID: 5,
  103. Type: "Shizi",
  104. Name: "语文识字",
  105. Name2: "上学期",
  106. Finish: 0,
  107. Total: 16,
  108. Image: "../images/examine_subject_a005.png"
  109. }, {
  110. ID: 6,
  111. Type: "Shizi",
  112. Name: "语文识字",
  113. Name2: "下学期",
  114. Finish: 0,
  115. Total: 16,
  116. Image: "../images/examine_subject_a006.png"
  117. },
  118. ]
  119. },
  120. {
  121. Name: "四年级",
  122. Name2: "语文四年级",
  123. Select: "",
  124. List: [
  125. {
  126. ID: 7,
  127. Type: "Shizi",
  128. Name: "语文识字",
  129. Name2: "上学期",
  130. Finish: 0,
  131. Total: 16,
  132. Image: "../images/examine_subject_a007.png"
  133. },
  134. ]
  135. },
  136. {
  137. Name: "五年级",
  138. Name2: "语文五年级",
  139. Select: "",
  140. List: [
  141. {
  142. ID: 9,
  143. Type: "Shizi",
  144. Name: "语文识字",
  145. Name2: "上学期",
  146. Finish: 0,
  147. Total: 16,
  148. Image: "../images/examine_subject_a009.png"
  149. },
  150. ]
  151. },
  152. // {
  153. // Name: "六年级",
  154. // Name2: "语文六年级",
  155. // Select: "",
  156. // List: [
  157. // {
  158. // ID: 11,
  159. // Type: "Shizi",
  160. // Name: "语文识字",
  161. // Name2: "上学期",
  162. // Finish: 0,
  163. // Total: 16,
  164. // Image: "../images/examine_subject_a011.png"
  165. // },
  166. // ]
  167. // },
  168. // {
  169. // Name: "英语常用词",
  170. // Name2: "英语常用词",
  171. // Select: "",
  172. // List: [
  173. // {
  174. // ID: 13,
  175. // Type: "Word",
  176. // Name: "常用词1",
  177. // Name2: "词汇1~220",
  178. // Finish: 0,
  179. // Total: 22,
  180. // Image: "../images/examine_subject_b001.png"
  181. // },
  182. // {
  183. // ID: 14,
  184. // Type: "Word",
  185. // Name: "常用词2",
  186. // Name2: "词汇221~500",
  187. // Finish: 0,
  188. // Total: 28,
  189. // Image: "../images/examine_subject_b002.png"
  190. // },
  191. // {
  192. // ID: 15,
  193. // Type: "Word",
  194. // Name: "常用词3",
  195. // Name2: "词汇500~1000",
  196. // Finish: 0,
  197. // Total: 25,
  198. // Image: "../images/examine_subject_b003.png"
  199. // },
  200. // ]
  201. // },
  202. ],
  203. })
  204. var userid = app.globalData.userInfo.UserID;
  205. main.getData('GetTestReportList?UserID=' + userid, function (data) {
  206. if (data) {
  207. var dataTemp=[];
  208. for (var i = 0; i < data.length; i++) {
  209. for(var j=0;j<dataTemp.length;j++){
  210. if (dataTemp[j].Name[0] == data[i].Name[0]
  211. && dataTemp[j].Name[1] == data[i].Name[1]
  212. && dataTemp[j].TestType == data[i].TestType
  213. && data[i].IsFinished==1
  214. ){
  215. dataTemp.splice(j,1);
  216. break;
  217. }
  218. }
  219. dataTemp.push(data[i]);
  220. }
  221. for (var i = 0; i < dataTemp.length;i++){
  222. var name = dataTemp[i].Name[0].split(" ");
  223. for(var j=0;j<that.data.GradeArr.length;j++){
  224. var item = that.data.GradeArr[j];
  225. if (name[0]==item.Name){
  226. for(var k=0;k<item.List.length;k++){
  227. if (name[1] == item.List[k].Name && name[2] == item.List[k].Name2){
  228. if (dataTemp[i].IsFinished==1)
  229. item.List[k].Finish++;
  230. }
  231. }
  232. }
  233. }
  234. }
  235. for (var j = 0; j < that.data.GradeArr.length; j++) {
  236. var item = that.data.GradeArr[j];
  237. for (var k = 0; k < item.List.length; k++) {
  238. item.List[k].Finished = Math.round(100 * item.List[k].Finish / item.List[k].Total);
  239. }
  240. }
  241. that.setData({
  242. TestReport: data,
  243. GradeArr:that.data.GradeArr,
  244. });
  245. wx.setStorageSync("UserTestReport", data);
  246. common.getStorageValue(that, "TestSelectGrade", 0, function () {
  247. that.onSelectGrade({ currentTarget: { dataset: { value: that.data.TestSelectGrade } } });
  248. });
  249. }
  250. });
  251. },
  252. onSelectGrade:function(e){
  253. var index=e.currentTarget.dataset.value;
  254. for (var i = 0; i < this.data.GradeArr.length;i++)
  255. this.data.GradeArr[i].Select = "";
  256. this.data.GradeArr[index].Select="Select";
  257. this.setData({
  258. TestSelectGrade:index,
  259. GradeArr: this.data.GradeArr,
  260. });
  261. this.closeSelectGrade();
  262. wx.setStorageSync("TestSelectGrade", index);
  263. },
  264. gotoTestReportInfo: function (e) {
  265. var id = e.currentTarget.dataset.id;
  266. var userid = app.globalData.userInfo.UserID;
  267. main.getData('GetTestReportInfo?UserID=' + userid+'&ID='+id, function (data) {
  268. if (data) {
  269. wx.setStorageSync("TestTask", data);
  270. wx.navigateTo({
  271. url: "./report?type=edit",
  272. });
  273. }
  274. });
  275. },
  276. onUnload:function(){
  277. wx.removeStorageSync("UserTestReport");
  278. },
  279. onShareAppMessage: function () {
  280. return {
  281. title: app.globalData.ShareTitle,
  282. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  283. imageUrl: app.globalData.ShareImage,
  284. }
  285. },
  286. })