mistakes.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. // pages/mistakes/mistakes.js
  2. const APIClient = require('../../utils/APIClient.js');
  3. const login = require('../../utils/loginSchedule.js');
  4. const util = require('../../utils/util.js');
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. mistakesData: [],
  11. animationData: {},
  12. flags: [],
  13. exponentData: [],
  14. course: ['语文', '数学'],
  15. courseIndex: 0,
  16. flag: true,
  17. switchs: true,
  18. errorData: {},
  19. errImgW: [],
  20. errImgH: [],
  21. loginType: 1
  22. },
  23. particulars: function ({ currentTarget }) {
  24. //console.log(currentTarget.dataset.flag, currentTarget.dataset.index);
  25. let flage = currentTarget.dataset.flag;
  26. let index = currentTarget.dataset.index;
  27. if(flage){
  28. this.data.flags[index] = false;
  29. this.setData({
  30. flags: this.data.flags,
  31. })
  32. } else {
  33. this.data.flags[index] = true;
  34. this.setData({
  35. flags: this.data.flags,
  36. })
  37. let contentId = this.data.mistakesData[index].questions.id;
  38. let grade = this.data.mistakesData[index].userQuestionResult.grade;
  39. login.getOpenidSessionKey(res => {
  40. APIClient.getStatisticsOpt({
  41. uid: res.data.data.uid
  42. },{
  43. contentId,
  44. grade,
  45. type: 'WRONG_QUESTION'
  46. }).success(res => {
  47. console.log('成功')
  48. })
  49. }, (error) => {
  50. console.log(error)
  51. });
  52. }
  53. },
  54. //获取image宽高
  55. imageLoad: function (e) {
  56. let height = e.detail.height;
  57. let width = e.detail.width;
  58. this.data.errImgW.push(width);
  59. this.data.errImgH.push(height);
  60. //console.log(height, width)
  61. //设置图片宽度
  62. //const imgW = width * .9;
  63. //设置图片高度
  64. //const imgH = imgW * (height / width);
  65. this.setData({
  66. errImgW: this.data.errImgW,
  67. errImgH: this.data.errImgH
  68. })
  69. },
  70. /*tab切换*/
  71. tab (e) {
  72. const index = e.currentTarget.dataset.index;
  73. this.setData({
  74. courseIndex: index
  75. })
  76. this.getmistakesData(index + 1)
  77. },
  78. /* 创建动画并执行 */
  79. util (height) {
  80. // 创建动画实例
  81. var animation = wx.createAnimation({
  82. duration: 200, //动画时长
  83. timingFunction: "linear", //线性
  84. delay: 0 //0则不延迟
  85. });
  86. this.animation = animation;
  87. animation.height(height).step();
  88. this.setData({
  89. animationData: animation.export()
  90. })
  91. },
  92. /*请求错题数据*/
  93. getmistakesData: function (category) {
  94. login.getOpenidSessionKey(res => {
  95. APIClient.getErrorsSchedule({
  96. uid: res.data.data.uid
  97. },{
  98. pageNo: 1,
  99. pageSize: 1000,
  100. category
  101. }).success(res => {
  102. console.log(res.data.data.list)
  103. this.setData({
  104. mistakesData: res.data.data.list
  105. })
  106. for(let item of res.data.data.list) {
  107. this.data.flags.push(false);
  108. }
  109. this.setData({
  110. flags: this.data.flags
  111. })
  112. })
  113. //用户答题指数
  114. APIClient.getExponentSchedule({
  115. uid: res.data.data.uid
  116. }).success(res => {
  117. console.log(res);
  118. this.setData({
  119. exponentData: res.data.data
  120. })
  121. })
  122. }, () => {
  123. this.setData({
  124. flag: !this.data.flag
  125. })
  126. }, this.data.loginType);
  127. },
  128. closeDialog: function () {
  129. this.setData({
  130. switchs: true
  131. })
  132. },
  133. /**
  134. * 生命周期函数--监听页面加载
  135. */
  136. onLoad: function (options) {
  137. if(options.type == "noTv") {
  138. this.setData({
  139. loginType: ""
  140. })
  141. }
  142. const qid = util.convertObject(decodeURIComponent(options.scene)).i || '';
  143. console.log('qid:' + qid);
  144. if(qid) {
  145. APIClient.getScheduleErr(qid).success(res => {
  146. console.log(res.data.data)
  147. this.setData({
  148. errorData: res.data.data
  149. })
  150. this.setData({
  151. switchs: false
  152. })
  153. }).fail(res => {
  154. console.log(res)
  155. })
  156. }
  157. },
  158. /**
  159. * 生命周期函数--监听页面初次渲染完成
  160. */
  161. onReady: function () {
  162. },
  163. /**
  164. * 生命周期函数--监听页面显示
  165. */
  166. onShow: function () {
  167. this.getmistakesData(1)
  168. },
  169. /**
  170. * 生命周期函数--监听页面隐藏
  171. */
  172. onHide: function () {
  173. },
  174. /**
  175. * 生命周期函数--监听页面卸载
  176. */
  177. onUnload: function () {
  178. },
  179. /**
  180. * 页面相关事件处理函数--监听用户下拉动作
  181. */
  182. onPullDownRefresh: function () {
  183. },
  184. /**
  185. * 页面上拉触底事件的处理函数
  186. */
  187. onReachBottom: function () {
  188. },
  189. /**
  190. * 用户点击右上角分享
  191. */
  192. onShareAppMessage: function () {
  193. },
  194. /*获取个人信息弹框*/
  195. jurisdiction: function () {
  196. this.setData({
  197. flag: !this.data.flag
  198. })
  199. this.onShow();
  200. }
  201. })