mistakes.js 4.4 KB

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