调试接口
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,8 +51,8 @@
|
||||
const redirectUrl = ref<string>('')
|
||||
|
||||
onLoad((args) => {
|
||||
console.log("🚀 ~ login args:", args)
|
||||
redirectUrl.value = args.redirect || ''
|
||||
|
||||
})
|
||||
|
||||
const Login = {
|
||||
@ -72,12 +72,13 @@
|
||||
const res = await userStore.wxLogin()
|
||||
uni.hideLoading()
|
||||
if (res) {
|
||||
toast.info('登录成功')
|
||||
if (redirectUrl.value) {
|
||||
router.redirectTo(redirectUrl.value)
|
||||
} else {
|
||||
router.navigateBack(1, 500)
|
||||
const decoded = decodeURIComponent(redirectUrl.value)
|
||||
if (decoded == '/bundle/order/tea-room/order-detail') {
|
||||
uni.$emit('transferOrder')
|
||||
}
|
||||
|
||||
toast.info('登录成功')
|
||||
router.navigateBack(1, 500)
|
||||
}
|
||||
} catch(error) {
|
||||
uni.hideLoading()
|
||||
|
||||
@ -176,7 +176,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 茶艺师订单 -->
|
||||
<view class="bg-white rounded-16rpx mx-30rpx mt-28rpx pb-34rpx">
|
||||
<!-- <view class="bg-white rounded-16rpx mx-30rpx mt-28rpx pb-34rpx">
|
||||
<view class="px-30rpx pt-30rpx py-24rpx">茶艺师订单</view>
|
||||
<view class="flex relative px-30rpx">
|
||||
<view v-for="(item, index) in teaReserveMenuList" :key="index">
|
||||
@ -190,10 +190,10 @@
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- 更多服务 -->
|
||||
<view class="bg-white rounded-16rpx mx-30rpx mt-28rpx pb-34rpx">
|
||||
<!-- <view class="bg-white rounded-16rpx mx-30rpx mt-28rpx pb-34rpx">
|
||||
<view class="px-30rpx pt-30rpx py-24rpx">更多服务</view>
|
||||
<view class="flex px-30rpx">
|
||||
<view v-for="(item, index) in serviceMenuList" :key="index">
|
||||
@ -210,7 +210,7 @@
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<!-- 推广码 -->
|
||||
@ -322,8 +322,6 @@
|
||||
user.value = res
|
||||
if (res.member === 1) {
|
||||
isVip.value = true
|
||||
} else {
|
||||
isVip.value = false
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@ -334,6 +332,8 @@
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
isVip.value = false
|
||||
|
||||
uni.$on('clearUser', () => {
|
||||
const userStore = useUserStore()
|
||||
isLogin.value = userStore.isLoggedIn
|
||||
|
||||
@ -6,18 +6,28 @@
|
||||
}</route>
|
||||
|
||||
<template>
|
||||
<view class="mt-84rpx flex justify-center items-center">
|
||||
<view v-if="type == OrderType.TeaRoomOrder">
|
||||
<reserve-notice :title="isGroupBuying ? '套餐购买成功' : '茶室预约成功'" desc="可以点击下方查看订单详情">
|
||||
<template #layout>
|
||||
<view class="pb-22rpx mt-40rpx mx-30rpx flex justify-between items-center text-[32rpx] text-center">
|
||||
<view class='bg-[#F6F7F8] text-[#303133] rounded-8rpx h-90rpx leading-90rpx mr-28rpx w-300rpx' @click="reserve.handleRoomSeeOrder">查看订单</view>
|
||||
<view class='bg-[#4C9F44] text-[#fff] rounded-8rpx h-90rpx leading-90rpx w-300rpx' @click="reserve.handleRoomDone">完成</view>
|
||||
</view>
|
||||
</template>
|
||||
</reserve-notice>
|
||||
<view class="">
|
||||
<view class="">
|
||||
<wd-navbar safeAreaInsetTop custom-class='!bg-[#fff]' :bordered="false" placeholder>
|
||||
<template #left>
|
||||
<view></view>
|
||||
</template>
|
||||
</wd-navbar>
|
||||
</view>
|
||||
<view class="mt-84rpx flex justify-center items-center">
|
||||
<view v-if="type == OrderType.TeaRoomOrder">
|
||||
<reserve-notice :title="isGroupBuying ? '套餐购买成功' : '茶室预约成功'" desc="可以点击下方查看订单详情">
|
||||
<template #layout>
|
||||
<view class="pb-22rpx mt-40rpx mx-30rpx flex justify-between items-center text-[32rpx] text-center">
|
||||
<view class='bg-[#F6F7F8] text-[#303133] rounded-8rpx h-90rpx leading-90rpx mr-28rpx w-300rpx' @click="reserve.handleRoomSeeOrder">查看订单</view>
|
||||
<view class='bg-[#4C9F44] text-[#fff] rounded-8rpx h-90rpx leading-90rpx w-300rpx' @click="reserve.handleRoomDone">完成</view>
|
||||
</view>
|
||||
</template>
|
||||
</reserve-notice>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
"layout": "tabbar",
|
||||
"style": {
|
||||
// 'custom' 表示开启自定义导航栏,默认 'default'
|
||||
"needLogin": true,
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "首页"
|
||||
}
|
||||
@ -45,30 +46,6 @@
|
||||
</template>
|
||||
</mescroll-body>
|
||||
</view>
|
||||
|
||||
<!-- <view class="mx-30rpx" :style="{ paddingTop: navbarHeight + 'px' }"> -->
|
||||
<!-- 茶室预约 -->
|
||||
<!-- <view v-if="tab === 0">
|
||||
<mescroll-body @init="mescrollInit" @down="downCallback" @up="Reserve.upCallback" :up="upOption">
|
||||
<view v-for="(item, index) in 5" :key="index" >
|
||||
<view class="mb-20rpx" @click="Reserve.handleToReserveRoomOrder">
|
||||
<combo-card :type="OrderSource.TeaRoom" :order-status="OrderStatus.Consuming"></combo-card>
|
||||
</view>
|
||||
</view>
|
||||
</mescroll-body>
|
||||
</view> -->
|
||||
|
||||
<!-- 茶艺师预约 -->
|
||||
<!-- <view v-if="tab === 1">
|
||||
<mescroll-body @init="mescrollInit" @down="downCallback" @up="Reserve.upCallback" :up="upOption">
|
||||
<view v-for="(item, index) in 5" :key="index" >
|
||||
<view class="mb-20rpx" @click="Reserve.handleToTeaSpecialistOrder">
|
||||
<combo-card :type="OrderSource.TeaSpecialist" :order-status="OrderStatus.Consuming"></combo-card>
|
||||
</view>
|
||||
</view>
|
||||
</mescroll-body>
|
||||
</view> -->
|
||||
<!-- </view> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -104,6 +81,15 @@
|
||||
const orderStatus = ref<string>('')
|
||||
const list = ref<Array<any>>([]) // 茶室列表
|
||||
const keywords = ref<string>('') // 搜索关键词
|
||||
const canReset = ref<boolean>(false) // 避免onShow重复加载
|
||||
|
||||
onShow(() => {
|
||||
if (canReset.value) {
|
||||
list.value = []
|
||||
getMescroll().resetUpScroll();
|
||||
}
|
||||
canReset.value = true
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user