list.vue 6.4 KB

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