martial-arts/pagesB/course-detail/course-detail.vue

222 lines
6.7 KiB
Vue
Raw Normal View History

2022-08-03 13:28:45 +00:00
<template>
<view>
2022-08-03 13:28:45 +00:00
<status-container titlet="课程详情" returnc="#FFFFFF">
<view v-if="isLoading" slot="content" style="margin-top: -20rpx;">
2022-08-03 13:28:45 +00:00
<view class="bacf">
<view class="fon32 tcenter pad-s50">{{couresDetail.name}}</view>
2022-08-18 08:21:58 +00:00
<view class="pad30 posir disjcac">
<image :src="couresDetail.cover" style="height: 388rpx;" mode="aspectFill" class="width100" lazy-load></image>
2022-08-03 13:28:45 +00:00
</view>
<view class="mar-zy30 bbot pad-x10">
<span class="fon28 bold posir pad-x10">
<text>课程介绍</text>
2022-08-03 13:28:45 +00:00
<view class="posia-xzy" style="height: 6rpx;background-color: #e42417;bottom: -2rpx;"></view>
</span>
</view>
<view class="mar-zy30 pad-sx20 bbot">
<view class="disjbac ae pad-x20" style="color: #262626;">
<view class="fon24">教练{{couresDetail.teacher}}</view>
<view class="fon20">{{couresDetail.published_at.slice(0,10).split('-').join('.')}}</view>
</view>
<view class="rich-text fon24" style="line-height: 1.8;">
<rich-text :nodes="couresDetail.content" style="color: #5a5a5a;"></rich-text>
2022-08-03 13:28:45 +00:00
</view>
</view>
2022-08-11 10:27:47 +00:00
<view class="disjcac pad-sx40" v-if="!couresDetail.is_buy">
2022-08-03 13:28:45 +00:00
<view class="disjcac fon28 radius34"
style="width: 290rpx;height: 68rpx;border: 2rpx solid #e42417;color: #e42417;"
2022-08-10 10:18:06 +00:00
@tap="goBuy">立即购买</view>
2022-08-03 13:28:45 +00:00
</view>
</view>
<view class="pad-zy20">
<view class="disjb ae mar-s40">
<view class="fon32 bold colb">推荐课程</view>
<view class="fon20" style="color: #bbb4b3;" @tap="$toolAll.tools.goPage('/pages/tabbar/course/course')">+</view>
2022-08-03 13:28:45 +00:00
</view>
2023-03-23 02:51:22 +00:00
<list ref="refcourse" @goDetail="goDetail(arguments)"></list>
2022-08-03 13:28:45 +00:00
</view>
<!-- 登录弹框 start -->
<view class="posAll disjc" v-if="ifLogin">
<view class="bacf radius10 posir disjcac fc pad-zy60" style="height: 256rpx;margin-top: 304rpx;">
<image src="/static/tabbar/icon-password.png" mode="" lazy-load style="width: 86rpx;height: 102rpx;"></image>
2022-08-12 10:14:13 +00:00
<view class="fon28 mar-s20">请登录后查看课程<span style="color:#e42417;" @tap="goLogin"></span></view>
2022-08-03 13:28:45 +00:00
<view class="posia-sy20" @tap="ifLogin=false"><i class="icon icon-del-white fon24" style="color: #9d9d9d;"></i></view>
</view>
</view>
<!-- 登录弹框 end -->
</view>
</status-container>
</view>
</template>
<script>
// 底部组件
import footTab from '@/components/foot-tabs/foot-tab.vue';
import list from '@/components/list.vue';
export default {
2022-08-16 10:06:46 +00:00
components:{'foot-tab' :footTab,list},
2022-08-03 13:28:45 +00:00
data() {
return {
richText:'', //
ifLogin:false, //是否登录
isLoading:false, //加载完成
couresDetail:{}, //课程详情
couresRecommend:[], //课程推荐
classId:'', //分类id
id:'', //课程id
page:1, //页数
2022-08-10 10:18:06 +00:00
size:1000, //条数
2022-08-12 10:14:13 +00:00
courseList:[],
2022-08-03 13:28:45 +00:00
}
},
onLoad(op) {
if(op.id){
2022-08-12 10:14:13 +00:00
if(op.invite_code) {
// 设置为第一次进入
this.$store.commit('setFristIn',true);
uni.setStorageSync('invite_code',op.invite_code);
} else {
this.$store.commit('setFristIn',false);
}
this.id = op.id;
2022-08-12 10:14:13 +00:00
this.classId = op.category_id;
// 获取课程详情
2022-08-16 10:06:46 +00:00
this.getCouresDetail(this.id);
}
2022-08-03 13:28:45 +00:00
},
2022-08-10 10:18:06 +00:00
onShareAppMessage(res) {
var shareObj = {
     title: ``, // 默认是小程序的名称(可以写slogan等)
2022-08-12 10:14:13 +00:00
     path: `/pagesB/course-detail/course-detail?id=${this.id}&category_id=${this.classId}&invite_code=${uni.getStorageSync('invite_code')}`, // 默认是当前页面,必须是以‘/’开头的完整路径
2022-08-10 10:18:06 +00:00
     imageUrl: ``//自定义图片路径可以是本地文件路径、代码包文件路径或者网络图片路径支持PNG及JPG不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
  };
  return shareObj;
},
onShow() {
uni.removeStorageSync('courseInfo');
uni.removeStorageSync('skuList');
2022-08-16 10:06:46 +00:00
// 获取课程详情
this.getCouresDetail(this.id);
2022-08-10 10:18:06 +00:00
},
2022-08-03 13:28:45 +00:00
methods: {
// 获取课程详情
getCouresDetail(id){
uni.showLoading({
title:'加载中'
});
2022-08-10 10:18:06 +00:00
this.$requst.get('/api/spu/detail',{id}).then(res=>{
console.log(res,'课程详情')
if(res.code==0) {
this.couresDetail = res.data.detail;
2022-08-10 10:18:06 +00:00
// 课程规格
this.$requst.get('/api/spu/spec',{id}).then(resspec=>{
if(resspec.code==0){
this.courseList.push({
sku_list:[
{
sku_coding:resspec.data.sku.coding,
num:1,
}
]
})
}
})
// 获取课程推荐
this.getCouresRecommend();
}
uni.hideLoading();
this.isLoading = true;
})
},
2022-08-10 10:18:06 +00:00
// 立即购买
goBuy(){
2022-08-12 10:14:13 +00:00
if(uni.getStorageSync('is_active')){
let params = {
sku_list:this.courseList[0].sku_list
};
this.$requst.post('/api/order/prepare-info',params).then(res=>{
if(res.code==0){
uni.setStorageSync('courseInfo',res.data);
uni.setStorageSync('skuList',params.sku_list);
uni.navigateTo({
url:'/pagesB/buy-now/buy-now'
})
}
})
} else {
this.ifLogin = true;
}
2022-08-10 10:18:06 +00:00
},
// 获取课程推荐
getCouresRecommend(){
let params = {
page:this.page,
size:this.size,
category_id:this.classId,
id:this.id
}
this.$requst.get('/api/spu/course-recommend',params).then(res=>{
if(res.code==0) {
this.$refs.refcourse.list = res.data.list;
}
})
},
2022-08-03 13:28:45 +00:00
// 去课程详情
2023-03-23 02:51:22 +00:00
goDetail(data){
let id = data[0],
is_buy = data[1];
if(is_buy == 0) {
uni.navigateTo({
url:`/pagesB/course-detail/course-detail?id=${id}&category_id=${this.classId}`
})
}else {
uni.navigateTo({
url:`/pagesB/course-list/course-list?id=${id}`
})
}
},
2023-02-22 02:39:55 +00:00
// 播放视频
playVideo(){
2022-08-12 10:14:13 +00:00
if(this.couresDetail.type=="video_number"){
// #ifdef MP-WEIXIN
wx.openChannelsActivity({
2022-08-12 10:14:13 +00:00
finderUserName:this.couresDetail.video_number,
feedId:this.couresDetail.video_id,
success:(res)=>{},fail:()=>{
2022-08-12 10:14:13 +00:00
// this.$toolAll.tools.showToast('视频已丢失或已删除')
}
})
// #endif
} else {
2022-08-12 10:14:13 +00:00
if(uni.getStorageSync('is_active')){
if(this.couresDetail.is_buy){
let newArr = [];
newArr.push({src:this.couresDetail.video})
uni.setStorageSync('videoList',newArr);
uni.navigateTo({
url:`/pagesB/play-video/play-video?current=${0}`
})
} else {
this.$toolAll.tools.showToast('请购买课程');
}
2022-08-12 10:14:13 +00:00
} else {
this.ifLogin = true;
}
}
2022-08-12 10:14:13 +00:00
},
// 去登录
goLogin(){
uni.navigateTo({
url:`/pages/login/login`
})
}
2022-08-03 13:28:45 +00:00
}
}
</script>
2023-03-28 06:09:31 +00:00
<style>
.rich-text [alt]{width: 100%;}
</style>