problem_list.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. // pages/problem_list/problem_list.js
  2. const app = getApp()
  3. const { formatDate, formatTime2 } = require('../../utils/util.js')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. baseImgUrl: app.globalData.baseImgUrl,
  10. thumbnail: app.globalData.thumbnail,
  11. maxCreateTime: formatTime2(new Date()),
  12. hiddenModel:false,
  13. pageNo: 1,
  14. pageSize: 10,
  15. isAll: false,
  16. navIndex: 0,
  17. list: [
  18. // {
  19. // "problemPictureId": "",
  20. // "chilName": "小明",
  21. // "childImg": "",
  22. // "createTime": "2019-10-23 30:00:00",
  23. // "problemPicturePath": "",
  24. // }
  25. ],
  26. subject:'语文',
  27. navList: [
  28. {
  29. text: '语文'
  30. },
  31. {
  32. text: '数学'
  33. },
  34. {
  35. text: '英语'
  36. }
  37. ],
  38. footerData: {
  39. actIndex: 0,
  40. list: [
  41. {
  42. text: '首页',
  43. url: '../../image/shou_ye_hui.png',
  44. actUrl: '../../image/shou_ye.png',
  45. src: 'problem_list',
  46. id: 'problem_list'
  47. },
  48. {
  49. text: '学习成长报告',
  50. url: '../../image/xue_qing_hui.png',
  51. actUrl: '../../image/xue_qing.png',
  52. src: 'learning_report',
  53. id: 'learning_report'
  54. },
  55. {
  56. text: '我的',
  57. url: '../../image/wo_de_hui.png',
  58. actUrl: '../../image/wo_de.png',
  59. src: 'me',
  60. id: 'me'
  61. }
  62. ],
  63. },
  64. headerData: {
  65. actIndex: 1,
  66. list: [
  67. {
  68. text: '作业',
  69. src: 'homework_list',
  70. id: 'homework_list'
  71. },
  72. {
  73. text: '难题',
  74. src: 'problem_list',
  75. id: 'problem_list'
  76. },
  77. // {
  78. // text: '辅导课',
  79. // src: 'one_to_one',
  80. // id: 'one_to_one'
  81. // }
  82. ],
  83. },
  84. },
  85. /**
  86. * 生命周期函数--监听页面加载
  87. */
  88. onLoad: function (options) {
  89. options.vipId = app.getGlobalAttributeValue(`parentVipId-${app.getGlobalAttributeValue(`userId`)}`)
  90. this.setData({ options })
  91. },
  92. /**
  93. * 生命周期函数--监听页面初次渲染完成
  94. */
  95. onReady: function () {
  96. },
  97. /**
  98. * 生命周期函数--监听页面显示
  99. */
  100. onShow: function () {
  101. this.getMyInfo()
  102. this.getPuzzleList();
  103. },
  104. /**
  105. * 生命周期函数--监听页面隐藏
  106. */
  107. onHide: function () {
  108. // let pages = getCurrentPages();
  109. // console.log(pages);
  110. },
  111. /**
  112. * 生命周期函数--监听页面卸载
  113. */
  114. onUnload: function () {
  115. },
  116. /**
  117. * 页面相关事件处理函数--监听用户下拉动作
  118. */
  119. onPullDownRefresh: function () {
  120. this.setData({ pageNo: 1 })
  121. this.getPuzzleList(res => {
  122. wx.stopPullDownRefresh()
  123. })
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom: function () {
  129. const { isAll } = this.data;
  130. if (isAll) {
  131. return
  132. }
  133. this.getPuzzleList()
  134. },
  135. /**
  136. * 用户点击右上角分享
  137. */
  138. onShareAppMessage: function () {
  139. },
  140. /**
  141. * 底部导航跳转
  142. */
  143. redirectCtl: app.redirectCtl,
  144. /**
  145. * 路由跳转
  146. */
  147. navigateCtl: app.navigateCtl,
  148. //查看图片
  149. viewImageCtl: app.viewImageCtl,
  150. /**
  151. * 选择切换项
  152. */
  153. selectNavIndexCtl: function (e) {
  154. const { index } = e.currentTarget.dataset
  155. const { navIndex = 0, navList = [] } = this.data || {}
  156. if (navIndex == index) return
  157. const temp = {}
  158. temp[`navIndex`] = index
  159. temp[`subject`] = navList[index].text
  160. this.setData(temp)
  161. this.getPuzzleList()
  162. },
  163. /**
  164. * 我的信息
  165. */
  166. getMyInfo: function () {
  167. const userId = app.globalData.userId || wx.getStorageSync('userId');
  168. const postData = { fn: this.getChildInfo, param: { ...arguments } }
  169. app.post('/api/parents/parents/V2/getMyInfo', {}, 0, postData).then(res => {
  170. const { childList, phone } = res.data;
  171. if (!phone) {
  172. this.redirectCtl({ url: 'phone', method: {isFrist:1} }, true)
  173. }
  174. })
  175. },
  176. // 获取难题列表
  177. getPuzzleList:function(){
  178. const postData = { fn: this.getPuzzleList, param: { ...arguments } }
  179. const { vipId }= this.data.options;
  180. const { pageNo, maxCreateTime, pageSize, list}=this.data;
  181. app.post('/api/parents/parents/V2/problemReviewSimilarVersion', {
  182. vipId,
  183. maxCreateTime,
  184. pageNo,
  185. pageSize
  186. }, 0, postData).then(res => {
  187. const listTemp = res.data.list;
  188. let arr = []
  189. if (pageNo == 1) {
  190. arr = [...listTemp]
  191. } else {
  192. arr = [...list, ...listTemp]
  193. }
  194. console.log(pageNo, pageSize)
  195. this.setData({
  196. list: arr,
  197. pageNo: listTemp.length == pageSize? pageNo + 1 : pageNo,
  198. isAll: listTemp.length < pageSize
  199. })
  200. })
  201. },
  202. })