mistakes.js 3.4 KB

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