调试接口
This commit is contained in:
@ -41,26 +41,32 @@
|
||||
<pay @pay="Cashier.handleGetPayValue" :hidePlatformBalance="hidePlatformBalance" :hideStoreBalance="hideStoreBalance" :hideWechat="hideWechat" :storeMoney="storeMoney"></pay>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="fixed bottom-70rpx left-0 right-0 bg-#4C9F44 text-#fff font-bold text-30rpx leading-42rpx mx-60rpx h-90rpx leading-90rpx text-center rounded-8rpx"
|
||||
<!-- <view
|
||||
class="fixed bottom-70rpx left-0 right-0 text-#fff font-bold text-30rpx leading-42rpx mx-60rpx h-90rpx leading-90rpx text-center rounded-8rpx"
|
||||
@click="Cashier.handleToPay">立即支付
|
||||
</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" >
|
||||
<wd-button custom-class='!bg-[#4C9F44] !rounded-8rpx !h-90rpx !leading-90rpx !w-630rpx' :disabled="isSubmitting" @click='Cashier.handleToPay'>{{ isGroupBuying ? '立即购买' : '立即预定' }}</wd-button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import Pay from '@/components/Pay.vue'
|
||||
import { getTeaSpecialistDetails } from '@/api/tea'
|
||||
import { ITeaSpecialistDetailsFields } from '@/api/types/tea'
|
||||
import { prePay, balancePay } 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'
|
||||
import { PayValue, PayValueMap, PayOrderType, PayOrderSource } from '@/utils/pay'
|
||||
import { toast } from '@/utils/toast'
|
||||
import { router } from '@/utils/tools'
|
||||
import { PayValue, PayValueMap } from '@/utils/pay'
|
||||
import { prePay, balancePay } from '@/api/pay'
|
||||
import { useUserStore } from '@/store'
|
||||
import type {IUserInfoVo } from '@/api/types/login'
|
||||
import { getTeaRoomBalance, getTeaRoomOrderDetail, getTeaRoomPackageOrderDetail } from '@/api/tea-room'
|
||||
import { OrderType } from '@/utils/order'
|
||||
import { wxPay } from '@/hooks/usePay'
|
||||
import { wechatPay } from '@/hooks/usePay'
|
||||
import { useUserStore } from '@/store'
|
||||
|
||||
|
||||
|
||||
// 用户信息
|
||||
const userInfo = ref<IUserInfoVo>(null)
|
||||
@ -109,6 +115,7 @@
|
||||
// 门店ID
|
||||
const storeId = ref<number>(0)
|
||||
const storeMoney = ref<number>(0)
|
||||
const comboId = ref<number>(0) // 套餐ID
|
||||
|
||||
// 一键续订
|
||||
const renew = ref<string>('')
|
||||
@ -118,7 +125,13 @@
|
||||
const isGroupBuying = ref<number>(0)
|
||||
const groupCouponId = ref<number>(0)
|
||||
|
||||
// 防止重复提交
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
onLoad(async (args) => {
|
||||
orderId.value = Number(args.orderId)
|
||||
comboId.value = Number(args.cmoboId) || 0
|
||||
|
||||
// 一键续订
|
||||
renew.value = args.renew || ''
|
||||
isGroupBuying.value = Number(args.isGroupBuying)
|
||||
@ -149,8 +162,7 @@
|
||||
|
||||
// 获取订单详情
|
||||
if (args.from == OrderType.TeaRoomOrder && args.orderId) {
|
||||
// 获取订单详情
|
||||
orderId.value = Number(args.orderId)
|
||||
// 获取订单详情
|
||||
if (isGroupBuying.value == 0) {
|
||||
Cashier.handleGetOrderDetails()
|
||||
} else {
|
||||
@ -205,13 +217,11 @@
|
||||
*/
|
||||
handleGetRoomPackageDetails: async () => {
|
||||
// 获取订单详情接口
|
||||
const res = await getTeaRoomPackageOrderDetail({
|
||||
id: orderId.value,
|
||||
latitude: uni.getStorageSync('latitude'),
|
||||
longitude: uni.getStorageSync('longitude')
|
||||
const res = await getTeaRoomPackageDetail({
|
||||
id: comboId.value
|
||||
})
|
||||
order.value = res
|
||||
money.value = Number(res.details.order_amount)
|
||||
console.log("🚀 ~ res:", res)
|
||||
money.value = Number(res.details.discount_price)
|
||||
},
|
||||
|
||||
// 获取支付方式
|
||||
@ -224,50 +234,78 @@
|
||||
* 支付
|
||||
*/
|
||||
handleToPay: async () => {
|
||||
if (isSubmitting.value) return
|
||||
|
||||
if (pay.value == null || pay.value == undefined) {
|
||||
toast.info('请选择支付方式')
|
||||
return
|
||||
}
|
||||
|
||||
isSubmitting.value = true
|
||||
|
||||
if (from.value == OrderType.TeaRoomOrder) {
|
||||
// 预支付-茶室订单
|
||||
uni.showLoading({ title: '支付中...' })
|
||||
try {
|
||||
// 预支付
|
||||
let ordeType = 1
|
||||
let ordeType = PayOrderType.TeaRoom
|
||||
if (isGroupBuying.value) {
|
||||
ordeType = 2
|
||||
// 购买团购套餐
|
||||
ordeType = PayOrderType.BuyCombo
|
||||
}
|
||||
|
||||
const res1 = await prePay({
|
||||
const res = await prePay({
|
||||
from: PayValueMap[pay.value],
|
||||
order_id: orderId.value,
|
||||
pay_way: pay.value,
|
||||
order_source: 1, //订单来源:1-小程序; 2-h5; 3app
|
||||
order_source: PayOrderSource.MINI, //订单来源:1-小程序; 2-h5; 3app
|
||||
order_type: ordeType // 0为茶艺师 1为茶室包间 2为茶室套餐
|
||||
})
|
||||
|
||||
// 余额支付(平台余额、门店余额)
|
||||
if (pay.value == PayValue.PlatformBalance || pay.value == PayValue.StoreBalance) {
|
||||
await balancePay({
|
||||
id: res1.pay
|
||||
id: res.pay
|
||||
})
|
||||
|
||||
uni.hideLoading()
|
||||
result.value = 'success'
|
||||
|
||||
isSubmitting.value = false
|
||||
router.navigateBack(1, 500)
|
||||
} else if (pay.value == PayValue.WeChatPay) {
|
||||
// 微信支付
|
||||
// await wxpay(res1.pay_params)
|
||||
// wxPay()
|
||||
wechatPay(res.pay.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(() => {
|
||||
uni.hideLoading()
|
||||
toast.info('支付失败,请重试')
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
uni.hideLoading()
|
||||
result.value = 'success'
|
||||
} catch (error) {
|
||||
isSubmitting.value = false
|
||||
uni.hideLoading()
|
||||
result.value = 'fail'
|
||||
router.navigateBack(1, 500)
|
||||
return
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({delta: 1})
|
||||
}, 500);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user