Compare commits
5 Commits
5c89ba97c4
...
c4562333c0
Author | SHA1 | Date |
---|---|---|
|
c4562333c0 | |
|
150487bbfb | |
|
168069f6a1 | |
|
627d9b557c | |
|
c3ddddee3a |
src
common/apis
pages
approval
cabinet
me
order
product/components
pinia/stores
|
@ -1,5 +1,6 @@
|
|||
import { request } from '@/http/axios'
|
||||
import type { CabinetDetailResponse } from './type'
|
||||
import { OpenCabinetApiData } from '../shop/type'
|
||||
|
||||
/** 获取智能柜详情接口 */
|
||||
export function getCabinetDetailApi() {
|
||||
|
@ -9,9 +10,10 @@ export function getCabinetDetailApi() {
|
|||
})
|
||||
}
|
||||
|
||||
export function openCabinet(lockControlNo: number, pinNo: number) {
|
||||
export function openCabinet(lockControlNo: number, pinNo: number, data: OpenCabinetApiData) {
|
||||
return request<ApiResponseData<void>>({
|
||||
url: `cabinet/openCabinet/${lockControlNo}/${pinNo}`,
|
||||
method: 'post'
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { request } from "@/http/axios"
|
||||
import { GetBalanceResponse, GetOrdersByOpenIdDTO, QyLoginDTO, QyLoginRequestParams, ShopGoodsResponseData, SubmitOrderRequestData, SubmitOrderResponseData } from './type'
|
||||
import { GetBalanceResponse, GetOrdersByOpenIdDTO, OpenCabinetApiData, QyLoginDTO, QyLoginRequestParams, ShopGoodsResponseData, SubmitOrderRequestData, SubmitOrderResponseData } from './type'
|
||||
import { GetOpenIdRequestParams } from './type'
|
||||
|
||||
|
||||
|
@ -47,10 +47,11 @@ export function getOrdersByOpenIdApi(openid: string) {
|
|||
}
|
||||
|
||||
/** 打开储物柜接口 */
|
||||
export function openCabinetApi(orderId: number, orderGoodsId: number) {
|
||||
export function openCabinetApi(orderId: number, orderGoodsId: number, data: OpenCabinetApiData) {
|
||||
return request<ApiResponseData<void>>({
|
||||
url: `order/openCabinet/${orderId}/${orderGoodsId}`,
|
||||
method: "post"
|
||||
method: "post",
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -107,4 +107,20 @@ export interface QyLoginDTO {
|
|||
userid: string
|
||||
openid: string
|
||||
isCabinetAdmin: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface OpenCabinetApiData {
|
||||
// 格口ID
|
||||
cellId?: number
|
||||
// 用户ID
|
||||
userid: string
|
||||
// 是否内部用户(0否 1汇邦云用户 2企业微信用户)
|
||||
isInternal: number
|
||||
// 姓名
|
||||
name: string
|
||||
// 联系电话
|
||||
mobile: string
|
||||
// 操作类型(1用户 2管理员)
|
||||
operationType: number
|
||||
}
|
|
@ -9,12 +9,16 @@ import { useRoute, useRouter } from 'vue-router'
|
|||
import { useApprovalStore } from '@/pinia/stores/approval'
|
||||
import { useWxStore } from '@/pinia/stores/wx';
|
||||
import Compressor from 'compressorjs';
|
||||
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
|
||||
|
||||
const { VITE_APP_BASE_API } = import.meta.env;
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const approvalStore = useApprovalStore();
|
||||
const wxStore = useWxStore();
|
||||
const { openid, balance, corpidLogin, userid: qyUserid, name: qyName } = storeToRefs(wxStore);
|
||||
const ab98UserStore = useAb98UserStore();
|
||||
const { tel, userid: ab98Userid, name } = storeToRefs(ab98UserStore);
|
||||
|
||||
const formData = ref<HandleApprovalRequestData>({
|
||||
approvalId: approvalStore.currentApproval?.approvalId || 0,
|
||||
|
@ -188,9 +192,16 @@ const handleOpenCabinet = async () => {
|
|||
|
||||
isButtonDisabled.value = true
|
||||
try {
|
||||
const isInternal = corpidLogin.value ? 2 : ab98Userid.value ? 1 : 0;
|
||||
const result = await openCabinetApi(
|
||||
approvalStore.currentApproval.orderId,
|
||||
approvalStore.currentApproval.orderGoodsId
|
||||
approvalStore.currentApproval.orderGoodsId, {
|
||||
userid: isInternal === 2 ? qyUserid.value : ab98Userid.value,
|
||||
isInternal: isInternal,
|
||||
name: isInternal === 2 ? qyName.value : name.value,
|
||||
mobile: tel.value,
|
||||
operationType: 2
|
||||
}
|
||||
)
|
||||
if (result.code !== 0) {
|
||||
showFailToast(result.msg || '开启失败')
|
||||
|
|
|
@ -56,10 +56,11 @@
|
|||
import { ref } from 'vue'
|
||||
import { getCabinetDetailApi, openCabinet } from '@/common/apis/cabinet'
|
||||
import type { CabinetDetailDTO } from '@/common/apis/cabinet/type'
|
||||
import { useWxStoreOutside } from '@/pinia/stores/wx'
|
||||
import { useWxStore, useWxStoreOutside } from '@/pinia/stores/wx'
|
||||
import { publicPath } from "@/common/utils/path"
|
||||
|
||||
const wxStore = useWxStoreOutside()
|
||||
const wxStore = useWxStore();
|
||||
const { userid: qyUserid, name: qyName } = storeToRefs(wxStore);
|
||||
|
||||
const activeCabinet = ref(0)
|
||||
const cabinetList = ref<CabinetItem[]>([])
|
||||
|
@ -132,7 +133,14 @@ const handleOpenLocker = async (locker: LockerItem) => {
|
|||
openingLockerId.value = locker.lockerId
|
||||
try {
|
||||
// 调用打开柜口接口
|
||||
await openCabinet(cabinetList.value[activeCabinet.value].lockControlNo, locker.lockerNumber)
|
||||
await openCabinet(cabinetList.value[activeCabinet.value].lockControlNo, locker.lockerNumber, {
|
||||
cellId: locker.lockerId,
|
||||
userid: qyUserid.value,
|
||||
isInternal: 2,
|
||||
name: qyName.value,
|
||||
mobile: '',
|
||||
operationType: 2
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('打开柜口失败:', error)
|
||||
} finally {
|
||||
|
|
|
@ -4,15 +4,32 @@ import { useWxStore } from '@/pinia/stores/wx'
|
|||
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { publicPath } from "@/common/utils/path"
|
||||
import { showConfirmDialog } from 'vant';
|
||||
|
||||
const router = useRouter()
|
||||
const wxStore = useWxStore()
|
||||
const ab98UserStore = useAb98UserStore()
|
||||
|
||||
const { balance } = storeToRefs(wxStore)
|
||||
const { name: userName, sex: userSex, face_img } = storeToRefs(ab98UserStore)
|
||||
const { balance, name: qyName } = storeToRefs(wxStore);
|
||||
const { name: userName, sex: userSex, face_img } = storeToRefs(ab98UserStore);
|
||||
|
||||
const userAvatar = face_img.value ? face_img.value : `${publicPath}img/1.jpg`
|
||||
const name = computed(() => {
|
||||
return userName.value || qyName.value || '未知用户'
|
||||
})
|
||||
|
||||
const userAvatar = face_img.value ? face_img.value : `${publicPath}img/1.jpg`;
|
||||
|
||||
const handleLogout = () => {
|
||||
showConfirmDialog({
|
||||
title: '退出登录',
|
||||
message: '确定要退出当前账号吗?',
|
||||
}).then(() => {
|
||||
ab98UserStore.clearUserInfo();
|
||||
router.push('/ab98');
|
||||
}).catch(() => {
|
||||
// 取消操作
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -27,9 +44,10 @@ const userAvatar = face_img.value ? face_img.value : `${publicPath}img/1.jpg`
|
|||
height="80"
|
||||
:src="userAvatar"
|
||||
class="mr-4"
|
||||
@click="handleLogout"
|
||||
/>
|
||||
<div>
|
||||
<div class="text-lg font-bold mb-2">{{ userName }}</div>
|
||||
<div class="text-lg font-bold mb-2">{{ name }}</div>
|
||||
<van-tag type="primary" class="mr-2">{{ userSex }}</van-tag>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,23 +2,35 @@
|
|||
import { useRouter } from 'vue-router'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { Order, useOrderStore } from '@/pinia/stores/order'
|
||||
import { useWxStoreOutside } from '@/pinia/stores/wx'
|
||||
import { useWxStore, useWxStoreOutside } from '@/pinia/stores/wx'
|
||||
import { openCabinetApi } from '@/common/apis/shop'
|
||||
import { showSuccessToast, showFailToast } from 'vant'
|
||||
import { ref } from 'vue'
|
||||
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const orderStore = useOrderStore()
|
||||
const wxStore = useWxStoreOutside()
|
||||
const orderId = ref(Number(route.query.orderId))
|
||||
const currentOrder = ref<Order>()
|
||||
const isButtonDisabled = ref<Record<number, boolean>>({})
|
||||
|
||||
const wxStore = useWxStore();
|
||||
const { openid, balance, corpidLogin, userid: qyUserid, name: qyName } = storeToRefs(wxStore);
|
||||
const ab98UserStore = useAb98UserStore();
|
||||
const { tel, userid: ab98Userid, name } = storeToRefs(ab98UserStore);
|
||||
|
||||
async function handleOpenCabinet(orderId: number, orderGoodsId: number) {
|
||||
isButtonDisabled.value[orderGoodsId] = true
|
||||
try {
|
||||
const result = await openCabinetApi(orderId, orderGoodsId)
|
||||
const isInternal = corpidLogin.value ? 2 : ab98Userid.value ? 1 : 0;
|
||||
const result = await openCabinetApi(orderId, orderGoodsId, {
|
||||
userid: isInternal === 2 ? qyUserid.value : ab98Userid.value,
|
||||
isInternal: isInternal,
|
||||
name: isInternal === 2 ? qyName.value : name.value,
|
||||
mobile: tel.value,
|
||||
operationType: 1
|
||||
});
|
||||
if (result.code !== 0) {
|
||||
showFailToast(result.msg || '开启失败,请稍后重试')
|
||||
return
|
||||
|
|
|
@ -5,11 +5,18 @@ import { useRoute, useRouter } from 'vue-router'
|
|||
import { openCabinetApi } from '@/common/apis/shop'
|
||||
import { showSuccessToast, showFailToast } from 'vant'
|
||||
import { ref } from 'vue'
|
||||
import { useWxStore } from '@/pinia/stores/wx'
|
||||
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
|
||||
|
||||
const orderStore = useOrderStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const wxStore = useWxStore();
|
||||
const { openid, balance, corpidLogin, userid: qyUserid, name: qyName } = storeToRefs(wxStore);
|
||||
const ab98UserStore = useAb98UserStore();
|
||||
const { tel, userid: ab98Userid, name } = storeToRefs(ab98UserStore);
|
||||
|
||||
const statusMap: Record<number, string> = {
|
||||
1: '待付款',
|
||||
2: '已付款',
|
||||
|
@ -65,7 +72,14 @@ async function handleOpenCabinet(item: OrderGoods) {
|
|||
const orderGoodsId = item.orderGoods.orderGoodsId
|
||||
isButtonDisabled.value[orderGoodsId] = true
|
||||
try {
|
||||
const result = await openCabinetApi(orderId.value, orderGoodsId)
|
||||
const isInternal = corpidLogin.value ? 2 : ab98Userid.value ? 1 : 0;
|
||||
const result = await openCabinetApi(orderId.value, orderGoodsId, {
|
||||
userid: isInternal === 2 ? qyUserid.value : ab98Userid.value,
|
||||
isInternal: isInternal,
|
||||
name: isInternal === 2 ? qyName.value : name.value,
|
||||
mobile: tel.value,
|
||||
operationType: 1
|
||||
})
|
||||
if (result.code !== 0) {
|
||||
showFailToast(result.msg || '开启失败,请稍后重试')
|
||||
return
|
||||
|
@ -120,7 +134,7 @@ async function handleOpenCabinet(item: OrderGoods) {
|
|||
<p>小计: ¥{{ (item.orderGoods.price * item.orderGoods.quantity).toFixed(2) }}</p>
|
||||
<div class="button-group">
|
||||
<van-button
|
||||
v-if="[1,5].includes(item.orderGoods.status)"
|
||||
v-if="[1,5].includes(item.orderGoods.status) && [2,3].includes(order.payStatus)"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleOpenCabinet(item)"
|
||||
|
@ -129,7 +143,7 @@ async function handleOpenCabinet(item: OrderGoods) {
|
|||
打开柜子
|
||||
</van-button>
|
||||
<van-button
|
||||
v-if="item.orderGoods.status === 1"
|
||||
v-if="item.orderGoods.status === 1 && [2,3].includes(order.payStatus)"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleRefund(item)"
|
||||
|
|
|
@ -14,7 +14,7 @@ const cartStore = useCartStore()
|
|||
const { cartItems, totalPrice } = storeToRefs(cartStore)
|
||||
|
||||
const wxStore = useWxStore()
|
||||
const { openid, balance, corpidLogin, userid: qyUserid } = storeToRefs(wxStore)
|
||||
const { openid, balance, corpidLogin, userid: qyUserid, name: qyName } = storeToRefs(wxStore)
|
||||
|
||||
const ab98UserStore = useAb98UserStore()
|
||||
const { tel, userid: ab98Userid, name } = storeToRefs(ab98UserStore)
|
||||
|
@ -102,7 +102,7 @@ async function handleSubmit() {
|
|||
})),
|
||||
paymentType: selectedPayment.value,
|
||||
mobile: tel.value,
|
||||
name: name.value,
|
||||
name: isInternal === 2 ? qyName.value : name.value,
|
||||
qyUserid: isInternal === 2 ? qyUserid.value : ab98Userid.value,
|
||||
isInternal: isInternal
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ export const useWxStore = defineStore("wx", () => {
|
|||
const corpidLogin = ref<boolean>(false);
|
||||
// 是否是柜子管理员
|
||||
const isCabinetAdmin = ref<boolean>(false);
|
||||
// 企业微信用户姓名
|
||||
const name = ref<string>("");
|
||||
|
||||
// 设置 openid
|
||||
const setOpenid = (id: string) => {
|
||||
|
@ -57,6 +59,7 @@ export const useWxStore = defineStore("wx", () => {
|
|||
userid.value = res.data.userid;
|
||||
openid.value = res.data.openid;
|
||||
isCabinetAdmin.value = res.data.isCabinetAdmin === 1;
|
||||
name.value = res.data.name;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +90,7 @@ export const useWxStore = defineStore("wx", () => {
|
|||
}
|
||||
}
|
||||
|
||||
return { code, state, openid, corpid, userid, balance, isCabinetAdmin, corpidLogin,
|
||||
return { code, state, openid, corpid, userid, balance, isCabinetAdmin, corpidLogin, name,
|
||||
setOpenid, setBalance, handleWxCallback, setIsCabinetAdmin }
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue