list.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. var isClick = true;
  5. Page({
  6. data: {
  7. IsSelect: false,
  8. ImagePath: app.globalData.uploadImageUrl,
  9. },
  10. onLoad: function(options) {
  11. var that = this;
  12. that.setData({
  13. Containnerheight: main.getWindowHeight(),
  14. Name1: options.name1,
  15. });
  16. isClick = true;
  17. main.getHanzi(function(arr) {
  18. if (!arr) {
  19. wx.removeStorageSync("HanziUpdateTime");
  20. wx.removeStorageSync("HanziAll");
  21. main.getHanzi(function(arr) {
  22. that.init(options);
  23. });
  24. } else {
  25. that.init(options);
  26. }
  27. });
  28. },
  29. init: function(options) {
  30. var that = this;
  31. var name = options.name1;
  32. if (name.indexOf(" ") > 0)
  33. name = name.substr(name.indexOf(" ") + 1);
  34. wx.setNavigationBarTitle({
  35. title: name
  36. });
  37. var arr = wx.getStorageSync("HanziAll");
  38. var testReportList = wx.getStorageSync("UserTestReport");
  39. arr = JSON.parse(arr);
  40. var id = Number(options.id);
  41. for (var i = 0; i < arr.length; i++) {
  42. if (arr[i].ID == id) {
  43. var list = arr[i].Units;
  44. for (var j = 0; j < list.length; j++) {
  45. var str = "";
  46. for (var k = 0; k < list[j].Words.length; k++) {
  47. if (k < 27 && k < list[j].Words.length - 1)
  48. str += list[j].Words[k].Name + "、";
  49. else if (k == list[j].Words.length - 1)
  50. str += list[j].Words[k].Name;
  51. else {
  52. str += list[j].Words[k].Name + "…";
  53. break;
  54. }
  55. }
  56. list[j].WordList = str;
  57. list[j].TestTypeReadFinished = true;
  58. list[j].TestTypeWriteFinished = true;
  59. for (var k = 0; k < testReportList.length; k++) {
  60. if (testReportList[k].Name[0] == options.name1 &&
  61. testReportList[k].Name[1] == list[j].Name) {
  62. if (testReportList[k].TestType == "read") {
  63. if (testReportList[k].IsFinished == 1)
  64. list[j].TestTypeRead = 1;
  65. if ((testReportList[k].TestRight + testReportList[k].TestWrong + testReportList[k].TestSkip) < testReportList[k].TestTotal) {
  66. list[j].TestTypeReadFinished = false;
  67. }
  68. list[j].ReadReportID = testReportList[k].ID;
  69. }
  70. if (testReportList[k].TestType == "write") {
  71. if (testReportList[k].IsFinished == 1)
  72. list[j].TestTypeWrite = 1;
  73. if ((testReportList[k].TestRight + testReportList[k].TestWrong + testReportList[k].TestSkip) < testReportList[k].TestTotal) {
  74. list[j].TestTypeWriteFinished = false;
  75. }
  76. list[j].WriteReportID = testReportList[k].ID;
  77. }
  78. }
  79. }
  80. }
  81. that.setData({
  82. List: list,
  83. UnitsID: id,
  84. });
  85. }
  86. }
  87. },
  88. onShowFrame: function(e) {
  89. var selectItem;
  90. var id = e.currentTarget.dataset.id;
  91. for (var i = 0; i < this.data.List.length; i++) {
  92. if (id == this.data.List[i].ID) {
  93. selectItem = this.data.List[i];
  94. }
  95. }
  96. this.setData({
  97. IsSelect: true,
  98. SelectItem: selectItem,
  99. });
  100. },
  101. onClose: function() {
  102. this.setData({
  103. IsSelect: false,
  104. });
  105. },
  106. goto: function(e) {
  107. var url = e.currentTarget.dataset.url;
  108. wx.navigateTo({
  109. url: url,
  110. });
  111. this.onClose();
  112. },
  113. gotoTestReportInfo: function(e) {
  114. var that=this;
  115. if (isClick) {
  116. isClick=false;
  117. setTimeout(function(){
  118. isClick=true;
  119. },2000);
  120. var id = e.currentTarget.dataset.id;
  121. var userid = app.globalData.userInfo.UserID;
  122. if (id) {
  123. var reporttype = e.currentTarget.dataset.type;
  124. main.getData('GetTestReportInfo?UserID=' + userid + '&ID=' + id, function(data) {
  125. if (data) {
  126. wx.setStorageSync("TestTask2", data);
  127. that.onClose();
  128. wx.navigateTo({
  129. url: "./item?type=" + reporttype,
  130. });
  131. }
  132. });
  133. } else {
  134. that.onClose();
  135. var url = e.currentTarget.dataset.url;
  136. wx.navigateTo({
  137. url: url,
  138. });
  139. }
  140. }
  141. },
  142. onShareAppMessage: function() {
  143. return {
  144. title: app.globalData.ShareTitle,
  145. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  146. imageUrl: app.globalData.ShareImage,
  147. }
  148. },
  149. })