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 { 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'
|
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>>({
|
return request<ApiResponseData<void>>({
|
||||||
url: `order/openCabinet/${orderId}/${orderGoodsId}`,
|
url: `order/openCabinet/${orderId}/${orderGoodsId}`,
|
||||||
method: "post"
|
method: "post",
|
||||||
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,4 +107,18 @@ export interface QyLoginDTO {
|
||||||
userid: string
|
userid: string
|
||||||
openid: string
|
openid: string
|
||||||
isCabinetAdmin: number
|
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 { useApprovalStore } from '@/pinia/stores/approval'
|
||||||
import { useWxStore } from '@/pinia/stores/wx';
|
import { useWxStore } from '@/pinia/stores/wx';
|
||||||
import Compressor from 'compressorjs';
|
import Compressor from 'compressorjs';
|
||||||
|
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
|
||||||
|
|
||||||
const { VITE_APP_BASE_API } = import.meta.env;
|
const { VITE_APP_BASE_API } = import.meta.env;
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const approvalStore = useApprovalStore();
|
const approvalStore = useApprovalStore();
|
||||||
const wxStore = useWxStore();
|
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>({
|
const formData = ref<HandleApprovalRequestData>({
|
||||||
approvalId: approvalStore.currentApproval?.approvalId || 0,
|
approvalId: approvalStore.currentApproval?.approvalId || 0,
|
||||||
|
@ -188,9 +192,16 @@ const handleOpenCabinet = async () => {
|
||||||
|
|
||||||
isButtonDisabled.value = true
|
isButtonDisabled.value = true
|
||||||
try {
|
try {
|
||||||
|
const isInternal = corpidLogin.value ? 2 : ab98Userid.value ? 1 : 0;
|
||||||
const result = await openCabinetApi(
|
const result = await openCabinetApi(
|
||||||
approvalStore.currentApproval.orderId,
|
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) {
|
if (result.code !== 0) {
|
||||||
showFailToast(result.msg || '开启失败')
|
showFailToast(result.msg || '开启失败')
|
||||||
|
|
|
@ -9,8 +9,12 @@ const router = useRouter()
|
||||||
const wxStore = useWxStore()
|
const wxStore = useWxStore()
|
||||||
const ab98UserStore = useAb98UserStore()
|
const ab98UserStore = useAb98UserStore()
|
||||||
|
|
||||||
const { balance } = storeToRefs(wxStore)
|
const { balance, name: qyName } = storeToRefs(wxStore);
|
||||||
const { name: userName, sex: userSex, face_img } = storeToRefs(ab98UserStore)
|
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`
|
const userAvatar = face_img.value ? face_img.value : `${publicPath}img/1.jpg`
|
||||||
</script>
|
</script>
|
||||||
|
@ -29,7 +33,7 @@ const userAvatar = face_img.value ? face_img.value : `${publicPath}img/1.jpg`
|
||||||
class="mr-4"
|
class="mr-4"
|
||||||
/>
|
/>
|
||||||
<div>
|
<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>
|
<van-tag type="primary" class="mr-2">{{ userSex }}</van-tag>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,23 +2,35 @@
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { Order, useOrderStore } from '@/pinia/stores/order'
|
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 { openCabinetApi } from '@/common/apis/shop'
|
||||||
import { showSuccessToast, showFailToast } from 'vant'
|
import { showSuccessToast, showFailToast } from 'vant'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const orderStore = useOrderStore()
|
const orderStore = useOrderStore()
|
||||||
const wxStore = useWxStoreOutside()
|
|
||||||
const orderId = ref(Number(route.query.orderId))
|
const orderId = ref(Number(route.query.orderId))
|
||||||
const currentOrder = ref<Order>()
|
const currentOrder = ref<Order>()
|
||||||
const isButtonDisabled = ref<Record<number, boolean>>({})
|
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) {
|
async function handleOpenCabinet(orderId: number, orderGoodsId: number) {
|
||||||
isButtonDisabled.value[orderGoodsId] = true
|
isButtonDisabled.value[orderGoodsId] = true
|
||||||
try {
|
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) {
|
if (result.code !== 0) {
|
||||||
showFailToast(result.msg || '开启失败,请稍后重试')
|
showFailToast(result.msg || '开启失败,请稍后重试')
|
||||||
return
|
return
|
||||||
|
|
|
@ -5,11 +5,18 @@ import { useRoute, useRouter } from 'vue-router'
|
||||||
import { openCabinetApi } from '@/common/apis/shop'
|
import { openCabinetApi } from '@/common/apis/shop'
|
||||||
import { showSuccessToast, showFailToast } from 'vant'
|
import { showSuccessToast, showFailToast } from 'vant'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { useWxStore } from '@/pinia/stores/wx'
|
||||||
|
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
|
||||||
|
|
||||||
const orderStore = useOrderStore()
|
const orderStore = useOrderStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
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> = {
|
const statusMap: Record<number, string> = {
|
||||||
1: '待付款',
|
1: '待付款',
|
||||||
2: '已付款',
|
2: '已付款',
|
||||||
|
@ -65,7 +72,14 @@ async function handleOpenCabinet(item: OrderGoods) {
|
||||||
const orderGoodsId = item.orderGoods.orderGoodsId
|
const orderGoodsId = item.orderGoods.orderGoodsId
|
||||||
isButtonDisabled.value[orderGoodsId] = true
|
isButtonDisabled.value[orderGoodsId] = true
|
||||||
try {
|
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) {
|
if (result.code !== 0) {
|
||||||
showFailToast(result.msg || '开启失败,请稍后重试')
|
showFailToast(result.msg || '开启失败,请稍后重试')
|
||||||
return
|
return
|
||||||
|
|
|
@ -19,6 +19,8 @@ export const useWxStore = defineStore("wx", () => {
|
||||||
const corpidLogin = ref<boolean>(false);
|
const corpidLogin = ref<boolean>(false);
|
||||||
// 是否是柜子管理员
|
// 是否是柜子管理员
|
||||||
const isCabinetAdmin = ref<boolean>(false);
|
const isCabinetAdmin = ref<boolean>(false);
|
||||||
|
// 企业微信用户姓名
|
||||||
|
const name = ref<string>("");
|
||||||
|
|
||||||
// 设置 openid
|
// 设置 openid
|
||||||
const setOpenid = (id: string) => {
|
const setOpenid = (id: string) => {
|
||||||
|
@ -57,6 +59,7 @@ export const useWxStore = defineStore("wx", () => {
|
||||||
userid.value = res.data.userid;
|
userid.value = res.data.userid;
|
||||||
openid.value = res.data.openid;
|
openid.value = res.data.openid;
|
||||||
isCabinetAdmin.value = res.data.isCabinetAdmin === 1;
|
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 }
|
setOpenid, setBalance, handleWxCallback, setIsCabinetAdmin }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue