You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

384 lines
8.9 KiB

1 year ago
<template>
<view class="container">
1 year ago
<image class="cbg" :src="base.imgHost('course-bg.png')"></image>
1 year ago
<view v-if="!hasImg"></view>
<view v-else>
<view class="detail">
<!-- <view class="detail-title">{{info.name}}</view>
<view class="detail-time" v-if="info.start_date">
<u-icon name="clock"></u-icon>
<text>开课日期{{info.start_date}} {{info.end_date}}</text>
</view> -->
<block v-if="imgList.length>0">
<view v-for="item in imgList">
<image mode="widthFix" :src="item.url"></image>
</view>
</block>
<block v-else>
<view class="detail-noinfo">
<image mode="widthFix" :src="base.imgHost('mycourse-status.png')"></image>
<text>课程详情敬请期待...</text>
</view>
</block>
1 year ago
</view>
1 year ago
<view class="detail-btn" v-if="info.sign_status===10">
<view @click="toApply">
<image class="course-btn" :src="base.imgHost('course-btn.png')"></image>
<text>我要报名</text>
1 year ago
</view>
</view>
1 year ago
</view>
1 year ago
1 year ago
<tabbar :currentPage="1"></tabbar>
<view class="modal">
<u-popup v-model="showRegister" mode="bottom">
<view>
<view class="modal-tip">提示</view>
<view class="modal-content">
<view>如您已是我方校友请先绑定账号</view>
<view @click="goBind" class="modal-bind">
去绑定
</view>
<view>如您还不是我方校友请先注册</view>
<view @click="toRegister" class="modal-register">
去注册
</view>
</view>
</view>
</u-popup>
1 year ago
</view>
</view>
</template>
<script>
1 year ago
import tabbar from '@/components/tabbar/tabbar.vue';
import {
ROOTPATH as baseUrl
} from "@/common/config.js"
1 year ago
export default {
components: {
1 year ago
tabbar,
1 year ago
},
data() {
1 year ago
return {
hasMobile: false,
course_id: '',
1 year ago
info: {},
1 year ago
imgList: [],
1 year ago
showRegister: false,
hasImg: false,
1 year ago
sign_info: {}
1 year ago
}
},
onShareAppMessage(res) {
return {
path: "/packages/course/detail?id=" + this.course_id, //这是为了传参 onload(data){let id=data.id;}
title: this.info.name,
imageUrl: '/static/share.jpg'
1 year ago
}
1 year ago
},
onShareTimeline() {
return {
path: "/packages/course/detail?id=" + this.course_id, //这是为了传参 onload(data){let id=data.id;}
title: this.info.name,
imageUrl: '/static/share.jpg'
}
1 year ago
},
1 year ago
onLoad(options) {
1 year ago
this.course_id = options.id
1 year ago
let token = uni.getStorageSync('stbc1_lifeData') ? uni.getStorageSync('stbc1_lifeData').vuex_token : ''
1 year ago
if (this.base.isNull(token)) {
this.getToken()
} else {
1 year ago
let user = uni.getStorageSync("stbc1_lifeData") ? uni.getStorageSync("stbc1_lifeData").vuex_user : {}
1 year ago
if (!this.base.isNull(user.mobile)) {
this.hasMobile = true
} else {
this.hasMobile = false
}
this.getCourseDetail(this.course_id)
1 year ago
}
},
1 year ago
onHide() {
this.showRegister = false
},
1 year ago
methods: {
1 year ago
async getToken() {
let that = this
1 year ago
const loginResult = await new Promise((resolve, reject) => {
uni.login({
provider: 'weixin',
success: (res) => {
resolve(res.code);
},
fail: (err) => {
console.error('uni.login失败:', err);
reject(err);
}
});
});
const tokenResult = await new Promise((resolve, reject) => {
this.$u.api.login({
code: loginResult
}).then(res1 => {
console.log("res1", res1)
uni.setStorageSync("stbc1_lifeData", {
'vuex_token': res1.token
1 year ago
})
1 year ago
resolve(res1.token);
}).catch(err => {
reject(err)
console.log('login-error:', JSON.stringify(err))
})
1 year ago
});
1 year ago
await this.getUserInfo(tokenResult)
await this.getCourseDetail(this.course_id)
},
async getUserInfo(tokenResult) {
let that = this
await this.$u.api.user().then(res2 => {
uni.setStorageSync("stbc1_lifeData", {
'vuex_token': tokenResult,
"vuex_user": res2.user
})
if (!that.base.isNull(res2.user.mobile)) {
that.hasMobile = true
} else {
that.hasMobile = false
}
})
1 year ago
},
1 year ago
1 year ago
async getCourseDetail(id) {
1 year ago
const res = await this.$u.api.courseDetail({
course_id: id
})
this.info = this.base.requestToForm(this.info, res)
if (res.publicize && res.publicize.length > 0) {
this.imgList = res.publicize
}
1 year ago
this.hasImg = true
let typeName = res.type_detail ? res.type_detail.name + " | " : ''
1 year ago
uni.setNavigationBarTitle({
1 year ago
title: typeName + res.name,
1 year ago
success: function() {
console.log('标题设置成功');
},
fail: function(err) {
console.error('标题设置失败', err);
}
});
1 year ago
},
1 year ago
// 是否有手机号,有则是学员, 没有就是游客。
// 游客可以选择绑定 或 注册报名
// 报名
1 year ago
async toApply() {
1 year ago
let that = this
1 year ago
// 我已报名该课程
1 year ago
if (this.info.my_user) {
1 year ago
const res = await this.$u.api.courseGetSign({
course_id: this.course_id
})
this.sign_info = res.detail
// 默认状态页
let url = '/packages/mycourse/courseStatus?id=' + this.course_id
// 审核通过
if (this.sign_info.status === 1) {
// 不需要付费 有群聊二维码进详情,没有进状态
if (this.info.is_fee === 0) {
if (!this.base.isNull(this.info.qun_image_id)) {
url = '/packages/course/freeDetail?id=' + this.course_id
}
} else {
// 付费 进详情
url = '/packages/mycourse/detail?id=' + this.course_id
}
} else {
// 待审核 不通过 备选 放弃 4取消 6黑名单
url = '/packages/mycourse/courseStatus?id=' + this.course_id
}
1 year ago
this.base.toast("您已报名该课程", 2000, function() {
setTimeout(function() {
uni.navigateTo({
1 year ago
url: url
1 year ago
})
1 year ago
}, 500)
1 year ago
})
return
}
1 year ago
// 收费的不限制报名人数 total没值也不限制
// 免费的限制报名人数
if (!this.info.is_fee && (this.info.total && this.info.total > 0)) {
// 报名人数已满
if (this.info.course_signs_count >= this.info.total) {
this.base.toast("当前报名人数已满")
return
}
}
// 游客就登录 或 注册
if (!this.hasMobile) {
this.showRegister = true
return
} else {
uni.navigateTo({
url: '/packages/apply/index?id=' + this.course_id
})
}
},
// 去绑定登录
goBind() {
uni.navigateTo({
url: '/packages/register/login?id=' + this.course_id
1 year ago
})
1 year ago
},
// 去注册
toRegister() {
uni.navigateTo({
url: '/packages/register/index?id=' + this.course_id
1 year ago
})
},
}
}
</script>
<style lang="scss" scoped>
.container {
1 year ago
width: 100%;
height: 100vh;
.cbg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100vh;
}
1 year ago
.detail {
width: 100%;
1 year ago
height: 100vh;
overflow: scroll;
1 year ago
// padding: 40rpx 80rpx;
1 year ago
position: relative;
1 year ago
padding-bottom: 115rpx;
1 year ago
1 year ago
image {
width: 100%;
}
1 year ago
&-title {
font-size: 32rpx;
color: #000096;
text-align: center;
padding: 40rpx 0rpx;
}
&-time {
display: flex;
align-items: center;
padding-bottom: 40rpx;
color: rgba(0, 0, 0, 0.4);
justify-content: center;
&>text {
margin-left: 10rpx;
}
}
&-noinfo {
width: calc(100% - 160rpx);
1 year ago
position: absolute;
top: calc(50% - 340rpx);
left: 50%;
transform: translate(-50%, 0%);
&>image {
width: 100%;
}
&>text {
font-size: 42rpx;
color: #000;
}
}
1 year ago
}
1 year ago
1 year ago
.detail-btn {
width: 100%;
1 year ago
height: 199rpx;
1 year ago
position: fixed;
left: 0;
1 year ago
bottom: 160rpx;
text-align: center;
1 year ago
&>view {
1 year ago
>image {
width: 580rpx;
height: 199rpx;
margin: 0 auto;
display: block;
}
>text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #fff;
font-size: 32rpx;
}
}
}
1 year ago
.modal {
::v-deep .u-drawer-bottom {
border-radius: 40rpx;
}
&-tip {
text-align: center;
padding: 30rpx;
font-size: 32rpx;
}
&-content {
height: 450rpx;
padding: 0 30rpx;
font-size: 32rpx;
text-align: center;
&>view {
margin: 30rpx auto;
}
}
&-bind {
width: 45%;
text-align: center;
margin: 0 auto;
color: #fff;
border-radius: 30rpx;
padding: 20rpx;
background: linear-gradient(to right, #e4cdb4, #c69c6d);
}
&-register {
width: 45%;
text-align: center;
margin: 0 auto;
color: #fff;
border-radius: 30rpx;
padding: 20rpx;
background: linear-gradient(to right, #5e5fbc, #0d0398);
}
1 year ago
}
}
</style>