完善茶室订单

This commit is contained in:
wangxiaowei
2025-11-20 17:29:26 +08:00
parent 0cad65c295
commit 3a8488dc18
29 changed files with 1812 additions and 765 deletions

View File

@ -0,0 +1,223 @@
<route lang="jsonc" type="page">
{
"needLogin": true,
"layout": "default",
"style": {
"navigationStyle": "custom"
}
}
</route>
<template>
<view>
<view>
<navbar title="收银台" custom-class='!bg-[#F6F7F8]' :leftArrow="false"></navbar>
</view>
<!-- 支付信息 -->
<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>
</view>
<view class="mt-12rpx flex items-center justify-center">
<view class="text-24rpx leading-34rpx text-#606266">
支付剩余时间
</view>
<wd-count-down :time="time" custom-class="!text-[#606266] !text-24rpx !leading-34rpx" />
</view>
</view>
<!-- 支付方式 -->
<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>
</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"
@click="Cashier.handleToPay">立即支付
</view>
</view>
</template>
<script lang="ts" setup>
import Pay from '@/components/Pay.vue'
import { getTeaSpecialistDetails, getTeaSpecialistOrderDetails, teaSpecialistPrepay, teaSpecialistPay } 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 { useUserStore } from '@/store'
import type {IUserInfoVo } from '@/api/types/login'
import { getTeaRoomBalance, getTeaRoomOrderDetail } from '@/api/tea-room'
import { OrderType } from '@/utils/order'
// 用户信息
const userInfo = ref<IUserInfoVo>(null)
// 支付倒计时取消
const time = ref<number>(30 * 60 * 60 * 1000)
// 支付金额
const money = ref<number>(0)
// 茶艺师详情
const id = ref<number>(0)
const info = reactive<ITeaSpecialistDetailsFields>({
id: 0,
name: '',
star: 0,
image: '',
reservation_num: 0,
distance: 0,
speed: 0,
real: { gender: 1, both: 18, height: 165, weight: 53, interests: '爱好茶艺,喜欢旅游,把爱好当工作' },
teamasterlabel: [],
teamasterLevel: [],
price: 0,
fare_price: 0,
collect: 0,
up_status: 0,
textarea: []
})
// 支付方式
const pay = ref<number>(0)
// 订单
const orderId = ref<number>(0)
const order = ref<{}>(null)
const result = ref<string>('')
const from = ref<string>('')
// 支付标题
const title = ref<string>('')
// 门店ID
const storeId = ref<number>(0)
const storeMoney = ref<number>(0)
onLoad(async (args) => {
// 获取门店余额
if (args.storeId) {
storeId.value = Number(args.storeId)
const balance = await getTeaRoomBalance({ store_id: storeId.value })
storeMoney.value = Number(balance.data.money) || 0
}
// 设置支付来源标题
from.value = args.from || ''
if (from.value === OrderType.TeaRoomOrder) {
if (args.teaRoomName) {
title.value = `茶室预定-${args.teaRoomName}`
} else {
title.value = '茶室预定支付'
}
}
// 用户信息
const userStore = useUserStore()
userInfo.value = userStore.userInfo
// 获取订单详情
if (args.from == OrderType.TeaRoomOrder && args.orderId) {
// 获取订单详情
orderId.value = Number(args.orderId)
Cashier.handleGetOrderDetails()
}
console.log('页面加载')
})
onUnload(() => {
switch(result.value) {
case 'success':
uni.$emit('payment', { result: true, orderId: orderId.value })
break;
case 'fail':
default: uni.$emit('payment', { result: false, orderId: orderId.value })
}
})
const Cashier = {
// 获取茶艺师详情
handleGetTeaSpecialistDetails: async (id: number, user_id: number) => {
const res = await getTeaSpecialistDetails({
id,
latitude: uni.getStorageSync('latitude'),
longitude: uni.getStorageSync('longitude'),
user_id
})
// 将返回的数据合并到 reactive 对象中
Object.assign(info, res.teamaster || {})
},
// 获取订单详情
handleGetOrderDetails: async () => {
// 获取订单详情接口
const res = await getTeaRoomOrderDetail({
id: orderId.value,
latitude: uni.getStorageSync('latitude'),
longitude: uni.getStorageSync('longitude')
})
order.value = res
console.log("🚀 ~ order.value:", order.value)
money.value = Number(res.details.amount_price)
},
// 获取支付方式
handleGetPayValue: (value: number) => {
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') {
try {
// 预支付
const res1 = await teaSpecialistPrepay({
order_id: orderId.value,
from: 'balance',
pay_way: pay.value,
order_source: 2 //订单来源1-小程序;2-h5;3app
})
// 支付
const res2 = await teaSpecialistPay({
id: res1.pay_id
})
result.value = 'success'
} catch (error) {
result.value = 'fail'
}
setTimeout(() => {
uni.navigateBack({delta: 1})
}, 500);
}
}
}
</script>
<style lang="scss" scoped>
page {
background-color: $cz-page-background;
}
</style>

View File

@ -31,8 +31,7 @@
<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"
@click="Index.handleClick" mode="aspectFit"></wd-swiper>
:indicator="{ type: 'dots-bar' }" :list="swiperList" v-model:current="current" mode="aspectFit"></wd-swiper>
</view>
<view class="mt-40rpx flex items-center h-36rpx mx-30rpx">
@ -113,7 +112,7 @@
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
import { LOCATION_DENY_TIME_KEY, handleEnsureLocationAuthHooks } from '@/hooks/useLocation'
import { getHomeBannerList } from '@/api/home'
import { getHomeTeaRoomList } from '@/api/tea-room'
import { getHomeTeaStoreList } from '@/api/tea-room'
import { useUserStore } from '@/store'
const OSS = inject('OSS')
@ -162,7 +161,10 @@
})
const Index = {
// 上拉加载的回调: 其中num:当前页 从1开始, size:每页数据条数,默认10
/**
* 茶室门店列表
* @param mescroll
*/
upCallback: (mescroll) => {
const userStore = useUserStore()
const userId = userStore.userInfo?.id || 0
@ -176,7 +178,7 @@
user_id: userId
}
getHomeTeaRoomList(filter).then( res => {
getHomeTeaStoreList(filter).then( res => {
console.log("🚀 ~ res:", res)
const curPageData = res.list || [] // 当前页数据
if(mescroll.num == 1) list.value = [] // 第一页需手动制空列表
@ -187,18 +189,25 @@
})
},
/**
* 初始化首页数据
*/
handleInit: () => {
// 初始化操作
getHomeBannerList().then(res => {
swiperList.value = res.list.map(item => item.address)
})
},
/**
* 跳转城市选择
*/
handleToCity: () => {
router.navigateTo(`/pages/city/city?lat=${latitude.value}&lng=${longitude.value}`)
},
// 跳转茶室搜索
/**
* 跳转茶室搜索
*/
handleToSearch: () => {
uni.$on('refreshTeaRoomList', params => {
keywords.value = params.keywords
@ -209,18 +218,18 @@
router.navigateTo(`/pages/search/search?keywords=${keywords.value}`)
},
handleClick: (item: any) => {
// 处理点击事件
console.log('Clicked item:', item)
},
/**
* 跳转到预约茶室页面
*/
handleToReserveRoom: (id: number = 0) => {
// 跳转到预约茶室页面
uni.navigateTo({
url: `/bundle/tea-room/room?id=${id}`
})
},
/**
* 重置搜索
*/
handleResetSearch: () => {
list.value = []
getMescroll().resetUpScroll()

View File

@ -27,7 +27,7 @@
</view>
<view class="flex-1 ml-22rpx flex justify-between items-center">
<view @click="My.handleToProfile">
<view class="text-[#303133] text-36rpx leading-50rpx ml-8rpx">{{ isLogin ? '王大帅' : '立即登录' }}</view>
<view class="text-[#303133] text-36rpx leading-50rpx ml-8rpx">{{ isLogin ? userInfo.nickname : '立即登录' }}</view>
<view v-if="isLogin" class="flex justify-center items-center vip-bg mt-10rpx">
<!-- 会员显示图标 -->
<view v-if="isVip" class="flex items-center mr-12rpx">
@ -52,21 +52,21 @@
<!-- 余额显示 -->
<view class="mt-16rpx mx-30rpx flex justify-between">
<view class="flex items-center">
<view class="w-160rpx text-[#303133] text-center" @click="My.handleToCoupon">
<view class="font-bold text-36rpx leading-50rpx"> {{ isLogin ? 51 : '- -' }}</view>
<view class="w-160rpx text-[#303133] text-center" @click="router.navigateTo('/bundle/coupon/my-coupon')">
<view class="font-bold text-36rpx leading-50rpx"> {{ isLogin ? user?.coupon_count : '- -' }}</view>
<view class="text-24rpx leading-34rpx">优惠券</view>
</view>
<view class="w-160rpx text-[#303133] text-center" @click="My.handleToCollect">
<view class="font-bold text-36rpx leading-50rpx"> {{ isLogin ? 51 : '- -' }}</view>
<view class="w-160rpx text-[#303133] text-center" @click="router.navigateTo('/bundle/collect/collect')">
<view class="font-bold text-36rpx leading-50rpx"> {{ isLogin ? user?.collect_count : '- -' }}</view>
<view class="text-24rpx leading-34rpx">收藏</view>
</view>
</view>
<view class="relative" @click="My.handleToWallet">
<view class="relative" @click="router.navigateTo('/bundle/wallet/wallet')">
<view class="w-300rpx h-148rpx">
<wd-img width="100%" height="100%" :src="`${OSS}images/my/my_image3.png`" mode="aspectFill"></wd-img>
</view>
<view class="text-[#303133] absolute bottom-12rpx left-24rpx text-center">
<view class="text-30rpx leading-36rpx fon-bold">{{ isLogin ? '¥2106.3623' : '- -' }}</view>
<view class="text-30rpx leading-36rpx font-bold">{{ isLogin ? user?.user_money : '- -' }}</view>
<view class="text-20rpx leading-28rpx ml-10rpx">平台余额</view>
</view>
</view>
@ -82,7 +82,7 @@
<view class="w-40rpx h-36rpx flex items-center">
<wd-img width="100%" height="100%" :src="`${OSS}icon/icon_vip.png`" mode="aspectFill"></wd-img>
</view>
<view class="flex items-center leading-34rpx" @click="My.handleToVipBenefits">
<view class="flex items-center leading-34rpx" @click="router.navigateTo('/bundle/vip/benefits')">
<view class="font-400 text-24rpx ml-12rpx mr-20rpx text-[#EECC99]">{{ isLogin ? '会员到期时间' : '- -' }}</view>
<view class="flex items-center mt-4rpx">
<wd-icon name="arrow-right" size="24rpx" color="#EECC99"></wd-icon>
@ -104,16 +104,16 @@
</view>
<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 10" :key="index">
<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">茶室券</view>
<view class="font-bold text-[#1C1C1D] leading-34rpx mt-8rpx">
<text class="text-24rpx">¥</text>
<text class="text-30rpx">20</text>
<text class="text-30rpx">{{ item.coupon_price }}</text>
</view>
<view class="font-400 text-20rpx leading-28rpx text-[#1C1C1D]">满200可用</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="isClaimCoupon ? 'bg-[#E6E3DF]' : 'bg-[#FCCA84]'" @click="isClaimCoupon = true">
{{ isClaimCoupon ? '已领取' : '立即领取' }}
:class="item.use == 1 ? 'bg-[#E6E3DF]' : 'bg-[#FCCA84]'" @click="My.handleClaimCoupon(item.id)">
{{ item.use == 1 ? '已领取' : '立即领取' }}
</view>
</view>
</scroll-view>
@ -134,7 +134,7 @@
<!-- 团购 -->
<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="My.handleToDouYinGroupBuying">
<view class="flex items-center" @click="router.navigateTo('/bundle/order/douyin/order-list')">
<view class="w-40rpx h-40rpx ">
<wd-img width="100%" height="100%" :src="`${OSS}icon/icon_douyin.png`"></wd-img>
</view>
@ -146,7 +146,7 @@
<view>
<wd-divider vertical />
</view>
<view class="flex items-center" @click="My.handleToPlatformGroupBuying">
<view class="flex items-center" @click="router.navigateTo('/bundle/order/platform/order-list')">
<view class="w-40rpx h-40rpx ">
<wd-img width="100%" height="100%" :src="`${OSS}icon/icon_platform.png`"></wd-img>
</view>
@ -244,6 +244,7 @@
import { toast } from '@/utils/toast'
import { router } from '@/utils/tools'
import { useUserStore } from '@/store'
import { getUserInfo, getMyCoupon, claimMyCoupon } from '@/api/user'
const OSS = inject('OSS')
const navbarHeight = inject('navbarHeight')
@ -251,6 +252,7 @@
// 登录信息相关
const userInfo = ref<any>(null)
const user = ref<any>(null)
const isLogin = ref<boolean>(false)
const isVip = ref<boolean>(true)
@ -286,22 +288,45 @@
const sheetMenu = ref<{ name: string}[]>([])
// 领取优惠券
const isClaimCoupon = ref<boolean>(false)
const couponList = ref<any[]>([])
onShow(() => {
const userStore = useUserStore()
isLogin.value = userStore.isLoggedIn
console.log("🚀 ~ isLogin.value:", isLogin.value)
if (isLogin.value) {
userInfo.value = userStore.userInfo
// 获取用户详情信息接口
getUserInfo().then(res => {
user.value = res
})
} else {
userInfo.value = null
user.value = null
}
})
onLoad(() => {
My.handleInit()
})
const My = {
// 跳转抖音团购
handleToDouYinGroupBuying: () => {
router.navigateTo('/bundle/order/douyin/order-list')
/**
* 初始化
*/
handleInit: () => {
getMyCoupon().then(res => {
couponList.value = Array.isArray(res) ? res : []
})
},
/**
* 领取优惠券
*/
handleClaimCoupon: async (id: number) => {
await claimMyCoupon({id})
toast.info('领取成功')
My.handleInit()
},
// 跳转到个人信息
@ -313,11 +338,6 @@
}
},
// 跳转平台团购
handleToPlatformGroupBuying: () => {
router.navigateTo('/bundle/order/platform/order-list')
},
// 点击显示客服电话
handleShowService: () => {
showServiceMobile.value = true
@ -341,46 +361,6 @@
toast.info('请先登录')
router.navigateTo('/pages/login/login', 800)
}
},
// 跳转到会员权益
handleToVipBenefits: () => {
if (isLogin.value) {
router.navigateTo('/bundle/vip/my-benefits')
} else {
toast.info('请先登录')
router.navigateTo('/pages/login/login', 800)
}
},
// 跳转到优惠券
handleToCoupon: () => {
if (isLogin.value) {
router.navigateTo('/bundle/coupon/my-coupon')
} else {
toast.info('请先登录')
router.navigateTo('/pages/login/login', 800)
}
},
// 跳转到收藏
handleToCollect: () => {
if (isLogin.value) {
router.navigateTo('/bundle/collect/collect')
} else {
toast.info('请先登录')
router.navigateTo('/pages/login/login', 800)
}
},
// 跳转到我的钱包
handleToWallet: () => {
if (isLogin.value) {
router.navigateTo('/bundle/wallet/wallet')
} else {
toast.info('请先登录')
router.navigateTo('/pages/login/login', 800)
}
}
}
</script>