添加收藏茶室接口和完善茶室详情
This commit is contained in:
97
src/hooks/useTeaSpecialistOrder.ts
Normal file
97
src/hooks/useTeaSpecialistOrder.ts
Normal file
@ -0,0 +1,97 @@
|
||||
import { router } from '@/utils/tools'
|
||||
import { toast } from '@/utils/toast'
|
||||
import { cancelTeaSpecialistOrder, deleteTeaSpecialistOrder, confirmTeaSpecialistOrder, refundTeaSpecialistOrder } from '@/api/teaSpecialist-order'
|
||||
|
||||
/**
|
||||
* 取消订单
|
||||
* @param orderId 订单ID
|
||||
*/
|
||||
export async function handleCancelOrderHooks(orderId: number) {
|
||||
try {
|
||||
const response = await cancelTeaSpecialistOrder({ id: orderId })
|
||||
uni.$emit('refreshOrderList')
|
||||
uni.$emit('refreshOrderDetail')
|
||||
} catch (error) {
|
||||
router.navigateBack()
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新支付
|
||||
* @param orderId 订单ID
|
||||
* @param teaSpecialistId 茶艺师ID
|
||||
* @returns
|
||||
*/
|
||||
export function handleToPayHooks(orderId: number, teaSpecialistId: number) {
|
||||
try {
|
||||
uni.$on('payment', params => {
|
||||
console.log("🚀 ~ params:", params)
|
||||
setTimeout(() => {
|
||||
uni.$off("payment")
|
||||
uni.$emit('refreshOrderList')
|
||||
uni.$emit('refreshOrderDetail')
|
||||
if (params.result) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/notice/reserve?type=teaSpecialist&orderId=${params.orderId}`
|
||||
})
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: '/bundle/order/tea-specialist/order-list'
|
||||
})
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
router.navigateTo(`/pages/cashier/cashier?from=order&orderId=${orderId}&teaSpecialistId=${teaSpecialistId}`)
|
||||
}, 800)
|
||||
} catch (error) {
|
||||
toast.info('订单提交失败,请稍后重试')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
*/
|
||||
export async function handleDeleteOrderHooks(orderId: number) {
|
||||
try {
|
||||
const response = await deleteTeaSpecialistOrder({ id: orderId })
|
||||
uni.$emit('refreshOrderList')
|
||||
uni.$emit('refreshOrderDetail')
|
||||
} catch (error) {
|
||||
router.navigateBack()
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认(完成)订单
|
||||
*/
|
||||
export async function handleConfirmOrderHooks(orderId: number) {
|
||||
try {
|
||||
const response = await confirmTeaSpecialistOrder({ id: orderId })
|
||||
uni.$emit('refreshOrderList')
|
||||
uni.$emit('refreshOrderDetail')
|
||||
} catch (error) {
|
||||
router.navigateBack()
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
* @param orderId 订单ID
|
||||
* @param orderType 订单类型
|
||||
*/
|
||||
export async function handleRefundOrderHooks(orderId: number, orderType: string) {
|
||||
try {
|
||||
const response = await refundTeaSpecialistOrder({ id: orderId, order_type: orderType })
|
||||
uni.$emit('refreshOrderList')
|
||||
uni.$emit('refreshOrderDetail')
|
||||
} catch (error) {
|
||||
router.navigateBack()
|
||||
throw error
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user