From 9e15542d828be002ea6b3b96cda465bf336b4f47 Mon Sep 17 00:00:00 2001 From: dzq Date: Wed, 2 Apr 2025 09:33:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 3 +- src/common/apis/shop/index.ts | 29 +++++++- src/common/apis/shop/type.ts | 23 ++++++- src/pages/me/index.vue | 15 +++-- src/pages/order/Success.vue | 1 + src/pages/product/ProductList.vue | 5 +- src/pages/product/components/checkout.vue | 81 +++++++++++++---------- src/pinia/stores/wx.ts | 62 ++++++++++++++--- types/auto/components.d.ts | 3 + 9 files changed, 165 insertions(+), 57 deletions(-) diff --git a/src/App.vue b/src/App.vue index 1def506..1bb4db8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -29,8 +29,9 @@ onMounted(() => { console.log('urlParams', urlParams); const code = urlParams.get('code') || undefined; const state = urlParams.get('state') || undefined; + const corpid = urlParams.get('corpid') || undefined; if (code || state) { - wxStore.handleWxCallback({ code, state }) + wxStore.handleWxCallback({ corpid, code, state }) } }) diff --git a/src/common/apis/shop/index.ts b/src/common/apis/shop/index.ts index 6aafb3e..f60a5b1 100644 --- a/src/common/apis/shop/index.ts +++ b/src/common/apis/shop/index.ts @@ -1,8 +1,9 @@ import { request } from "@/http/axios" -import { GetOrdersByOpenIdDTO, ShopGoodsResponseData, SubmitOrderRequestData, SubmitOrderResponseData } from './type' +import { GetBalanceResponse, GetOrdersByOpenIdDTO, QyLoginDTO, QyLoginRequestParams, ShopGoodsResponseData, SubmitOrderRequestData, SubmitOrderResponseData } from './type' import { GetOpenIdRequestParams } from './type' + /** 获取当前登录用户详情 */ export function getShopGoodsApi() { return request({ @@ -28,6 +29,14 @@ export function getOpenIdApi(params: GetOpenIdRequestParams) { params }) } +/** 企业微信登录 */ +export function qyLogin(params: QyLoginRequestParams) { + return request>({ + url: "common/login/qy", + method: "get", + params + }) +} /** 根据openid获取用户订单信息 */ export function getOrdersByOpenIdApi(openid: string) { @@ -43,4 +52,20 @@ export function openCabinetApi(orderId: number, orderGoodsId: number) { url: `order/openCabinet/${orderId}/${orderGoodsId}`, method: "post" }) -} \ No newline at end of file +} + +/** 获取用户余额接口 */ +export function getBalanceApi(openid: string) { + return request>({ + url: "payment/getBalance", + method: "get", + params: { openid } + }) +} +export function getBalanceByQyUserid(corpid: string, userid: string) { + return request>({ + url: "payment/getBalanceByQyUserid", + method: "get", + params: { corpid, userid } + }) +} diff --git a/src/common/apis/shop/type.ts b/src/common/apis/shop/type.ts index f38efcd..9f3314d 100644 --- a/src/common/apis/shop/type.ts +++ b/src/common/apis/shop/type.ts @@ -16,7 +16,10 @@ export type category = { } export interface SubmitOrderRequestData { - openid: string + openid: string; + userid: string; + corpid: string; + paymentType: 'wechat' | 'balance'; goodsList: Array<{ goodsId: number quantity: number @@ -26,6 +29,7 @@ export interface SubmitOrderRequestData { export type SubmitOrderResponseData = ApiResponseMsgData<{ orderId: number totalAmount: number + newBalance: number paymentInfo: WxJsApiPreCreateResponse }> @@ -46,6 +50,11 @@ export interface WxJsApiPreCreateResponse { export interface GetOpenIdRequestParams { code: string } +export interface QyLoginRequestParams { + corpid: string + code: string + state?: string +} export interface ShopOrderEntity { orderId: number @@ -72,3 +81,15 @@ export interface GetOrdersByOpenIdDTO { orderGoods: ShopOrderGoodsEntity[] goods: Goods[] } + +export interface GetBalanceResponse { + userid: string + corpid: string + balance: number +} + +export interface QyLoginDTO { + userid: string + openid: string + isCabinetAdmin: number +} \ No newline at end of file diff --git a/src/pages/me/index.vue b/src/pages/me/index.vue index 3114617..9b099ed 100644 --- a/src/pages/me/index.vue +++ b/src/pages/me/index.vue @@ -1,6 +1,11 @@