feat(router): 添加企业微信登录校验逻辑
在全局前置守卫中添加企业微信登录校验,当URL中包含corpid参数时,直接放行。同时,在订单提交逻辑中,根据用户类型(企业微信用户、汇邦云用户、外部用户)设置isInternal字段,并完善订单提交数据的字段。
This commit is contained in:
parent
4891d9376c
commit
1582ca6f2f
|
@ -16,10 +16,21 @@ export type category = {
|
|||
}
|
||||
|
||||
export interface SubmitOrderRequestData {
|
||||
/** 微信用户唯一标识 */
|
||||
openid: string;
|
||||
/** 系统用户ID */
|
||||
userid: string;
|
||||
/** 企业ID */
|
||||
corpid: string;
|
||||
/** 支付类型 wechat:微信 balance:余额 */
|
||||
paymentType: 'wechat' | 'balance';
|
||||
/** 联系电话 */
|
||||
mobile: string;
|
||||
/** 企业微信用户ID或汇邦云用户ID */
|
||||
qyUserid: string;
|
||||
/** 是否内部订单 0否 1汇邦云用户 2企业微信用户 */
|
||||
isInternal: number;
|
||||
/** 订单商品明细列表 */
|
||||
goodsList: Array<{
|
||||
goodsId: number
|
||||
quantity: number
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { useCartStore } from "@/pinia/stores/cart"
|
||||
import { useWxStore } from "@/pinia/stores/wx"
|
||||
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
|
||||
import { storeToRefs } from "pinia"
|
||||
import { showConfirmDialog } from "vant"
|
||||
import { submitOrderApi } from "@/common/apis/shop"
|
||||
|
@ -13,7 +14,10 @@ const cartStore = useCartStore()
|
|||
const { cartItems, totalPrice } = storeToRefs(cartStore)
|
||||
|
||||
const wxStore = useWxStore()
|
||||
const { openid, balance } = storeToRefs(wxStore)
|
||||
const { openid, balance, corpid, userid: qyUserid } = storeToRefs(wxStore)
|
||||
|
||||
const ab98UserStore = useAb98UserStore()
|
||||
const { tel, userid: ab98Userid } = storeToRefs(ab98UserStore)
|
||||
|
||||
const selectedPayment = ref<'wechat' | 'balance'>('wechat')
|
||||
const contact = ref("")
|
||||
|
@ -72,6 +76,11 @@ async function handleSubmit() {
|
|||
|
||||
submitting.value = true
|
||||
try {
|
||||
// 判断用户类型:
|
||||
// 2 - 企业微信用户(corpid存在)
|
||||
// 1 - 汇邦云用户(qyUserid存在)
|
||||
// 0 - 外部用户
|
||||
const isInternal = corpid.value ? 2 : qyUserid.value ? 1 : 0;
|
||||
const requestData: SubmitOrderRequestData = {
|
||||
openid: openid.value,
|
||||
userid: wxStore.userid,
|
||||
|
@ -80,7 +89,10 @@ async function handleSubmit() {
|
|||
goodsId: item.product.id,
|
||||
quantity: item.quantity
|
||||
})),
|
||||
paymentType: selectedPayment.value
|
||||
paymentType: selectedPayment.value,
|
||||
mobile: tel.value,
|
||||
qyUserid: isInternal === 2 ? qyUserid.value : ab98Userid.value,
|
||||
isInternal: isInternal
|
||||
}
|
||||
|
||||
const { code, data } = await submitOrderApi(requestData)
|
||||
|
|
|
@ -18,6 +18,14 @@ export function registerNavigationGuard(router: Router) {
|
|||
// 全局前置守卫
|
||||
router.beforeEach((to, _from) => {
|
||||
NProgress.start()
|
||||
|
||||
// 企业微信登录
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const corpid = urlParams.get('corpid') || undefined;
|
||||
if (corpid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const userStore = useAb98UserStore()
|
||||
if (!userStore.isLogin) {
|
||||
// 如果在免登录的白名单中,则直接进入
|
||||
|
|
Loading…
Reference in New Issue