list.js 8.1 KB

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