更新:增加课程和图书VIP购买及“我的”主页vip身份显示
This commit is contained in:
@@ -259,9 +259,7 @@ const handleChapterClick = (chapter: IChapter) => {
|
||||
border-bottom-left-radius: 40rpx;
|
||||
|
||||
.vip-badge {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
display: inline-block;
|
||||
font-size: 24rpx;
|
||||
background: linear-gradient(90deg, #6429db 0%, #0075ed 100%);
|
||||
color: #fff;
|
||||
|
||||
@@ -124,22 +124,28 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { orderApi } from '@/api/modules/order'
|
||||
import { getUserInfo } from '@/api/modules/user'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { t } from '@/utils/i18n'
|
||||
import type { IGoods, IGoodsDiscountParams } from '@/types/order'
|
||||
import PayWay from '@/components/order/PayWay.vue'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 使用页面传参
|
||||
interface Props {
|
||||
goodsList: IGoods[],
|
||||
userInfo: object,
|
||||
allowPointPay: boolean,
|
||||
orderType: string,
|
||||
backStep: number // 购买完成后返回几层页面
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
goodsList: () => [],
|
||||
userInfo: () => ({}),
|
||||
allowPointPay: () => true,
|
||||
orderType: () => 'order',
|
||||
allowPointPay: true,
|
||||
orderType: 'order',
|
||||
backStep: 1
|
||||
})
|
||||
|
||||
// 订单备注
|
||||
@@ -185,7 +191,7 @@ const calculateAllPrices = async () => {
|
||||
// 计算商品总价
|
||||
calculateTotalPrice()
|
||||
|
||||
await Promise.all([
|
||||
props.orderType === 'order' && await Promise.all([
|
||||
// 获取VIP优惠
|
||||
calculateVipDiscounted(),
|
||||
|
||||
@@ -319,7 +325,7 @@ const calculateFinalPrice = () => {
|
||||
0,
|
||||
totalAmount.value - couponAmount - pointsDiscounted.value - promotionDiscounted.value - vipDiscounted.value
|
||||
)
|
||||
finalAmount.value = result.toFixed(2)
|
||||
finalAmount.value = result
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,7 +333,7 @@ const calculateFinalPrice = () => {
|
||||
*/
|
||||
const validateOrder = (): boolean => {
|
||||
// 验证实付金额是否计算完成
|
||||
if (typeof finalAmount.value != 'number') {
|
||||
if (isNaN(parseFloat(finalAmount.value))) {
|
||||
uni.showToast({
|
||||
title: t('order.invalidPaymentAmount'),
|
||||
icon: 'none'
|
||||
@@ -357,10 +363,19 @@ const handleSubmit = async () => {
|
||||
// 创建订单 此app用天医币支付,创建订单成功即支付成功
|
||||
await createOrder()
|
||||
|
||||
// 重新获取用户信息更新store和本地缓存
|
||||
const res = await getUserInfo()
|
||||
userStore.setUserInfo(res.result)
|
||||
|
||||
uni.showToast({
|
||||
title: t('order.orderSuccess'),
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 返回上一页
|
||||
uni.navigateBack({
|
||||
delta: props.backStep
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -372,18 +387,20 @@ const createOrder = async (): Promise<string | null> => {
|
||||
paymentMethod: 4, // 天医币
|
||||
orderMoney: totalAmount.value,
|
||||
realMoney: finalAmount.value,
|
||||
pointsDeduction: pointsDiscounted.value,
|
||||
jfDeduction: pointsDiscounted.value,
|
||||
// couponId: selectedCoupon.value?.id,
|
||||
// couponName: selectedCoupon.value?.couponEntity.couponName,
|
||||
vipDiscountAmount: vipDiscounted.value,
|
||||
districtMoney: promotionDiscounted.value,
|
||||
remark: remark.value,
|
||||
productList: goodsListParams.value,
|
||||
orderType: props.orderType,
|
||||
productList: props.orderType === 'order' ? goodsListParams.value : null,
|
||||
vipBuyConfigId: props.orderType === 'vip' ? props.goodsList[0].productId : null,
|
||||
abroadVipId: props.orderType === 'abroadVip' ? props.goodsList[0].productId : null,
|
||||
come: 10
|
||||
}
|
||||
|
||||
const res = await orderApi.placeCourseOrder(orderParams)
|
||||
const res = await orderApi.placeOrder(orderParams)
|
||||
|
||||
if (res.orderSn) {
|
||||
return res.orderSn
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<wd-popup
|
||||
v-model="visible"
|
||||
position="bottom"
|
||||
@close="handleClose"
|
||||
>
|
||||
<view class="goods-selector">
|
||||
<view v-if="selectedIndex !== -1" class="goods-info-mini">
|
||||
@@ -93,9 +94,20 @@ const handleConfirm = () => {
|
||||
return
|
||||
}
|
||||
|
||||
visible.value = false
|
||||
emit('confirm', props.goods[selectedIndex.value])
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭弹窗
|
||||
*/
|
||||
const handleClose = () => {
|
||||
visible.value = false
|
||||
emit('close')
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 监听显示状态,重置选择
|
||||
watch(() => props.show, (newVal: boolean) => {
|
||||
if (newVal && props.goods.length > 0) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import { t } from '@/utils/i18n'
|
||||
interface Props {
|
||||
data: any
|
||||
type: string
|
||||
|
||||
@@ -362,13 +362,13 @@ const retry = () => {
|
||||
|
||||
.video-wrapper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
height: 400rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.video-element {
|
||||
width: 100%;
|
||||
height: 400rpx;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.error-display {
|
||||
@@ -401,10 +401,12 @@ const retry = () => {
|
||||
}
|
||||
|
||||
.btn-retry {
|
||||
display: inline-block;
|
||||
background-color: #1989fa;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 20rpx 40rpx;
|
||||
line-height: 1;
|
||||
border-radius: 8rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user