index.js 4.1 KB

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