完善茶艺师接口对接

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
}
}
},

View File

@ -10,6 +10,31 @@
<template>
<view class="home-bg">
<!-- 领取优惠券 -->
<wd-overlay :show="showCoupon" @click="showCoupon = false">
<view class="flex flex-col justify-center items-center h-100%">
<view class="w-652rpx h-590rpx relative" >
<wd-img :src="`${OSS}images/home/home_image8.png`" width="100%" height="100%"></wd-img>
<view class="absolute top-82rpx left-1/2 transform -translate-x-1/2 flex flex-col items-center">
<view class="font-bold text-30rpx leading-42rpx text-[#E64545]">正在发送一波优惠券</view>
<view class="font-bold text-[#313131] text-36rpx leading-50rpx mt-38rpx">你有待领取的优惠券</view>
<view class="mt-220rpx " @click.stop="showCoupon = false">
<view class="h-90rpx relative">
<wd-img :src="`${OSS}images/home/home_image9.png`" width="342rpx" height="90rpx"></wd-img>
<view class="absolute top-20rpx left-1/2 transform -translate-x-1/2 flex flex-col items-center" @click.stop="Index.handleToGetCoupon">立即领取</view>
</view>
</view>
</view>
</view>
<view class="mt-80rpx" @click.stop="showCoupon = false">
<wd-img :src="`${OSS}icon/icon_close2.png`" width="72rpx" height="72rpx"></wd-img>
</view>
</view>
</wd-overlay>
<view class="home-bg w-[100%] fixed top-0 left-0 z-100">
<wd-navbar safeAreaInsetTop :bordered="false" custom-style="background-color: transparent !important;">
<template #left>
@ -30,7 +55,14 @@
<view :style="{ paddingTop: navbarHeight + 'px' }">
<view class="mt-32rpx mx-30rpx">
<wd-swiper height="240rpx" indicatorPosition="bottom-left" :indicator="{ type: 'dots-bar' }" :list="swiperList" v-model:current="current" mode="aspectFit"></wd-swiper>
<wd-swiper
height="240rpx"
indicatorPosition="bottom-left"
:indicator="{ type: 'dots-bar' }"
:list="swiperList"
v-model:current="current"
mode="aspectFit"
@click="Index.handleBanner"></wd-swiper>
</view>
<view class="mt-40rpx flex items-center h-36rpx mx-30rpx">
@ -114,14 +146,14 @@
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
import { LOCATION_DENY_TIME_KEY, handleEnsureLocationAuthHooks, LOCATION_DEFAULT_CITY, handleGetLocationCity, LOCATION_CITY_KEY, handleForceGetLocation } from '@/hooks/useLocation'
import { getHomeBannerList } from '@/api/home'
import { getHomeBannerList, getHomeCouponPopup } from '@/api/home'
import { getHomeTeaStoreList } from '@/api/tea-room'
import { useUserStore } from '@/store'
const OSS = inject('OSS')
const navbarHeight = inject('navbarHeight')
/** 轮播图 **/
// 轮播图
const swiperList = ref<string[]>([])
const current = ref<number>(0)
@ -143,6 +175,10 @@
let lastLocation = { lat: 0, lng: 0 }
const canLocation = ref<boolean>(false)
// 显示优惠券弹窗
const showCoupon = ref<boolean>(false)
onShow(async () => {
// if (canLocation) {
// const location = await handleGetLocationCity(latitude.value, longitude.value)
@ -166,6 +202,16 @@
}
}
}
const userStore = useUserStore()
const userId = userStore.userInfo?.id
if (userId) {
// 获取首页优惠券弹窗
const res = await getHomeCouponPopup()
if (Number(res.status) === 0) {
showCoupon.value = true
}
}
})
onLoad(async() => {
@ -299,6 +345,46 @@
longitude.value = params.longitude
Index.handleResetSearch()
}
},
/**
* 跳转领取优惠券页面
*/
handleToGetCoupon: () => {
showCoupon.value = false
router.switchTab('/pages/my/my')
},
/**
* 轮播图跳转
*/
handleBanner: (e: any) => {
switch(e.index){
case 0:
// 跳转到茶艺师入驻
router.navigateTo('/bundle/settle-in/tea-specialist')
break;
case 1:
// 跳转到茶馆入驻
router.navigateTo('/bundle/settle-in/tea-room')
break;
case 2:
// 跳转到茶艺师列表
router.navigateTo('/bundle_b/pages/tea-specialist/list')
break;
case 3:
// 跳转到充值会员
router.navigateTo('/bundle/vip/benefits')
break;
}
// if (e.index == 2) {
// // 跳转到茶艺师列表
// router.navigateTo(`/bundle_b/pages/tea-specialist/list`)
// }
console.log("🚀 ~ e:", e)
// const index = e.currentTarget.dataset.index
}
}
</script>

View File

@ -103,7 +103,7 @@
</view>
<!-- <view class="font-400 text-24rpx text-[#D2D0D0] leading-34rpx">请尽快领取会员权益</view> -->
</view>
<view class="mt-50rpx ml-24rpx">
<!-- <view class="mt-50rpx ml-24rpx">
<scroll-view class="w-[100%] whitespace-nowrap" :scroll-x="true" scroll-left="120">
<view class="scroll-item mr-20rpx" v-for="(item, index) in couponList" :key="index">
<view class="font-bold text-22rpx text-[#AF6400] leading-32rpx mt-6rpx">{{ item.type_id == 1 ? '茶艺师券' : '茶室券' }}</view>
@ -118,7 +118,7 @@
</view>
</view>
</scroll-view>
</view>
</view> -->
</view>
<!-- 非会员下的状态 -->
@ -133,6 +133,24 @@
</view>
</view>
<!-- 优惠券 -->
<view class="bg-white rounded-16rpx mx-30rpx mt-28rpx px-30rpx py-20rpx flex items-center justify-between" v-if="isLogin && couponList.length > 0">
<scroll-view class="w-[100%] whitespace-nowrap" :scroll-x="true" scroll-left="120">
<view class="scroll-item mr-20rpx" v-for="(item, index) in couponList" :key="index">
<view class="font-bold text-22rpx text-[#AF6400] leading-32rpx mt-6rpx">{{ item.type_id == 1 ? '茶艺师券' : '茶室券' }}</view>
<view class="font-bold text-[#1C1C1D] leading-34rpx mt-8rpx">
<text class="text-24rpx">¥</text>
<text class="text-30rpx">{{ item.coupon_price }}</text>
</view>
<view class="font-400 text-20rpx leading-28rpx text-[#1C1C1D]">{{ item.name }}</view>
<view class="font-400 text-20rpx w-126rpx h-40rpx rounded-20rpx mt-18rpx leading-40rpx mx-auto"
:class="item.use == 1 ? 'bg-[#E6E3DF]' : 'bg-[#FCCA84]'" @click="My.handleClaimCoupon(item.id, item.type_id)">
{{ item.use == 1 ? '已领取' : '立即领取' }}
</view>
</view>
</scroll-view>
</view>
<!-- 团购 -->
<view class="bg-white rounded-16rpx mx-30rpx mt-28rpx px-56rpx py-48rpx flex items-center justify-between">
<view class="flex items-center" @click="router.navigateTo('/bundle/order/douyin/order-list')">
@ -174,7 +192,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">
@ -186,7 +204,7 @@
</view>
</view>
</view>
</view> -->
</view>
<!-- 更多服务 -->
<view class="bg-white rounded-16rpx mx-30rpx mt-28rpx pb-34rpx">
@ -237,7 +255,8 @@
</template>
<script lang="ts" setup>
import { TeaRoomOrderStatusText, TeaSpecialistOrderStatusText } from '@/utils/order'
import { TeaRoomOrderStatusText } from '@/utils/order'
import { TeaSpecialistManageOrderStatusText } from '@/utils/teaSpecialistOrder'
import { toast } from '@/utils/toast'
import { router } from '@/utils/tools'
import { useUserStore } from '@/store'
@ -282,11 +301,11 @@
// 茶艺师订单
const teaReserveMenuList = reactive([
{ id: 1, title: '全部订单', icon: `${OSS}icon/icon_tea_all_order.png`, badge: '', status: TeaSpecialistOrderStatusText.All },
{ id: 2, title: '待付款', icon: `${OSS}icon/icon_tea_wait_pay_order.png`, badge: '', status: TeaSpecialistOrderStatusText.Pending },
{ id: 3, title: '预约单', icon: `${OSS}icon/icon_tea_reserve_order.png`, badge: '', status: TeaSpecialistOrderStatusText.Pay },
{ id: 4, title: '待确认', icon: `${OSS}icon/icon_tea_wait_confirm_order.png`, badge: '', status: TeaSpecialistOrderStatusText.Confirm },
{ id: 4, title: '已完', icon: `${OSS}icon/icon_tea_finish_order.png`, badge: '', status: TeaSpecialistOrderStatusText.Finished },
{ id: 1, title: '全部订单', icon: `${OSS}icon/icon_tea_all_order.png`, badge: '', status: TeaSpecialistManageOrderStatusText.All },
{ id: 2, title: '待付款', icon: `${OSS}icon/icon_tea_wait_pay_order.png`, badge: '', status: TeaSpecialistManageOrderStatusText.Unpaid },
{ id: 3, title: '预约单', icon: `${OSS}icon/icon_tea_reserve_order.png`, badge: '', status: TeaSpecialistManageOrderStatusText.Reserved },
{ id: 4, title: '服务中', icon: `${OSS}icon/icon_tea_wait_confirm_order.png`, badge: '', status: TeaSpecialistManageOrderStatusText.Service },
{ id: 5, title: '已完', icon: `${OSS}icon/icon_tea_wait_confirm_order.png`, badge: '', status: TeaSpecialistManageOrderStatusText.Completed },
])
// 更多服务
@ -321,6 +340,8 @@
isVip.value = true
}
})
My.handleInit()
} else {
Object.keys(user.value).forEach(key => {
user.value[key] = ''
@ -368,13 +389,17 @@
/**
* 领取优惠券
*/
handleClaimCoupon: async (id: number) => {
handleClaimCoupon: async (id: number, type_id: number) => {
await claimMyCoupon({id})
toast.info('领取成功')
My.handleInit()
getUserInfo().then(res => {
user.value = res
})
if (type_id == 1) {
router.navigateTo('/bundle_b/pages/tea-specialist/list')
}
},
// 跳转到个人信息

View File

@ -25,6 +25,16 @@
</template>
</reserve-notice>
</view>
<view v-if="type == OrderType.TeaSpecialist">
<reserve-notice title="茶艺师预约成功" 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.handleSeeTeaSpecialistOrder">查看订单</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>
@ -67,6 +77,13 @@
router.navigateTo('/bundle/order/tea-room/order-list')
}
},
/**
* 预约茶艺师 - 查看订单
*/
handleSeeTeaSpecialistOrder: () => {
router.navigateTo('/bundle/order/tea-specialist/order-list')
},
/**
* 预约茶室 - 完成

View File

@ -15,7 +15,7 @@
<wd-navbar safeAreaInsetTop :bordered="false" custom-style="background-color: transparent !important;">
<template #left>
<view class="search-box flex items-center ml-26rpx">
<wd-search v-model="keywords" placeholder="请输入内容" hide-cancel disabled placeholder-left
<wd-search v-model="keywords" placeholder="请输入内容" hide-cancel placeholder-left
@search="Reserve.handleSearch()"
placeholderStyle="text-align:left;padding-left: 24rpx;line-heigt: 44rpx;color: #C9C9C9; font-size: 32rpx;font-weight: normal;">
</wd-search>
@ -26,7 +26,7 @@
<view class="tabs">
<wd-tabs v-model="tab" swipeable slidable="always" @change="Reserve.handleChangeTab" :lazy="false">
<wd-tab title="茶室预约"></wd-tab>
<!-- <wd-tab title="茶艺师预约"></wd-tab> -->
<wd-tab title="茶艺师预约"></wd-tab>
</wd-tabs>
</view>
</view>
@ -143,6 +143,7 @@
tab.value = item.index
// 切换tab时,重置当前的mescroll
keywords.value = ''
list.value = []
getMescroll().resetUpScroll();
},