list.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. var isClick = true;
  5. Page({
  6. data: {
  7. IsSelect: false,
  8. ImagePath: app.globalData.uploadImageUrl,
  9. },
  10. onLoad: function (options) {
  11. var that = this;
  12. that.setData({
  13. BookID: options.id,
  14. Containnerheight: main.getWindowHeight(),
  15. Name1: options.name1,
  16. });
  17. isClick = true;
  18. main.getHanzi(function (arr) {
  19. if (!arr) {
  20. wx.removeStorageSync("HanziUpdateTime");
  21. wx.removeStorageSync("HanziAll");
  22. main.getHanzi(function (arr) {
  23. that.init(options);
  24. });
  25. } else {
  26. that.init(options);
  27. }
  28. });
  29. },
  30. init: function (options) {
  31. var that = this;
  32. var name = options.name1;
  33. if (name.indexOf(" ") > 0)
  34. name = name.substr(name.indexOf(" ") + 1);
  35. wx.setNavigationBarTitle({
  36. title: name
  37. });
  38. var arr = [];
  39. if (that.data.BookID == 13 || that.data.BookID == 14 || that.data.BookID == 15 || that.data.BookID == 16 || that.data.BookID == 17)
  40. arr = wx.getStorageSync("EnglishAll");
  41. else if (that.data.BookID <= 12)
  42. arr = wx.getStorageSync("HanziAll");
  43. var testReportList = wx.getStorageSync("UserTestReport");
  44. arr = JSON.parse(arr);
  45. var id = Number(options.id);
  46. for (var i = 0; i < arr.length; i++) {
  47. if (arr[i].ID == id) {
  48. var list = arr[i].Units;
  49. for (var j = 0; j < list.length; j++) {
  50. var str = "";
  51. for (var k = 0; k < list[j].Words.length; k++) {
  52. if (k < 27 && k < list[j].Words.length - 1)
  53. str += list[j].Words[k].Name + "、";
  54. else if (k == list[j].Words.length - 1)
  55. str += list[j].Words[k].Name;
  56. else {
  57. str += list[j].Words[k].Name + "…";
  58. break;
  59. }
  60. }
  61. list[j].WordList = str;
  62. list[j].TestTypeReadFinished = true;
  63. list[j].TestTypeWriteFinished = true;
  64. for (var k = 0; k < testReportList.length; k++) {
  65. if (testReportList[k].Name[0] == options.name1 &&
  66. testReportList[k].Name[1] == list[j].Name) {
  67. var testRightCount = 0;
  68. if (testReportList[k].TestRightStr)
  69. testRightCount = testReportList[k].TestRightStr.length;
  70. var testWrongCount = 0;
  71. if (testReportList[k].testWrongStr)
  72. testWrongCount = testReportList[k].testWrongStr.length;
  73. var testSkipCount = 0;
  74. if (testReportList[k].TestSkipStr)
  75. testSkipCount = testReportList[k].TestSkipStr.length;
  76. if (testReportList[k].TestType == "read") {
  77. if (testReportList[k].IsFinished == 1)
  78. list[j].TestTypeRead = 1;
  79. if ((testRightCount + testWrongCount + testSkipCount) < testReportList[k].TestTotal) {
  80. list[j].TestTypeReadFinished = false;
  81. }
  82. list[j].ReadReportID = testReportList[k].ID;
  83. }
  84. if (testReportList[k].TestType == "write") {
  85. if (testReportList[k].IsFinished == 1)
  86. list[j].TestTypeWrite = 1;
  87. if ((testRightCount + testWrongCount + testSkipCount) < testReportList[k].TestTotal) {
  88. list[j].TestTypeWriteFinished = false;
  89. }
  90. list[j].WriteReportID = testReportList[k].ID;
  91. }
  92. }
  93. }
  94. }
  95. that.setData({
  96. List: list,
  97. UnitsID: id,
  98. });
  99. }
  100. }
  101. },
  102. onShowFrame: function (e) {
  103. var selectItem;
  104. var id = e.currentTarget.dataset.id;
  105. for (var i = 0; i < this.data.List.length; i++) {
  106. if (id == this.data.List[i].ID) {
  107. selectItem = this.data.List[i];
  108. }
  109. }
  110. this.setData({
  111. IsSelect: true,
  112. SelectItem: selectItem,
  113. });
  114. },
  115. onClose: function () {
  116. this.setData({
  117. IsSelect: false,
  118. });
  119. },
  120. goto: function (e) {
  121. var url = e.currentTarget.dataset.url;
  122. wx.navigateTo({
  123. url: url,
  124. });
  125. this.onClose();
  126. },
  127. gotoTestReportInfo: function (e) {
  128. var that = this;
  129. if (isClick) {
  130. isClick = false;
  131. setTimeout(function () {
  132. isClick = true;
  133. }, 2000);
  134. var id = e.currentTarget.dataset.id;
  135. var userid = app.globalData.userInfo.UserID;
  136. if (id) {
  137. var reporttype = e.currentTarget.dataset.type;
  138. main.GetTestReportInfo(id, function (data) {
  139. data.BookID=that.data.BookID;
  140. wx.setStorageSync("TestTask2", data);
  141. that.onClose();
  142. wx.navigateTo({
  143. url: "./item?type=" + reporttype+"&bookid="+that.data.BookID,
  144. });
  145. });
  146. } else {
  147. that.onClose();
  148. var url = e.currentTarget.dataset.url+"&bookid="+that.data.BookID;
  149. wx.navigateTo({
  150. url: url,
  151. });
  152. }
  153. }
  154. },
  155. onShareAppMessage: function () {
  156. return {
  157. title: app.globalData.ShareTitle,
  158. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  159. imageUrl: app.globalData.ShareImage,
  160. }
  161. },
  162. })