list.js 8.2 KB

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