index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. import constant from '../../utils/constant';
  4. const app = getApp();
  5. Page({
  6. data: {
  7. List: [],
  8. TestSelectGrade: 0,
  9. IsIPhoneX: app.globalData.IsIPhoneX,
  10. IsIPad: app.globalData.IsIPad,
  11. ScrollLeft: 0,
  12. },
  13. onLoad: function (options) {
  14. if (options.UserID) {
  15. app.globalData.userInfo = {};
  16. app.globalData.userInfo.UserID = options.UserID;
  17. }
  18. var that = this;
  19. that.setData({
  20. Containnerheight: main.getWindowHeight(),
  21. Subject: "CHN",
  22. });
  23. main.getHanzi(function (arr) {
  24. if (!arr) {
  25. wx.removeStorageSync("HanziUpdateTime");
  26. wx.removeStorageSync("HanziAll");
  27. main.getHanzi(function (arr) {});
  28. }
  29. });
  30. },
  31. onShow: function () {
  32. this.getTestReportList();
  33. },
  34. selectSubject: function (e) {
  35. var subject = e.currentTarget.dataset.type;
  36. var that = this;
  37. that.setData({
  38. Subject: subject,
  39. });
  40. },
  41. goto: function (e) {
  42. var url = e.currentTarget.dataset.url;
  43. if (url == "../other/userbook") {
  44. } else if (e.currentTarget.dataset.type == "Shici") {
  45. var name1 = e.currentTarget.dataset.name1;
  46. name1 = name1.replace("语文古诗文", "语文");
  47. url = "./item?testtype=recite&name1=" + name1 + "&bookid=" + e.currentTarget.dataset.bookid;
  48. } else if (e.currentTarget.dataset.type == "Word" && e.currentTarget.dataset.bookid == 100) {
  49. var name1 = e.currentTarget.dataset.name1;
  50. url = "./item?testtype=read&name1=" + name1 + "&name2=英文字母&bookid=100";
  51. } else if (e.currentTarget.dataset.name1 && e.currentTarget.dataset.bookid) {
  52. url = "./list?name1=" + e.currentTarget.dataset.name1 + "&id=" + e.currentTarget.dataset.bookid;
  53. }
  54. wx.navigateTo({
  55. url: url,
  56. });
  57. },
  58. getTestReportList: function () {
  59. var that = this;
  60. var userid = app.globalData.userInfo.UserID;
  61. main.GetTestReportList(userid,function (data,GradeArrResult) {
  62. that.setData({
  63. TestReport: data,
  64. GradeArr: GradeArrResult,
  65. });
  66. common.getStorageValue(that, "TestSelectGrade", 0, function () {
  67. that.onSelectGrade({
  68. currentTarget: {
  69. dataset: {
  70. value: that.data.TestSelectGrade
  71. }
  72. }
  73. });
  74. if (that.data.TestSelectGrade < 9) {
  75. that.setData({
  76. Subject: "CHN",
  77. });
  78. if (that.data.TestSelectGrade > 4) {
  79. that.setData({
  80. ScrollLeft: 500,
  81. });
  82. }
  83. } else {
  84. that.setData({
  85. Subject: "ENG",
  86. });
  87. if (that.data.TestSelectGrade > 11) {
  88. that.setData({
  89. ScrollLeft: 500,
  90. });
  91. }
  92. }
  93. });
  94. });
  95. },
  96. onSelectGrade: function (e) {
  97. var index = e.currentTarget.dataset.value;
  98. for (var i = 0; i < this.data.GradeArr.length; i++)
  99. this.data.GradeArr[i].Select = "";
  100. this.data.GradeArr[index].Select = "Select";
  101. this.setData({
  102. TestSelectGrade: index,
  103. GradeArr: this.data.GradeArr,
  104. });
  105. wx.setStorageSync("TestSelectGrade", index);
  106. },
  107. gotoTestReportInfo: function (e) {
  108. var id = e.currentTarget.dataset.id;
  109. var userid = app.globalData.userInfo.UserID;
  110. main.GetTestReportInfo(id, function (data) {
  111. wx.setStorageSync("TestTask", data);
  112. wx.navigateTo({
  113. url: "./report?type=edit",
  114. });
  115. });
  116. },
  117. onUnload: function () {
  118. wx.removeStorageSync("UserTestReport");
  119. },
  120. gotoReLaunch: function (e) {
  121. var url = e.currentTarget.dataset.url;
  122. wx.reLaunch({
  123. url: url,
  124. });
  125. },
  126. onShareAppMessage: function () {
  127. return {
  128. title: app.globalData.ShareTitle,
  129. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  130. imageUrl: app.globalData.ShareImage,
  131. }
  132. },
  133. })