my_course.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // pages/user/my_course/my_course.js
  2. import {
  3. getMyPaidlesson,
  4. getVRCourseList
  5. } from '../../../utils/request'
  6. import {
  7. getCourseStatus
  8. } from '../../../utils/courseTime'
  9. const {
  10. noExhibitionImg
  11. } = require('../../../utils/images');
  12. Page({
  13. /**
  14. * 页面的初始数据
  15. */
  16. data: {
  17. noExhibitionImg,
  18. list: [],
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. async onLoad(options) {
  24. if (options.userId) {
  25. this.getPaidList(options.userId);
  26. }
  27. },
  28. async getPaidList(id) {
  29. const res = await getMyPaidlesson(id);
  30. // const res = await getVRCourseList();
  31. console.log('res', res)
  32. if (res.code === 0) {
  33. this.setData({
  34. list: res.data ? res.data.map(item => {
  35. item.courseStaus = getCourseStatus(item.openRoomTime, item.endRoomTime)
  36. return item
  37. }) : []
  38. })
  39. }
  40. },
  41. handleOpenDetail({
  42. currentTarget
  43. }) {
  44. const {
  45. detail
  46. } = currentTarget.dataset;
  47. console.log('detail', detail.id)
  48. wx.navigateTo({
  49. url:`/pages/course_detail/course_detail?id=${detail.id}`,
  50. })
  51. },
  52. /**
  53. * 生命周期函数--监听页面初次渲染完成
  54. */
  55. onReady() {
  56. },
  57. /**
  58. * 生命周期函数--监听页面显示
  59. */
  60. onShow() {
  61. },
  62. /**
  63. * 生命周期函数--监听页面隐藏
  64. */
  65. onHide() {
  66. },
  67. /**
  68. * 生命周期函数--监听页面卸载
  69. */
  70. onUnload() {
  71. },
  72. /**
  73. * 页面相关事件处理函数--监听用户下拉动作
  74. */
  75. onPullDownRefresh() {
  76. },
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom() {
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage() {
  86. },
  87. onRefresh() {
  88. this.setData({
  89. enable: true
  90. });
  91. setTimeout(() => {
  92. this.setData({
  93. enable: false
  94. });
  95. }, 1500);
  96. },
  97. onScroll(e) {
  98. const {
  99. scrollTop
  100. } = e.detail;
  101. this.setData({
  102. scrollTop
  103. });
  104. }
  105. })