list.js 7.0 KB

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