course.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. // pages/course/course.js
  2. const {
  3. getVRCourseList
  4. } = require('../../utils/request');
  5. const {
  6. noExhibitionImg
  7. } = require('../../utils/images');
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. testData: 20,
  14. enable: false,
  15. scrollTop: 0,
  16. noExhibitionImg,
  17. query: {
  18. pageNum: 1,
  19. pageSize: 10,
  20. searchKey: ""
  21. },
  22. list: []
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad(options) {
  28. },
  29. async getCourseList() {
  30. const {
  31. code,
  32. data
  33. } = await getVRCourseList(this.data.query);
  34. if (code === 0) {
  35. console.log('data', data)
  36. this.setData({
  37. list: data.records
  38. })
  39. }
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady() {},
  45. /**
  46. * 生命周期函数--监听页面显示
  47. */
  48. onShow() {
  49. this.getCourseList();
  50. },
  51. /**
  52. * 生命周期函数--监听页面隐藏
  53. */
  54. onHide() {
  55. },
  56. /**
  57. * 生命周期函数--监听页面卸载
  58. */
  59. onUnload() {
  60. },
  61. handlerSearch({
  62. detail
  63. }) {
  64. console.log('detail', detail.value)
  65. this.setData({
  66. "query.searchKey": detail.value
  67. }, () => {
  68. this.getCourseList();
  69. })
  70. },
  71. /**
  72. * 页面上拉触底事件的处理函数
  73. */
  74. onReachBottom() {
  75. },
  76. /**
  77. * 用户点击右上角分享
  78. */
  79. onShareAppMessage() {
  80. },
  81. openHost() {
  82. wx.navigateToMiniProgram({
  83. appId: 'wxd55ee54235e90359',
  84. path: 'pages/paid-room/paid-room',
  85. extraData: {
  86. roomId: 'test-01586',
  87. role: "leader",
  88. userId: '066893f525e56f09ce8b4420dff7e0681',
  89. nickname: "四维展主持人",
  90. avatar: "https://4dkk.4dage.com/take-look/images/other/6d5298a02bd849119b7e5357cbd6edff.jpeg"
  91. },
  92. envVersion: 'develop',
  93. success(res) {
  94. // 打开成功
  95. }
  96. })
  97. },
  98. openCustomer() {
  99. wx.navigateToMiniProgram({
  100. appId: 'wxd55ee54235e90359',
  101. path: 'pages/paid-room/paid-room',
  102. extraData: {
  103. roomId: 'test-01586',
  104. userId: 'xxxx121212',
  105. role: "customer",
  106. nickname: "四维展客人",
  107. avatar: "https://4dkk.4dage.com/take-look/images/other/6d5298a02bd849119b7e5357cbd6edff.jpeg"
  108. },
  109. envVersion: 'develop',
  110. success(res) {
  111. // 打开成功
  112. }
  113. })
  114. },
  115. handleVRDetail({
  116. currentTarget
  117. }) {
  118. const {
  119. id
  120. } = currentTarget.dataset;
  121. console.log('item-id', id)
  122. wx.navigateTo({
  123. url: `/pages/course_detail/course_detail?id=${id}`,
  124. })
  125. },
  126. onRefresh() {
  127. this.setData({
  128. enable: true,
  129. query: {
  130. pageNum: 1,
  131. pageSize: 10,
  132. searchKey: ""
  133. },
  134. }, () => {
  135. this.getCourseList();
  136. });
  137. setTimeout(() => {
  138. this.setData({
  139. enable: false
  140. });
  141. }, 1500);
  142. },
  143. onScroll(e) {
  144. const {
  145. scrollTop
  146. } = e.detail;
  147. this.setData({
  148. scrollTop
  149. });
  150. }
  151. })