list.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view>
  3. <nav-bar title="我的直播课"></nav-bar>
  4. <view class="content">
  5. <view class="content__header" v-if="livingSectionList[0]" @click="goLive(livingSectionList[0])">
  6. <image class="img" src="../static/live.png" mode="widthFix"></image>
  7. <view class="note">正在直播中</view>
  8. <view class="title">{{livingSectionList[0].name}}</view>
  9. </view>
  10. <view class="content__body">
  11. <view class="list">
  12. <view class="item" v-for="(item,index) in list" :key="index" @click="go(item)">
  13. <image mode="widthFix" class="img" :src="$method.splitImgHost(item.coverUrl,false)"></image>
  14. <view class="title">{{item.goodsName}}</view>
  15. <view class="desc">
  16. <image class="desc__img" src="../static/icon-list.png"></image>
  17. 共 <text>{{item.studyCount}}</text> 学时
  18. </view>
  19. <view class="desc">
  20. <image mode="widthFix" class="desc__img" src="../static/icon-time.png"></image>
  21. 直播日期:<text>{{$method.timestampToTime(item.liveStartTime)}} - {{$method.timestampToTime(item.liveEndTime)}}</text>
  22. </view>
  23. <view class="button">进入学习</view>
  24. </view>
  25. <view v-if="list.length==0">
  26. <u-empty text="暂无直播课" margin-top="500" mode="list"></u-empty>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. // import { websocket } from '@/common/socket.js';
  35. import {WEBVIEW_URL} from '@/common/request.js'
  36. import { mapGetters } from 'vuex';
  37. export default {
  38. data() {
  39. return {
  40. list:[],
  41. param:{
  42. pageNum:1,
  43. pageSize:10
  44. },
  45. livingSectionList:[],
  46. total:0,
  47. };
  48. },
  49. onUnload() {},
  50. computed: { ...mapGetters(['userInfo']) },
  51. onLoad(option) {
  52. this.goodsListGoodsUserLive()
  53. this.goodsLivingSectionList();
  54. },
  55. onShow() {},
  56. onReachBottom() {
  57. if (this.list.length < this.total) {
  58. this.param.pageNum++;
  59. this.goodsListGoodsUserLive();
  60. }
  61. },
  62. methods: {
  63. studyRecordGetChannelBasicInfo(channelId) {
  64. return new Promise((resolve) => {
  65. this.$api
  66. .studyRecordGetChannelBasicInfo({
  67. channelId,
  68. })
  69. .then((res) => {
  70. resolve(res.data.data);
  71. });
  72. });
  73. },
  74. goodsLivingSectionList() {
  75. this.$api.goodsLivingSectionList().then(res => {
  76. this.livingSectionList = res.data.data;
  77. })
  78. },
  79. goodsListGoodsUserLive() {
  80. this.$api.goodsListGoodsUserLive(this.param).then(res => {
  81. this.list.push(...res.data.rows)
  82. this.total = res.data.total
  83. })
  84. },
  85. async goLive(item) {
  86. let data = await this.studyRecordGetChannelBasicInfo(item.liveUrl);
  87. let nowTime = +this.$method.timest();
  88. if (item.liveStartTime > nowTime) {
  89. if (data.watchStatus == "end" || data.watchStatus == "playback") {
  90. uni.showToast({
  91. title: '直播未开始',
  92. icon: 'none'
  93. });
  94. return;
  95. }
  96. } else if (
  97. item.liveStartTime < nowTime &&
  98. item.liveEndTime > nowTime
  99. ) {
  100. if (data.watchStatus == "end" || data.watchStatus == "playback") {
  101. uni.showToast({
  102. title: '暂无直播',
  103. icon: 'none'
  104. });
  105. return;
  106. }
  107. } else if (item.liveEndTime < nowTime) {
  108. if (data.watchStatus == "end" || data.watchStatus == "playback") {
  109. uni.showToast({
  110. title: '直播已结束',
  111. icon: 'none'
  112. });
  113. return;
  114. }
  115. }
  116. let moduleId = item.moduleId || 0;
  117. let chapterId = item.chapterId || 0;
  118. let sectionId = item.sectionId || item.menuId;
  119. let uuid = new Date().valueOf() + ""
  120. // buyCourse 是否购买课程:1是 0否
  121. let encode = encodeURIComponent(WEBVIEW_URL+'pages/live/index?token='+uni.getStorageSync('token')+'&userInfo='+JSON.stringify(this.userInfo)+'&channelId='
  122. +item.liveUrl+'&gradeId='+0+'&courseId='+this.courseId+'&goodsId='+this.goodsId+'&orderGoodsId='+this.orderGoodsId+'&sectionId='+sectionId+'&chapterId='
  123. +chapterId+'&moduleId='+moduleId+'&buyCourse=1'+'&ident='+uuid)
  124. uni.navigateTo({
  125. url:`../../pages/webview/index?url=`+encode
  126. })
  127. },
  128. go(item) {
  129. this.$api.courseCourseList({
  130. pageNum: 1,
  131. pageSize: 1,
  132. goodsId: item.goodsId,
  133. gradeId: 0,
  134. orderGoodsId: item.orderGoodsId,
  135. }).then(res => {
  136. if (res.data.code == 200) {
  137. if(res.data.total > 1) {
  138. // uni.navigateTo({
  139. // url:'/pages5/liveDetail/course?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0'
  140. // })
  141. uni.navigateTo({
  142. url:'/pages3/live/detail?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0&courseId=""'
  143. })
  144. } else if(res.data.total == 1) {
  145. uni.navigateTo({
  146. url:'/pages3/live/detail?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0&courseId='+ res.data.rows[0].courseId
  147. })
  148. } else {
  149. uni.showToast({
  150. icon:'none',
  151. title:'暂无可观看的直播课程'
  152. })
  153. }
  154. }
  155. });
  156. }
  157. }
  158. };
  159. </script>
  160. <style>
  161. page {
  162. background-color: #eaeef1;
  163. }
  164. </style>
  165. <style lang="scss" scope>
  166. .content {
  167. padding:24rpx;
  168. &__header {
  169. position:relative;
  170. width:100%;
  171. height:150rpx;
  172. padding:24rpx 150rpx 24rpx 24rpx;
  173. .img {
  174. position:absolute;
  175. left:0;
  176. top:0;
  177. width:100%;
  178. }
  179. .note {
  180. position:relative;
  181. z-index: 10;
  182. font-size: 24rpx;
  183. font-family: PingFang SC;
  184. font-weight: bold;
  185. color: #EFDBFF;
  186. }
  187. .title {
  188. position:relative;
  189. z-index: 10;
  190. font-size: 26rpx;
  191. font-family: PingFang SC;
  192. font-weight: bold;
  193. color: #FFFFFF;
  194. }
  195. .desc {
  196. }
  197. }
  198. &__body {
  199. .list {
  200. .item {
  201. margin-top:20rpx;
  202. background: #fff;
  203. padding: 24rpx;
  204. box-shadow: 0px 10rpx 9rpx 1px rgba(165, 196, 239, 0.1);
  205. border-radius: 24rpx;
  206. .img {
  207. width: 654rpx;
  208. height: 367rpx;
  209. background: #E6EEFF;
  210. border-radius: 16rpx;
  211. }
  212. .title {
  213. margin-top:10rpx;
  214. font-size: 32rpx;
  215. font-family: PingFang SC;
  216. font-weight: bold;
  217. color: #333333;
  218. display: -webkit-box;
  219. -webkit-box-orient: vertical;
  220. -webkit-line-clamp: 2;
  221. overflow: hidden;
  222. }
  223. .desc {
  224. margin-top:10rpx;
  225. font-size: 24rpx;
  226. font-family: PingFang SC;
  227. font-weight: 500;
  228. color: #999999;
  229. display: flex;
  230. align-items: center;
  231. &__img {
  232. margin-right:5rpx;
  233. width:24rpx;
  234. height:24rpx;
  235. }
  236. text {
  237. color:#666;
  238. }
  239. }
  240. .button {
  241. margin-top:10rpx;
  242. width: 100%;
  243. height: 64rpx;
  244. background: #007AFF;
  245. border-radius: 16rpx;
  246. text-align: center;
  247. line-height: 64rpx;
  248. color:#fff;
  249. font-size: 28rpx;
  250. }
  251. }
  252. }
  253. }
  254. }
  255. </style>