mistakes.js 3.1 KB

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