list.vue 6.4 KB

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