list.js 6.5 KB

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