list.js 6.0 KB

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