list.js 6.6 KB

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