list.js 8.5 KB

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