list.js 6.2 KB

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