完善茶艺师接口对接

This commit is contained in:
wangxiaowei
2026-01-05 00:39:06 +08:00
parent 237df8d039
commit 39c64a2504
29 changed files with 1204 additions and 651 deletions

View File

@ -41,7 +41,7 @@
<pay @pay="Cashier.handleGetPayValue" :hidePlatformBalance="hidePlatformBalance" :hideStoreBalance="hideStoreBalance" :hideWechat="hideWechat" :storeMoney="storeMoney"></pay>
</view>
<view class="fixed bottom-70rpx left-0 right-0 text-#fff font-bold text-30rpx leading-42rpx mx-60rpx text-center rounded-8rpx w-630rpx" >
<view class="fixed bottom-70rpx left-0 right-0 text-#fff font-bold text-30rpx leading-42rpx mx-60rpx text-center rounded-8rpx w-630rpx" >
<wd-button custom-class='!bg-[#4C9F44] !rounded-8rpx !h-90rpx !leading-90rpx !w-630rpx' :disabled="isSubmitting" @click='Cashier.handleToPay'>{{ isGroupBuying ? '立即购买' : '立即预定' }}</wd-button>
</view>
</view>
@ -50,7 +50,7 @@
<script lang="ts" setup>
import { getTeaSpecialistDetails } from '@/api/tea'
import { ITeaSpecialistDetailsFields } from '@/api/types/tea'
import { prePay, balancePay } from '@/api/pay'
import { prePay, balancePay, newPrePay } from '@/api/pay'
import type {IUserInfoVo } from '@/api/types/login'
import { getTeaRoomBalance, getTeaRoomOrderDetail, getTeaRoomPackageOrderDetail, getTeaRoomPackageDetail } from '@/api/tea-room'
import Pay from '@/components/Pay.vue'
@ -60,7 +60,7 @@
import { OrderType } from '@/utils/order'
import { wechatPay } from '@/hooks/usePay'
import { useUserStore } from '@/store'
import { getTeaSpecialistOrderDetails } from '@/api/teaSpecialist-order'
// 用户信息
@ -116,12 +116,17 @@
const renew = ref<string>('')
const renewPrice = ref<number>(0)
// 购买套餐支付
const isGroupBuying = ref<number>(0)
const groupCouponId = ref<number>(0)
// 只有在续订茶艺师下才有这个renewOrderId
const renewOrderId = ref<number>(0)
// 预约茶艺师支付
const reserveTeaSpecialist = ref<boolean>(false)
const teaSpecialistOrderAmount = ref<number>(0) // 茶艺师订单金额
// 防止重复提交
const isSubmitting = ref(false)
@ -139,7 +144,7 @@
// 一键续订
renew.value = args?.renew || ''
renewPrice.value = Number(args?.renewPrice) || 0
// 获取门店余额
if (args.storeId) {
storeId.value = Number(args.storeId)
@ -159,8 +164,16 @@
}
} else if (from.value === OrderType.TeaSpecialist) {
// 预约茶艺师
renewOrderId.value = args.renewOrderId
teaSpecialistOrderAmount.value = Number(args.teaSpecialistOrderAmount) || 0
reserveTeaSpecialist.value = true
title.value = `预约茶艺师-${args.teaSpecialistName || ''}`
if (renewOrderId.value > 0) {
title.value = `续订茶艺师-${args.teaSpecialistName || ''}`
} else {
title.value = `预订茶艺师-${args.teaSpecialistName || ''}`
}
hideStoreBalance.value = true // 隐藏门店余额支付
}
// 用户信息
@ -177,6 +190,9 @@
} else {
Cashier.handleGetRoomPackageDetails()
}
} else if (args.from == OrderType.TeaSpecialist && args.orderId) {
// 获取预定茶艺师订单详情
Cashier.handleGetTeaSpecialistOrderDetails()
}
})
@ -191,20 +207,22 @@
})
const Cashier = {
/**获取茶艺师详情
/**获取茶艺师订单详情
*
* @param id
* @param user_id
*/
handleGetTeaSpecialistDetails: async (id: number, user_id: number) => {
const res = await getTeaSpecialistDetails({
id,
latitude: uni.getStorageSync('latitude') || import.meta.env.VITE_DEFAULT_LATITUDE,
longitude: uni.getStorageSync('longitude') || import.meta.env.VITE_DEFAULT_LONGITUDE,
user_id
handleGetTeaSpecialistOrderDetails: async () => {
const res = await getTeaSpecialistOrderDetails({
id: orderId.value
})
// 将返回的数据合并到 reactive 对象中
Object.assign(info, res.teamaster || {})
order.value = res
if (teaSpecialistOrderAmount.value > 0) {
money.value = teaSpecialistOrderAmount.value
} else {
money.value = Number(res.order_amount)
}
},
/**
@ -226,11 +244,9 @@
* @param value
*/
handleGetRoomPackageDetails: async () => {
// 获取订单详情接口
const res = await getTeaRoomPackageDetail({
id: comboId.value
})
console.log("🚀 ~ res:", res)
money.value = Number(res.details.discount_price)
},
@ -240,7 +256,6 @@
*/
handleGetPayValue: (value: number) => {
pay.value = value
console.log("🚀 ~ pay.value:", pay.value)
},
/**
@ -325,6 +340,59 @@
router.navigateBack(1, 500)
return
}
} else if (from.value == OrderType.TeaSpecialist) {
// 预支付-茶艺师订单
uni.showLoading({ title: '支付中...' })
try {
// 预支付
const res = await newPrePay({
from: PayValueMap[pay.value],
order_id: renewOrderId.value > 0 ? renewOrderId.value : orderId.value, //如果是续单的话则用续单的订单ID
pay_way: pay.value,
order_source: PayOrderSource.MINI, //订单来源1-小程序; 2-h5; 3app
order_type: renewOrderId.value > 0 ? PayOrderType.RenewTeaSpecialist : PayOrderType.TeaSpecialis, // 茶艺师订单
})
// 余额支付(平台余额)
if (pay.value == PayValue.PlatformBalance && res) {
uni.hideLoading()
result.value = 'success'
isSubmitting.value = false
router.navigateBack(1, 500)
} else if (pay.value == PayValue.WeChatPay) {
// 微信支付
wechatPay(res.config).then((res) => {
uni.hideLoading()
if (res === 'success') {
toast.success('支付成功')
result.value = 'success'
} else if (res === 'cancel') {
toast.info('已取消支付')
result.value = 'fail'
} else {
toast.info('支付失败,请重试')
result.value = 'fail'
}
isSubmitting.value = false
router.navigateBack(1, 500)
return
}).catch((e) => {
console.log("🚀 ~ error:", e)
uni.hideLoading()
toast.info('支付失败,请重试')
return
})
}
} catch (error) {
isSubmitting.value = false
uni.hideLoading()
result.value = 'fail'
router.navigateBack(1, 500)
return
}
}
},