list.js 7.9 KB

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