list.js 8.1 KB

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