index.js 3.7 KB

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