Compare commits

...

5 Commits

Author SHA1 Message Date
dzq c4562333c0 feat(用户页面): 添加点击头像退出登录功能
在用户页面中,点击用户头像时会弹出确认对话框,确认后清除用户信息并跳转到登录页面
2025-04-25 09:58:19 +08:00
dzq 150487bbfb fix(订单页面): 修正打开柜子和退款按钮的显示条件
根据订单支付状态调整按钮的显示逻辑,确保按钮仅在订单支付状态为2或3时显示
2025-04-23 14:55:44 +08:00
dzq 168069f6a1 feat: 在开柜接口中添加格口ID并更新操作类型
在OpenCabinetApiData接口中添加了格口ID字段,并更新了多个页面中的操作类型值,以支持不同的操作场景。此外,开柜接口现在支持传递完整的开柜数据,确保操作信息的完整性。
2025-04-22 17:47:25 +08:00
dzq 627d9b557c fix(结账组件): 根据用户类型动态设置姓名字段
在结账组件中,根据用户类型(内部用户或普通用户)动态设置姓名字段。当用户为内部用户时,使用企业微信的用户姓名,否则使用普通用户的姓名。这样可以确保在结账时显示正确的用户姓名。
2025-04-22 15:39:13 +08:00
dzq c3ddddee3a feat: 添加企业微信用户姓名并更新储物柜打开接口
在QyLoginDTO接口中添加name字段,并在wx存储中引入name变量。更新openCabinetApi接口以支持传递用户信息,确保在打开储物柜时记录用户身份和操作类型。
2025-04-22 10:47:08 +08:00
10 changed files with 107 additions and 22 deletions
src
common/apis
pages
approval
cabinet
me
order
product/components
pinia/stores

View File

@ -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
})
}

View File

@ -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
})
}

View File

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

View File

@ -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 || '开启失败')

View File

@ -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 {

View File

@ -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>

View File

@ -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

View File

@ -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)"

View File

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

View File

@ -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 }
})