list.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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 encode = encodeURIComponent(WEBVIEW_URL+'pages/live/index?token='+uni.getStorageSync('token')+'&userInfo='+JSON.stringify(this.userInfo)+'&channelId='+item.liveUrl+'&gradeId='+0+'&courseId='+this.courseId+'&goodsId='+this.goodsId+'&orderGoodsId='+this.orderGoodsId+'&sectionId='+sectionId+'&chapterId='+chapterId+'&moduleId='+moduleId)
  120. uni.navigateTo({
  121. url:`../../pages/webview/index?url=`+encode
  122. })
  123. },
  124. go(item) {
  125. this.$api.courseCourseList({
  126. pageNum: 1,
  127. pageSize: 1,
  128. goodsId: item.goodsId,
  129. gradeId: 0,
  130. orderGoodsId: item.orderGoodsId,
  131. }).then(res => {
  132. if (res.data.code == 200) {
  133. if(res.data.total > 1) {
  134. uni.navigateTo({
  135. url:'/pages5/liveDetail/course?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0'
  136. })
  137. } else if(res.data.total == 1) {
  138. uni.navigateTo({
  139. url:'/pages3/live/detail?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0&courseId='+ res.data.rows[0].courseId
  140. })
  141. } else {
  142. uni.showToast({
  143. icon:'none',
  144. title:'暂无可观看的直播课程'
  145. })
  146. }
  147. }
  148. });
  149. }
  150. }
  151. };
  152. </script>
  153. <style>
  154. page {
  155. background-color: #eaeef1;
  156. }
  157. </style>
  158. <style lang="scss" scope>
  159. .content {
  160. padding:24rpx;
  161. &__header {
  162. position:relative;
  163. width:100%;
  164. height:150rpx;
  165. padding:24rpx 150rpx 24rpx 24rpx;
  166. .img {
  167. position:absolute;
  168. left:0;
  169. top:0;
  170. width:100%;
  171. }
  172. .note {
  173. position:relative;
  174. z-index: 10;
  175. font-size: 24rpx;
  176. font-family: PingFang SC;
  177. font-weight: bold;
  178. color: #EFDBFF;
  179. }
  180. .title {
  181. position:relative;
  182. z-index: 10;
  183. font-size: 26rpx;
  184. font-family: PingFang SC;
  185. font-weight: bold;
  186. color: #FFFFFF;
  187. }
  188. .desc {
  189. }
  190. }
  191. &__body {
  192. .list {
  193. .item {
  194. margin-top:20rpx;
  195. background: #fff;
  196. padding: 24rpx;
  197. box-shadow: 0px 10rpx 9rpx 1px rgba(165, 196, 239, 0.1);
  198. border-radius: 24rpx;
  199. .img {
  200. width: 654rpx;
  201. height: 367rpx;
  202. background: #E6EEFF;
  203. border-radius: 16rpx;
  204. }
  205. .title {
  206. margin-top:10rpx;
  207. font-size: 32rpx;
  208. font-family: PingFang SC;
  209. font-weight: bold;
  210. color: #333333;
  211. display: -webkit-box;
  212. -webkit-box-orient: vertical;
  213. -webkit-line-clamp: 2;
  214. overflow: hidden;
  215. }
  216. .desc {
  217. margin-top:10rpx;
  218. font-size: 24rpx;
  219. font-family: PingFang SC;
  220. font-weight: 500;
  221. color: #999999;
  222. display: flex;
  223. align-items: center;
  224. &__img {
  225. margin-right:5rpx;
  226. width:24rpx;
  227. height:24rpx;
  228. }
  229. text {
  230. color:#666;
  231. }
  232. }
  233. .button {
  234. margin-top:10rpx;
  235. width: 100%;
  236. height: 64rpx;
  237. background: #007AFF;
  238. border-radius: 16rpx;
  239. text-align: center;
  240. line-height: 64rpx;
  241. color:#fff;
  242. font-size: 28rpx;
  243. }
  244. }
  245. }
  246. }
  247. }
  248. </style>