|
@@ -20,7 +20,7 @@
|
|
|
<u-icon name="clock" size="28"></u-icon>
|
|
|
{{ getDateWeek(course.courseDate) }}
|
|
|
</view>
|
|
|
- <view class="course-price">¥{{ course.price }}元</view>
|
|
|
+ <view class="course-price">¥{{ isMember ? course.priceMember : course.price }}元</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="course-form" style="margin-top: 20rpx;">
|
|
@@ -36,7 +36,7 @@
|
|
|
<view class="course-label">
|
|
|
支付方式
|
|
|
</view>
|
|
|
- <view class="course-value" @click="show = true">
|
|
|
+ <view class="course-value" @click="payTypeShow = true">
|
|
|
{{ activePayType }}<i class="iconfont icon-sangedian-copy"></i>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -47,7 +47,7 @@
|
|
|
课程金额
|
|
|
</view>
|
|
|
<view class="course-value">
|
|
|
- ¥{{ course.price }}
|
|
|
+ ¥{{ isMember ? course.priceMember : course.price }}
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="course-form-item">
|
|
@@ -74,7 +74,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="course-form" style="background: none;">
|
|
|
+ <view class="course-form" style="background: none;" v-if="!isMember && course.viewMode === '2'">
|
|
|
<view class="course-form-item">
|
|
|
<text class="text-red" style="font-weight: bold;">个人会员或单位会员免费,点击现在入会></text>
|
|
|
</view>
|
|
@@ -87,60 +87,99 @@
|
|
|
<button class="pay-btn" @click="toBuy">立即购买</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <u-action-sheet :list="list" v-model="show" @click="clickAction" safe-area-inset-bottom></u-action-sheet>
|
|
|
+ <u-action-sheet :list="list" v-model="payTypeShow" @click="clickAction" safe-area-inset-bottom></u-action-sheet>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import {
|
|
|
- ref
|
|
|
+ ref,
|
|
|
+ computed
|
|
|
} from 'vue'
|
|
|
import {
|
|
|
onLoad
|
|
|
} from '@dcloudio/uni-app'
|
|
|
import configService from '@/utils/baseurl.js'
|
|
|
- import { loadCourseDetail } from "@/api/edu.js"
|
|
|
-
|
|
|
+ import {
|
|
|
+ loadCourseDetail,
|
|
|
+ payCourse
|
|
|
+ } from "@/api/edu.js"
|
|
|
+ import {
|
|
|
+ useAuthStore
|
|
|
+ } from '@/store/authStore'
|
|
|
+ const authStore = useAuthStore();
|
|
|
+ const isMember = computed(() => {
|
|
|
+ authStore.loadUserInfo()
|
|
|
+ return authStore.userInfo.isMember == '0' ? false : true
|
|
|
+ })
|
|
|
+ const openid = computed(() => {
|
|
|
+ authStore.loadOpenid()
|
|
|
+ return authStore.openid
|
|
|
+ })
|
|
|
const FILE_URL = configService.FILE_URL;
|
|
|
const courseId = ref("");
|
|
|
const course = ref({})
|
|
|
- const price = ref(0)
|
|
|
+ const price = computed(() => {
|
|
|
+ let val;
|
|
|
+ if (isMember.value) {
|
|
|
+ val = course.value.priceMember
|
|
|
+ } else {
|
|
|
+ val = course.value.price
|
|
|
+ }
|
|
|
+ // 如果后续有积分需求可以写在这里,计算一下积分,返回最终值
|
|
|
+ payForm.value.amount = val
|
|
|
+ return val
|
|
|
+ })
|
|
|
+
|
|
|
const activePayType = ref("微信支付")
|
|
|
+
|
|
|
const list = ref([{
|
|
|
text: '微信支付'
|
|
|
}])
|
|
|
- const show = ref(false)
|
|
|
+
|
|
|
+ const payForm = ref({
|
|
|
+ title: "",
|
|
|
+ desc: "",
|
|
|
+ id: "",
|
|
|
+ amount: "",
|
|
|
+ openid: ""
|
|
|
+ })
|
|
|
+
|
|
|
+ const payTypeShow = ref(false)
|
|
|
+ // 支付完成
|
|
|
const toBuy = () => {
|
|
|
- uni.redirectTo({
|
|
|
- url: "/pages/goOnEdu/course/courseDetail/coursePay?id=" + courseId.value
|
|
|
+ payForm.value.openid = openid.value
|
|
|
+ console.log(payForm.value)
|
|
|
+ // 支付部分
|
|
|
+ payCourse(payForm.value).then(res => {
|
|
|
+ if (res && res.code === 0) {
|
|
|
+ const params = res.data
|
|
|
+ wx.requestPayment({
|
|
|
+ nonceStr: params.nonceStr,
|
|
|
+ package: params.package,
|
|
|
+ paySign: params.paySign,
|
|
|
+ signType: params.signType,
|
|
|
+ timeStamp: params.timeStamp,
|
|
|
+ success(res){
|
|
|
+ msgSuccess("支付成功")
|
|
|
+ },
|
|
|
+ fail(res){
|
|
|
+ msgError("支付失败")
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
+ // uni.redirectTo({
|
|
|
+ // url: "/pages/goOnEdu/course/courseDetail/coursePay?id=" + courseId.value
|
|
|
+ // })
|
|
|
}
|
|
|
|
|
|
- const clickAction = (i) =>{
|
|
|
+ const clickAction = (i) => {
|
|
|
// console.log(i)
|
|
|
activePayType.value = list.value[i].text
|
|
|
- show.value = false
|
|
|
+ payTypeShow.value = false
|
|
|
}
|
|
|
- // 加载数据
|
|
|
- // const init = (id) => {
|
|
|
- // // 加载数据
|
|
|
- // courseId.value = id
|
|
|
- // course.value = {
|
|
|
- // id: id,
|
|
|
- // courseName: "11Vue.js 从入门到精通",
|
|
|
- // courseType: "领袖锻造营",
|
|
|
- // name: "李老师11",
|
|
|
- // courseDate: "2023-09-15",
|
|
|
- // imgUrl: "https://tse4-mm.cn.bing.net/th/id/OIP-C.X_J8jL0bSPQ_jgOrdIbsgQHaEK?rs=1&pid=ImgDetMain",
|
|
|
- // price: 199.00,
|
|
|
- // hasBuy: true,
|
|
|
- // hasFavi: false,
|
|
|
- // payType: "会员免费",
|
|
|
- // expirationDate: "用户注销前有效"
|
|
|
- // }
|
|
|
- // course.courseTime = "18:00"
|
|
|
- // price.value = course.value.price
|
|
|
- // }
|
|
|
+
|
|
|
// 日期格式:xxxx年xx月xx日(星期x)
|
|
|
function getDateWeek(val) {
|
|
|
const date = new Date(val);
|
|
@@ -152,16 +191,19 @@
|
|
|
// const result = `${year}年${month}月${day}日(星期${dayOfWeek})`
|
|
|
return `${year}年${month}月${day}日(星期${dayOfWeek})`
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 初始化
|
|
|
function init(id) {
|
|
|
- loadCourseDetail(id).then(res=>{
|
|
|
- if(res?.data){
|
|
|
+ loadCourseDetail(id).then(res => {
|
|
|
+ if (res?.data) {
|
|
|
course.value = res.data;
|
|
|
+ payForm.value.id = res.data.id;
|
|
|
+ payForm.value.title = res.data.courseName
|
|
|
+ payForm.value.desc = res.data.courseName
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
onLoad((option) => {
|
|
|
const {
|
|
|
id
|