mistakes.js 3.0 KB

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