mistakes.js 4.1 KB

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