list.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. var listType="hanzi";
  40. if (that.data.BookID > 100){
  41. arr = wx.getStorageSync("EnglishAll");
  42. listType="english";
  43. }
  44. else
  45. arr = wx.getStorageSync("HanziAll");
  46. that.setData({
  47. ListType: listType,
  48. });
  49. arr = JSON.parse(arr);
  50. var id = Number(options.id);
  51. var testReportList = wx.getStorageSync("UserTestReport");
  52. for (var i = 0; i < arr.length; i++) {
  53. if (arr[i].ID == id) {
  54. var list = arr[i].Units;
  55. for (var j = 0; j < list.length; j++) {
  56. var str = "";
  57. for (var k = 0; k < list[j].Words.length; k++) {
  58. if (k < 27 && k < list[j].Words.length - 1)
  59. str += list[j].Words[k] + "、";
  60. else if (k == list[j].Words.length - 1)
  61. str += list[j].Words[k];
  62. else {
  63. str += list[j].Words[k] + "…";
  64. break;
  65. }
  66. }
  67. list[j].WordList = str;
  68. list[j].TestTypeReadFinished = true;
  69. list[j].TestTypeWriteFinished = true;
  70. for (var k = 0; k < testReportList.length; k++) {
  71. if (testReportList[k].Name[0] == options.name1 &&
  72. testReportList[k].Name[1] == list[j].Name) {
  73. var testRightCount = 0;
  74. if (testReportList[k].TestRightStr)
  75. testRightCount = testReportList[k].TestRightStr.length;
  76. var testWrongCount = 0;
  77. if (testReportList[k].testWrongStr)
  78. testWrongCount = testReportList[k].testWrongStr.length;
  79. var testSkipCount = 0;
  80. if (testReportList[k].TestSkipStr)
  81. testSkipCount = testReportList[k].TestSkipStr.length;
  82. if (testReportList[k].TestType == "read") {
  83. if (testReportList[k].IsFinished == 1)
  84. list[j].TestTypeRead = 1;
  85. if ((testRightCount + testWrongCount + testSkipCount) < testReportList[k].TestTotal) {
  86. list[j].TestTypeReadFinished = false;
  87. }
  88. list[j].ReadReportID = testReportList[k].ID;
  89. }
  90. if (testReportList[k].TestType == "write") {
  91. if (testReportList[k].IsFinished == 1)
  92. list[j].TestTypeWrite = 1;
  93. if ((testRightCount + testWrongCount + testSkipCount) < testReportList[k].TestTotal) {
  94. list[j].TestTypeWriteFinished = false;
  95. }
  96. list[j].WriteReportID = testReportList[k].ID;
  97. }
  98. }
  99. }
  100. }
  101. that.setData({
  102. List: list,
  103. UnitsID: id,
  104. });
  105. }
  106. }
  107. },
  108. onShowFrame: function (e) {
  109. var selectItem;
  110. var id = e.currentTarget.dataset.id;
  111. for (var i = 0; i < this.data.List.length; i++) {
  112. if (id == this.data.List[i].ID) {
  113. selectItem = this.data.List[i];
  114. }
  115. }
  116. this.setData({
  117. IsSelect: true,
  118. SelectItem: selectItem,
  119. });
  120. },
  121. onClose: function () {
  122. this.setData({
  123. IsSelect: false,
  124. });
  125. },
  126. goto: function (e) {
  127. var url = e.currentTarget.dataset.url;
  128. wx.navigateTo({
  129. url: url,
  130. });
  131. this.onClose();
  132. },
  133. gotoTestReportInfo: function (e) {
  134. var that = this;
  135. if (isClick) {
  136. isClick = false;
  137. setTimeout(function () {
  138. isClick = true;
  139. }, 2000);
  140. var id = e.currentTarget.dataset.id;
  141. var userid = app.globalData.userInfo.UserID;
  142. if (id) {
  143. var reporttype = e.currentTarget.dataset.type;
  144. if (reporttype=="restart"){
  145. //main.getData('RestartTestReport?ID='+id+'&UserID=' + app.globalData.userInfo.UserID, function (data) {});
  146. var testReportList = wx.getStorageSync("UserTestReport");
  147. for(var i=0;i<testReportList.length;i++){
  148. if (id==testReportList[i].ID){
  149. testReportList[i].TestRightStr="";
  150. testReportList[i].TestWrongStr="";
  151. testReportList[i].TestSkipStr="";
  152. testReportList[i].TestExistStr="";
  153. break;
  154. }
  155. }
  156. wx.setStorageSync("UserTestReport", testReportList);
  157. }
  158. main.GetTestReportInfo(id, function (data) {
  159. data.BookID=that.data.BookID;
  160. wx.setStorageSync("TestTask2", data);
  161. that.onClose();
  162. var url="./item?type=" + reporttype+"&bookid="+that.data.BookID;
  163. var testtype=e.currentTarget.dataset.testtype;
  164. if (testtype)
  165. url+="&testtype="+testtype;
  166. wx.navigateTo({
  167. url: url,
  168. });
  169. });
  170. } else {
  171. that.onClose();
  172. var url = e.currentTarget.dataset.url+"&bookid="+that.data.BookID;
  173. wx.navigateTo({
  174. url: url,
  175. });
  176. }
  177. }
  178. },
  179. onShareAppMessage: function () {
  180. return {
  181. title: app.globalData.ShareTitle,
  182. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  183. imageUrl: app.globalData.ShareImage,
  184. }
  185. },
  186. })