feat: 添加企业微信用户姓名并更新储物柜打开接口
在QyLoginDTO接口中添加name字段,并在wx存储中引入name变量。更新openCabinetApi接口以支持传递用户信息,确保在打开储物柜时记录用户身份和操作类型。
This commit is contained in:
parent
5c89ba97c4
commit
c3ddddee3a
|
@ -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,18 @@ export interface QyLoginDTO {
|
|||
userid: string
|
||||
openid: string
|
||||
isCabinetAdmin: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface OpenCabinetApiData {
|
||||
// 用户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: 0
|
||||
}
|
||||
)
|
||||
if (result.code !== 0) {
|
||||
showFailToast(result.msg || '开启失败')
|
||||
|
|
|
@ -9,8 +9,12 @@ 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 name = computed(() => {
|
||||
return userName.value || qyName.value || '未知用户'
|
||||
})
|
||||
|
||||
const userAvatar = face_img.value ? face_img.value : `${publicPath}img/1.jpg`
|
||||
</script>
|
||||
|
@ -29,7 +33,7 @@ const userAvatar = face_img.value ? face_img.value : `${publicPath}img/1.jpg`
|
|||
class="mr-4"
|
||||
/>
|
||||
<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: 0
|
||||
});
|
||||
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: 0
|
||||
})
|
||||
if (result.code !== 0) {
|
||||
showFailToast(result.msg || '开启失败,请稍后重试')
|
||||
return
|
||||
|
|
|
@ -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