my_course.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.records ? res.data.records.map(item => {
  35. item.courseStaus = getCourseStatus(item.openRoomTime, item.endRoomTime)
  36. return item
  37. }) : []
  38. })
  39. }
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady() {
  45. },
  46. /**
  47. * 生命周期函数--监听页面显示
  48. */
  49. onShow() {
  50. },
  51. /**
  52. * 生命周期函数--监听页面隐藏
  53. */
  54. onHide() {
  55. },
  56. /**
  57. * 生命周期函数--监听页面卸载
  58. */
  59. onUnload() {
  60. },
  61. /**
  62. * 页面相关事件处理函数--监听用户下拉动作
  63. */
  64. onPullDownRefresh() {
  65. },
  66. /**
  67. * 页面上拉触底事件的处理函数
  68. */
  69. onReachBottom() {
  70. },
  71. /**
  72. * 用户点击右上角分享
  73. */
  74. onShareAppMessage() {
  75. },
  76. onRefresh() {
  77. this.setData({
  78. enable: true
  79. });
  80. setTimeout(() => {
  81. this.setData({
  82. enable: false
  83. });
  84. }, 1500);
  85. },
  86. onScroll(e) {
  87. const {
  88. scrollTop
  89. } = e.detail;
  90. this.setData({
  91. scrollTop
  92. });
  93. }
  94. })