index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // pages/user/my_course/my_course.js
  2. import {
  3. getMyHostlesson,
  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. testData: 10,
  18. time: 96 * 60 * 1000,
  19. list: [],
  20. noExhibitionImg
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. async onLoad(options) {
  26. if (options.userId) {
  27. // const res = await getMyHostlesson(options.userId);
  28. this.getCourseList(options.userId)
  29. }
  30. },
  31. async getCourseList(id) {
  32. // const res = await getMyPaidlesson(id);
  33. const res = await getVRCourseList();
  34. console.log('res', res)
  35. if (res.code === 0) {
  36. this.setData({
  37. list: res.data.records ? res.data.records.map(item => {
  38. item.courseStaus = getCourseStatus(item.openRoomTime, item.endRoomTime)
  39. return item
  40. }) : []
  41. })
  42. }
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady() {
  48. },
  49. /**
  50. * 生命周期函数--监听页面显示
  51. */
  52. onShow() {
  53. },
  54. /**
  55. * 生命周期函数--监听页面隐藏
  56. */
  57. onHide() {
  58. },
  59. /**
  60. * 生命周期函数--监听页面卸载
  61. */
  62. onUnload() {
  63. },
  64. /**
  65. * 页面相关事件处理函数--监听用户下拉动作
  66. */
  67. onPullDownRefresh() {
  68. },
  69. /**
  70. * 页面上拉触底事件的处理函数
  71. */
  72. onReachBottom() {
  73. },
  74. /**
  75. * 用户点击右上角分享
  76. */
  77. onShareAppMessage() {
  78. },
  79. onRefresh() {
  80. this.setData({
  81. enable: true
  82. });
  83. setTimeout(() => {
  84. this.setData({
  85. enable: false
  86. });
  87. }, 1500);
  88. },
  89. onScroll(e) {
  90. const {
  91. scrollTop
  92. } = e.detail;
  93. this.setData({
  94. scrollTop
  95. });
  96. }
  97. })