mistakes.js 4.0 KB

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