mistakes.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. flag: [],
  13. exponentData: [],
  14. course: ['语文', '数学'],
  15. courseIndex: 0,
  16. flag: true,
  17. switchs: true,
  18. errorData: {}
  19. },
  20. particulars: function (e) {
  21. let flage = e.currentTarget.dataset.flag;
  22. let index = e.currentTarget.dataset.index;
  23. if(flage){
  24. this.util('60rpx');
  25. this.data.flag[index] = false;
  26. this.setData({
  27. flag: this.data.flag,
  28. })
  29. } else {
  30. this.data.flag[index] = true;
  31. this.util('164rpx');
  32. this.setData({
  33. flag: this.data.flag,
  34. })
  35. }
  36. },
  37. /*tab切换*/
  38. tab (e) {
  39. const index = e.currentTarget.dataset.index;
  40. this.setData({
  41. courseIndex: index
  42. })
  43. this.getmistakesData(index + 1)
  44. },
  45. /* 创建动画并执行 */
  46. util (height) {
  47. // 创建动画实例
  48. var animation = wx.createAnimation({
  49. duration: 200, //动画时长
  50. timingFunction: "linear", //线性
  51. delay: 0 //0则不延迟
  52. });
  53. this.animation = animation;
  54. animation.height(height).step();
  55. this.setData({
  56. animationData: animation.export()
  57. })
  58. },
  59. /*请求错题数据*/
  60. getmistakesData: function (category) {
  61. login.getOpenidSessionKey(res => {
  62. APIClient.getErrorsSchedule({
  63. uid: res.data.data.uid
  64. },{
  65. pageNo: 1,
  66. pageSize: 1000,
  67. category
  68. }).success(res => {
  69. console.log(res.data.data.list)
  70. this.setData({
  71. mistakesData: res.data.data.list
  72. })
  73. for(let item of res.data.data.list) {
  74. //this.data.flag.push(false);
  75. }
  76. this.setData({
  77. flag: this.data.flag
  78. })
  79. })
  80. //用户答题指数
  81. APIClient.getExponentSchedule({
  82. uid: res.data.data.uid
  83. }).success(res => {
  84. console.log(res);
  85. this.setData({
  86. exponentData: res.data.data
  87. })
  88. })
  89. }, () => {
  90. this.setData({
  91. flag: !this.data.flag
  92. })
  93. });
  94. },
  95. closeDialog: function () {
  96. this.setData({
  97. switchs: true
  98. })
  99. },
  100. /**
  101. * 生命周期函数--监听页面加载
  102. */
  103. onLoad: function (options) {
  104. const qid = util.convertObject(decodeURIComponent(options.scene)).i || '';
  105. console.log('qid:' + qid);
  106. if(qid) {
  107. APIClient.getScheduleErr(qid).success(res => {
  108. console.log(res.data.data)
  109. this.setData({
  110. errorData: res.data.data
  111. })
  112. this.setData({
  113. switchs: false
  114. })
  115. }).fail(res => {
  116. console.log(res)
  117. })
  118. }
  119. },
  120. /**
  121. * 生命周期函数--监听页面初次渲染完成
  122. */
  123. onReady: function () {
  124. },
  125. /**
  126. * 生命周期函数--监听页面显示
  127. */
  128. onShow: function () {
  129. this.getmistakesData(1)
  130. },
  131. /**
  132. * 生命周期函数--监听页面隐藏
  133. */
  134. onHide: function () {
  135. },
  136. /**
  137. * 生命周期函数--监听页面卸载
  138. */
  139. onUnload: function () {
  140. },
  141. /**
  142. * 页面相关事件处理函数--监听用户下拉动作
  143. */
  144. onPullDownRefresh: function () {
  145. },
  146. /**
  147. * 页面上拉触底事件的处理函数
  148. */
  149. onReachBottom: function () {
  150. },
  151. /**
  152. * 用户点击右上角分享
  153. */
  154. onShareAppMessage: function () {
  155. },
  156. /*获取个人信息弹框*/
  157. jurisdiction: function () {
  158. this.setData({
  159. flag: !this.data.flag
  160. })
  161. this.onShow();
  162. }
  163. })