index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 getMyHostlesson(id);
  33. // const res = await getVRCourseList();
  34. console.log('res', res)
  35. if (res.code === 0) {
  36. this.setData({
  37. list: res.data ? res.data.map(item => {
  38. item.courseStaus = getCourseStatus(item.openRoomTime, item.endRoomTime)
  39. return item
  40. }) : []
  41. })
  42. }
  43. },
  44. openCouse({
  45. currentTarget
  46. }) {
  47. const {
  48. item
  49. } = currentTarget.dataset;
  50. console.log('item', item)
  51. const userInfo = wx.getStorageSync('userInfo')
  52. wx.navigateToMiniProgram({
  53. appId: 'wxd55ee54235e90359',
  54. path: 'pages/paid-room/paid-room',
  55. extraData: {
  56. roomId: item.roomId,
  57. role: "leader",
  58. userId: userInfo.id,
  59. nickname: userInfo.nickName,
  60. avatar: userInfo.avatarUrl,
  61. courseId: item.id
  62. },
  63. envVersion: getApp().globalData.envVersion,
  64. success(res) {
  65. // 打开成功
  66. }
  67. })
  68. },
  69. /**
  70. * 生命周期函数--监听页面初次渲染完成
  71. */
  72. onReady() {
  73. },
  74. /**
  75. * 生命周期函数--监听页面显示
  76. */
  77. onShow() {
  78. },
  79. /**
  80. * 生命周期函数--监听页面隐藏
  81. */
  82. onHide() {
  83. },
  84. /**
  85. * 生命周期函数--监听页面卸载
  86. */
  87. onUnload() {
  88. },
  89. /**
  90. * 页面相关事件处理函数--监听用户下拉动作
  91. */
  92. onPullDownRefresh() {
  93. },
  94. /**
  95. * 页面上拉触底事件的处理函数
  96. */
  97. onReachBottom() {
  98. },
  99. /**
  100. * 用户点击右上角分享
  101. */
  102. onShareAppMessage() {
  103. },
  104. onRefresh() {
  105. this.setData({
  106. enable: true
  107. });
  108. setTimeout(() => {
  109. this.setData({
  110. enable: false
  111. });
  112. }, 1500);
  113. },
  114. onScroll(e) {
  115. const {
  116. scrollTop
  117. } = e.detail;
  118. this.setData({
  119. scrollTop
  120. });
  121. }
  122. })