123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <template>
- <view>
- <nav-bar title="我的直播课"></nav-bar>
- <view class="content">
- <view class="content__header" v-if="livingSectionList[0]" @click="goLive(livingSectionList[0])">
- <image class="img" src="../static/live.png" mode="widthFix"></image>
- <view class="note">正在直播中</view>
- <view class="title">{{livingSectionList[0].name}}</view>
- </view>
- <view class="content__body">
- <view class="list">
- <view class="item" v-for="(item,index) in list" :key="index" @click="go(item)">
- <image mode="widthFix" class="img" :src="$method.splitImgHost(item.coverUrl,false)"></image>
- <view class="title">{{item.goodsName}}</view>
- <view class="desc">
- <image class="desc__img" src="../static/icon-list.png"></image>
- 共 <text>{{item.studyCount}}</text> 学时
- </view>
- <view class="desc">
- <image mode="widthFix" class="desc__img" src="../static/icon-time.png"></image>
- 直播日期:<text>{{$method.timestampToTime(item.liveStartTime)}} - {{$method.timestampToTime(item.liveEndTime)}}</text>
- </view>
- <view class="button">进入学习</view>
- </view>
-
- <view v-if="list.length==0">
- <u-empty text="暂无直播课" margin-top="500" mode="list"></u-empty>
-
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import config from '@/common/config'
- import { mapGetters } from 'vuex';
- export default {
- data() {
- return {
- list:[],
- param:{
- pageNum:1,
- pageSize:10
- },
- livingSectionList:[],
- total:0,
- };
- },
- onUnload() {},
- computed: { ...mapGetters(['userInfo']) },
- onLoad(option) {
- this.goodsListGoodsUserLive()
- this.goodsLivingSectionList();
- },
- onShow() {},
- onReachBottom() {
- if (this.list.length < this.total) {
- this.param.pageNum++;
- this.goodsListGoodsUserLive();
- }
- },
- methods: {
- studyRecordGetChannelBasicInfo(channelId) {
- return new Promise((resolve) => {
- this.$api
- .studyRecordGetChannelBasicInfo({
- channelId,
- })
- .then((res) => {
- resolve(res.data.data);
- });
- });
- },
- goodsLivingSectionList() {
- this.$api.goodsLivingSectionList().then(res => {
- this.livingSectionList = res.data.data;
- })
- },
- goodsListGoodsUserLive() {
- this.$api.goodsListGoodsUserLive(this.param).then(res => {
- this.list.push(...res.data.rows)
- this.total = res.data.total
- })
- },
- async goLive(item) {
- let data = await this.studyRecordGetChannelBasicInfo(item.liveUrl);
- let nowTime = +this.$method.timest();
-
- if (item.liveStartTime > nowTime) {
- if (data.watchStatus == "end" || data.watchStatus == "playback") {
- uni.showToast({
- title: '直播未开始',
- icon: 'none'
- });
- return;
- }
- } else if (
- item.liveStartTime < nowTime &&
- item.liveEndTime > nowTime
- ) {
- if (data.watchStatus == "end" || data.watchStatus == "playback") {
- uni.showToast({
- title: '暂无直播',
- icon: 'none'
- });
- return;
- }
- } else if (item.liveEndTime < nowTime) {
- if (data.watchStatus == "end" || data.watchStatus == "playback") {
- uni.showToast({
- title: '直播已结束',
- icon: 'none'
- });
- return;
- }
- }
- let moduleId = item.moduleId || 0;
- let chapterId = item.chapterId || 0;
- let sectionId = item.sectionId || item.menuId;
- let uuid = new Date().valueOf() + ""
- // buyCourse 是否购买课程:1是 0否
- let encode = encodeURIComponent(config.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+'§ionId='+sectionId+'&chapterId='
- +chapterId+'&moduleId='+moduleId+'&buyCourse=1'+'&ident='+uuid)
- uni.navigateTo({
- url:`../../pages/webview/index?url=`+encode
- })
- },
- go(item) {
- this.$api.courseCourseList({
- pageNum: 1,
- pageSize: 1,
- goodsId: item.goodsId,
- gradeId: 0,
- orderGoodsId: item.orderGoodsId,
- }).then(res => {
- if (res.data.code == 200) {
- if(res.data.total > 1) {
- // uni.navigateTo({
- // url:'/pages5/liveDetail/course?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0'
- // })
- uni.navigateTo({
- url:'/pages3/live/detail?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0&courseId=""'
- })
- } else if(res.data.total == 1) {
- uni.navigateTo({
- url:'/pages3/live/detail?orderGoodsId='+item.orderGoodsId+'&goodsId='+item.goodsId+'&gradeId=0&courseId='+ res.data.rows[0].courseId
- })
- } else {
- uni.showToast({
- icon:'none',
- title:'暂无可观看的直播课程'
- })
- }
-
- }
- });
-
- }
- }
- };
- </script>
- <style>
- page {
- background-color: #eaeef1;
- }
- </style>
- <style lang="scss" scope>
- .content {
- padding:24rpx;
-
- &__header {
- position:relative;
- width:100%;
- height:150rpx;
- padding:24rpx 150rpx 24rpx 24rpx;
-
- .img {
- position:absolute;
- left:0;
- top:0;
- width:100%;
- }
-
- .note {
- position:relative;
- z-index: 10;
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #EFDBFF;
- }
-
- .title {
- position:relative;
- z-index: 10;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FFFFFF;
- }
-
- .desc {
-
- }
- }
-
- &__body {
- .list {
- .item {
- margin-top:20rpx;
- background: #fff;
- padding: 24rpx;
- box-shadow: 0px 10rpx 9rpx 1px rgba(165, 196, 239, 0.1);
- border-radius: 24rpx;
-
- .img {
- width: 654rpx;
- height: 367rpx;
- background: #E6EEFF;
- border-radius: 16rpx;
- }
-
- .title {
- margin-top:10rpx;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- display: -webkit-box;
-
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- }
-
- .desc {
- margin-top:10rpx;
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- display: flex;
- align-items: center;
-
- &__img {
- margin-right:5rpx;
- width:24rpx;
- height:24rpx;
- }
-
- text {
- color:#666;
- }
- }
-
- .button {
- margin-top:10rpx;
- width: 100%;
- height: 64rpx;
- background: #007AFF;
- border-radius: 16rpx;
- text-align: center;
- line-height: 64rpx;
- color:#fff;
- font-size: 28rpx;
- }
- }
- }
- }
- }
- </style>
|