完善页面

This commit is contained in:
wangxiaowei
2025-11-28 19:19:54 +08:00
parent 58211f2430
commit 67c8e8e016
43 changed files with 2722 additions and 1018 deletions

View File

@ -17,7 +17,14 @@
<view class="mt-56rpx text-center">
<view class="text-28rpx leading-40rpx text-#606266">{{ title }}</view>
<view class="mt-24rpx">
<price-format color="#303133" :first-size="44" :second-size="44" :subscript-size="28" :price="money"></price-format>
<!-- 是否是一键续订 -->
<template v-if="renew">
<price-format color="#303133" :first-size="44" :second-size="44" :subscript-size="28" :price="renewPrice"></price-format>
</template>
<!-- 正常订单金额 -->
<template v-if="!renew">
<price-format color="#303133" :first-size="44" :second-size="44" :subscript-size="28" :price="money"></price-format>
</template>
</view>
<view class="mt-12rpx flex items-center justify-center">
<view class="text-24rpx leading-34rpx text-#606266">
@ -31,7 +38,7 @@
<view class="bg-white rounded-16rpx px-30rpx py-34rpx mx-30rpx mt-84rpx">
<view class="font-400 text-32rpx leading-44rpx text-#303133 border-b border-b-solid border-b-#F6F7F8 pb-16rpx mb-32rpx">支付方式</view>
<!-- pay 组件 -->
<pay @pay="Cashier.handleGetPayValue" :storeMoney="storeMoney"></pay>
<pay @pay="Cashier.handleGetPayValue" :hidePlatformBalance="hidePlatformBalance" :hideStoreBalance="hideStoreBalance" :hideWechat="hideWechat" :storeMoney="storeMoney"></pay>
</view>
<view
@ -43,15 +50,17 @@
<script lang="ts" setup>
import Pay from '@/components/Pay.vue'
import { getTeaSpecialistDetails, getTeaSpecialistOrderDetails, teaSpecialistPrepay, teaSpecialistPay } from '@/api/tea'
import { getTeaSpecialistDetails } from '@/api/tea'
import { ITeaSpecialistDetailsFields } from '@/api/types/tea'
import { toast } from '@/utils/toast'
import { router } from '@/utils/tools'
import { payTipTeaSpecialist } from '@/api/pay'
import { PayValue } from '@/utils/pay'
import { prePay, balancePay } from '@/api/pay'
import { useUserStore } from '@/store'
import type {IUserInfoVo } from '@/api/types/login'
import { getTeaRoomBalance, getTeaRoomOrderDetail } from '@/api/tea-room'
import { getTeaRoomBalance, getTeaRoomOrderDetail, getTeaRoomPackageOrderDetail } from '@/api/tea-room'
import { OrderType } from '@/utils/order'
import { wxPay } from '@/hooks/usePay'
// 用户信息
const userInfo = ref<IUserInfoVo>(null)
@ -84,6 +93,9 @@
// 支付方式
const pay = ref<number>(0)
const hideWechat = ref<boolean>(false)
const hidePlatformBalance = ref<boolean>(false)
const hideStoreBalance = ref<boolean>(false)
// 订单
const orderId = ref<number>(0)
@ -98,7 +110,20 @@
const storeId = ref<number>(0)
const storeMoney = ref<number>(0)
// 一键续订
const renew = ref<string>('')
const renewPrice = ref<number>(0)
// 是否是购买套餐
const isGroupBuying = ref<number>(0)
const groupCouponId = ref<number>(0)
onLoad(async (args) => {
// 一键续订
renew.value = args.renew || ''
isGroupBuying.value = Number(args.isGroupBuying)
groupCouponId.value = Number(args.groupCouponId) || 0
// 获取门店余额
if (args.storeId) {
storeId.value = Number(args.storeId)
@ -109,10 +134,13 @@
// 设置支付来源标题
from.value = args.from || ''
if (from.value === OrderType.TeaRoomOrder) {
if (args.teaRoomName) {
title.value = `茶室预定-${args.teaRoomName}`
// 茶室订单:预定、套餐团购两种方式
if (args.name && isGroupBuying.value == 0) {
title.value = `茶室预定-${args.name}`
} else {
title.value = '茶室预定支付'
title.value = `茶室套餐购买-${args.name}`
hidePlatformBalance.value = true // 隐藏平台余额支付
hideStoreBalance.value = true // 隐藏门店余额支付
}
}
@ -124,10 +152,12 @@
if (args.from == OrderType.TeaRoomOrder && args.orderId) {
// 获取订单详情
orderId.value = Number(args.orderId)
Cashier.handleGetOrderDetails()
if (isGroupBuying.value == 0) {
Cashier.handleGetOrderDetails()
} else {
Cashier.handleGetRoomPackageDetails()
}
}
console.log('页面加载')
})
onUnload(() => {
@ -153,7 +183,9 @@
Object.assign(info, res.teamaster || {})
},
// 获取订单详情
/**
* 获取预定茶室订单详情
*/
handleGetOrderDetails: async () => {
// 获取订单详情接口
const res = await getTeaRoomOrderDetail({
@ -162,8 +194,25 @@
longitude: uni.getStorageSync('longitude')
})
order.value = res
console.log("🚀 ~ order.value:", order.value)
money.value = Number(res.details.amount_price)
money.value = Number(res.details.order_amount)
// 一键续订价格
renewPrice.value = Number(res.details.renew_dtime.renew_price) || 0
},
/**
* 获取茶室套餐订单详情
* @param value
*/
handleGetRoomPackageDetails: async () => {
// 获取订单详情接口
const res = await getTeaRoomPackageOrderDetail({
id: orderId.value,
latitude: uni.getStorageSync('latitude'),
longitude: uni.getStorageSync('longitude')
})
order.value = res
money.value = Number(res.details.order_amount)
},
// 获取支付方式
@ -171,39 +220,43 @@
pay.value = value
},
// 去支付
/**
* 支付
*/
handleToPay: async () => {
console.log("🚀 ~ pay.value :", pay.value )
if (pay.value == null || pay.value == undefined) {
toast.info('请选择支付方式')
return
}
if (from.value == 'tip') {
payTipTeaSpecialist({
id: id.value,
tip_price: money.value,
pay_type: pay.value
}).then(res => {
router.navigateTo('/pages/notice/reserve?type=tipSuccess')
console.log("🚀 ~ res:", res)
})
} else if (from.value == 'order') {
if (from.value == OrderType.TeaRoomOrder) {
// 预支付-茶室订单
uni.showLoading({ title: '支付中...' })
try {
// 预支付
const res1 = await teaSpecialistPrepay({
const res1 = await prePay({
from: isGroupBuying.value ? 'wx' : 'balance',
order_id: orderId.value,
from: 'balance',
pay_way: pay.value,
order_source: 2 //订单来源1-小程序;2-h5;3app
pay_way: pay.value,
order_source: 1, //订单来源1-小程序; 2-h5; 3app
order_type: 1 // 0为茶艺师 1为茶室包间
})
// 支付
const res2 = await teaSpecialistPay({
id: res1.pay_id
})
// 余额支付(平台余额、门店余额)
if (pay.value == PayValue.PlatformBalance || pay.value == PayValue.StoreBalance) {
await balancePay({
id: res1.pay_id
})
} else if (pay.value == PayValue.WeChatPay) {
// 微信支付
// await wxpay(res1.pay_params)
// wxPay()
}
uni.hideLoading()
result.value = 'success'
} catch (error) {
uni.hideLoading()
result.value = 'fail'
}
@ -216,7 +269,7 @@
</script>
<style lang="scss" scoped>
<style lang="scss">
page {
background-color: $cz-page-background;
}