From 1bf1db640588bffd0180ff738583763c282dd684 Mon Sep 17 00:00:00 2001 From: DaxPay Date: Mon, 21 Oct 2024 10:42:09 +0800 Subject: [PATCH 01/12] =?UTF-8?q?ref=20=E8=8E=B7=E5=8F=96=E6=94=B6?= =?UTF-8?q?=E9=93=B6=E5=8F=B0=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/daxpay/cashier/ChannelCashier.api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/daxpay/cashier/ChannelCashier.api.ts b/src/views/daxpay/cashier/ChannelCashier.api.ts index 347adb6..7d2c9e1 100644 --- a/src/views/daxpay/cashier/ChannelCashier.api.ts +++ b/src/views/daxpay/cashier/ChannelCashier.api.ts @@ -8,7 +8,7 @@ import type { Result } from '#/axios' */ export function getCashierInfo(cashierType: string, appId: string) { return http.request>({ - url: '/unipay/ext/channel/cashier/getCashierType', + url: '/unipay/ext/channel/cashier/getCashier', method: 'GET', params: { cashierType, appId }, }) From de5e3a7fdab57e83b8be5b35bcd94113022be583 Mon Sep 17 00:00:00 2001 From: DaxPay Date: Mon, 28 Oct 2024 17:10:31 +0800 Subject: [PATCH 02/12] =?UTF-8?q?fix=20=E4=BD=8E=E7=89=88=E6=9C=ACnode?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=9E=84=E5=BB=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 15a781c..3f13e95 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "type": "module", "version": "3.0.0", "engines": { - "node": ">=18.12.0", + "node": ">=20.6.0", "pnpm": ">=9.0.2" }, "scripts": { From 2ab011adfcc7a1a5dc0e0d2544eff85734a9264e Mon Sep 17 00:00:00 2001 From: DaxPay Date: Mon, 25 Nov 2024 20:27:30 +0800 Subject: [PATCH 03/12] =?UTF-8?q?refactor(router):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=94=B6=E9=93=B6=E5=8F=B0=E8=B7=AF=E7=94=B1=E5=92=8C=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新路由配置,统一收银台相关路径 - 重命名收银台相关组件,提高代码可读性 - 新增结算台相关路由和组件 - 优化微信和支付宝收银台的逻辑 - 调整收银台 API 接口和数据结构 --- src/router/daxpay.ts | 42 +++++-- ...annelCashier.api.ts => CashierCode.api.ts} | 50 ++++---- .../{ChannelCashier.vue => CashierCode.vue} | 6 +- src/views/daxpay/cashier/ChannelCheckout.vue | 24 ++++ ...lipayCashier.vue => AlipayCashierCode.vue} | 20 ++-- .../daxpay/cashier/alipay/AlipayCheckout.vue | 111 ++++++++++++++++++ ...echatCashier.vue => WechatCashierCode.vue} | 40 ++++--- .../daxpay/cashier/wechat/WechatCheckout.vue | 11 ++ 8 files changed, 240 insertions(+), 64 deletions(-) rename src/views/daxpay/cashier/{ChannelCashier.api.ts => CashierCode.api.ts} (69%) rename src/views/daxpay/cashier/{ChannelCashier.vue => CashierCode.vue} (72%) create mode 100644 src/views/daxpay/cashier/ChannelCheckout.vue rename src/views/daxpay/cashier/alipay/{AlipayCashier.vue => AlipayCashierCode.vue} (88%) create mode 100644 src/views/daxpay/cashier/alipay/AlipayCheckout.vue rename src/views/daxpay/cashier/wechat/{WechatCashier.vue => WechatCashierCode.vue} (84%) create mode 100644 src/views/daxpay/cashier/wechat/WechatCheckout.vue diff --git a/src/router/daxpay.ts b/src/router/daxpay.ts index 282d435..e6df393 100644 --- a/src/router/daxpay.ts +++ b/src/router/daxpay.ts @@ -27,28 +27,52 @@ export const DaxPayRoute: RouteRecordRaw = { }, }, { - path: '/channel/cashier/:appId', - name: 'ChannelCashier', - component: () => import('@/views/daxpay/cashier/ChannelCashier.vue'), + path: '/cashier/:code', + name: 'CashierCode', + component: () => import('@/views/daxpay/cashier/CashierCode.vue'), meta: { title: '收银台', }, }, { - path: '/alipay/cashier/:appId', - name: 'AlipayCashier', - component: () => import('@/views/daxpay/cashier/alipay/AlipayCashier.vue'), + path: '/cashier/alipay/:code', + name: 'AlipayCashierCode', + component: () => import('@/views/daxpay/cashier/alipay/AlipayCashierCode.vue'), meta: { title: '支付宝收银台', }, }, { - path: '/wechat/cashier/:appId', - name: 'WechatCashier', - component: () => import('@/views/daxpay/cashier/wechat/WechatCashier.vue'), + path: '/cashier/wechat/:code', + name: 'WechatCashierCode', + component: () => import('@/views/daxpay/cashier/wechat/WechatCashierCode.vue'), meta: { title: '微信收银台', }, }, + { + path: '/checkout/:code', + name: 'ChannelCashier', + component: () => import('@/views/daxpay/cashier/ChannelCheckout.vue'), + meta: { + title: '结算台', + }, + }, + { + path: '/alipay/checkout/:appId/:orderId', + name: 'AlipayCashier', + component: () => import('@/views/daxpay/cashier/alipay/AlipayCheckout.vue'), + meta: { + title: '支付宝结算台', + }, + }, + { + path: '/wechat/checkout/:appId/:orderId', + name: 'WechatCheckout', + component: () => import('@/views/daxpay/cashier/wechat/WechatCheckout.vue'), + meta: { + title: '微信结算台', + }, + }, ], } diff --git a/src/views/daxpay/cashier/ChannelCashier.api.ts b/src/views/daxpay/cashier/CashierCode.api.ts similarity index 69% rename from src/views/daxpay/cashier/ChannelCashier.api.ts rename to src/views/daxpay/cashier/CashierCode.api.ts index 7d2c9e1..26f32ac 100644 --- a/src/views/daxpay/cashier/ChannelCashier.api.ts +++ b/src/views/daxpay/cashier/CashierCode.api.ts @@ -2,24 +2,23 @@ import type { AuthResult } from '../auth/ChannelAuth.api' import { http } from '@/utils/http/axios' import type { Result } from '#/axios' - /** - * 获取收银台信息 + * 获取收银台配置信息 */ -export function getCashierInfo(cashierType: string, appId: string) { - return http.request>({ - url: '/unipay/ext/channel/cashier/getCashier', +export function getCashierTypeConfig(cashierType: string, cashierCode: string) { + return http.request>({ + url: '/unipay/cashier/code/findByCashierType', method: 'GET', - params: { cashierType, appId }, + params: { cashierType, cashierCode }, }) } /** * 获取收银台所需授权链接, 用于获取OpenId一类的信息 */ -export function generateAuthUrl(param: CashierAuthParam) { +export function generateAuthUrl(param: CashierAuthUrlParam) { return http.request>({ - url: '/unipay/ext/channel/cashier/generateAuthUrl', + url: '/unipay/cashier/code/generateAuthUrl', method: 'POST', data: param, }) @@ -28,9 +27,9 @@ export function generateAuthUrl(param: CashierAuthParam) { /** * 获取授权信息 */ -export function auth(param: CashierPayParam) { +export function auth(param: CashierAuthParam) { return http.request>({ - url: '/unipay/ext/channel/cashier/auth', + url: '/unipay/cashier/code/auth', method: 'POST', data: param, }) @@ -41,18 +40,28 @@ export function auth(param: CashierPayParam) { */ export function cashierPay(param: CashierPayParam) { return http.request>({ - url: '/unipay/ext/channel/cashier/pay', + url: '/unipay/cashier/code/pay', method: 'POST', data: param, }) } /** - * 通道认证参数 + * 获取认证URL参数 + */ +export interface CashierAuthUrlParam { + // 应用号 + cashierCode?: string + // 收银台类型 + cashierType?: string +} + +/** + * 认证参数 */ export interface CashierAuthParam { // 应用号 - appId?: string + cashierCode?: string // 收银台类型 cashierType?: string // 授权码 @@ -64,7 +73,7 @@ export interface CashierAuthParam { */ export interface CashierPayParam { // 应用号 - appId?: string + cashierCode?: string // 收银台类型 cashierType?: string // 支付金额 @@ -79,7 +88,6 @@ export interface CashierPayParam { * 支付结果 */ export interface PayResult { - // 支付状态 status: string // 支付参数体 @@ -109,21 +117,17 @@ export interface WxJsapiSignResult { } /** - * 收银台配置信息 + * 收银码牌配置信息 */ -export interface ChannelCashierConfigResult { +export interface CashierTypeConfigResult { // 应用号 appId?: string - // 收银台类型 - cashierType?: string - // 收银台名称 - cashierName?: string + // 码牌名称 + name?: string // 支付通道 channel?: string // 支付方式 payMethod?: string // 是否开启分账 allocation?: boolean - // 自动分账 - autoAllocation?: boolean } diff --git a/src/views/daxpay/cashier/ChannelCashier.vue b/src/views/daxpay/cashier/CashierCode.vue similarity index 72% rename from src/views/daxpay/cashier/ChannelCashier.vue rename to src/views/daxpay/cashier/CashierCode.vue index d97039c..69e5846 100644 --- a/src/views/daxpay/cashier/ChannelCashier.vue +++ b/src/views/daxpay/cashier/CashierCode.vue @@ -6,14 +6,14 @@ import { useRoute } from 'vue-router' import router from '@/router' const route = useRoute() -const { appId } = route.params +const { code } = route.params const ua = navigator.userAgent if (ua.includes('MicroMessenger')) { - router.push({ path: `/wechat/cashier/${appId}`, replace: true }) + router.push({ path: `/cashier/wechat/${code}`, replace: true }) } else if (ua.includes('Alipay')) { - router.push({ path: `/alipay/cashier/${appId}`, replace: true }) + router.push({ path: `/cashier/alipay/${code}`, replace: true }) } else { router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等支付程序进行扫码支付' }, replace: true }) diff --git a/src/views/daxpay/cashier/ChannelCheckout.vue b/src/views/daxpay/cashier/ChannelCheckout.vue new file mode 100644 index 0000000..958e4b4 --- /dev/null +++ b/src/views/daxpay/cashier/ChannelCheckout.vue @@ -0,0 +1,24 @@ + + + + + diff --git a/src/views/daxpay/cashier/alipay/AlipayCashier.vue b/src/views/daxpay/cashier/alipay/AlipayCashierCode.vue similarity index 88% rename from src/views/daxpay/cashier/alipay/AlipayCashier.vue rename to src/views/daxpay/cashier/alipay/AlipayCashierCode.vue index 10cc33e..387f65f 100644 --- a/src/views/daxpay/cashier/alipay/AlipayCashier.vue +++ b/src/views/daxpay/cashier/alipay/AlipayCashierCode.vue @@ -2,7 +2,7 @@
- {{ cashierInfo.cashierName || '支付宝收银台' }} + {{ cashierTypeConfig.name || '支付宝收银台' }}

@@ -65,23 +65,23 @@ import { useRoute } from 'vue-router' import { showNotify } from 'vant' import type { CashierPayParam, - ChannelCashierConfigResult, -} from '@/views/daxpay/cashier/ChannelCashier.api' + CashierTypeConfigResult, +} from '@/views/daxpay/cashier/CashierCode.api' import { cashierPay, - getCashierInfo, -} from '@/views/daxpay/cashier/ChannelCashier.api' + getCashierTypeConfig, +} from '@/views/daxpay/cashier/CashierCode.api' import { CashierTypeEnum } from '@/enums/daxpay/DaxPayEnum' import router from '@/router' import { useKeyboard } from '@/hooks/daxpay/useKeyboard' const route = useRoute() -const { appId } = route.params +const { code } = route.params const showRemark = ref(false) const loading = ref(false) -const cashierInfo = ref({}) +const cashierTypeConfig = ref({}) const amount = ref('0') const description = ref('') @@ -95,8 +95,8 @@ onMounted(() => { * 初始化数据 */ function initData() { - getCashierInfo(CashierTypeEnum.ALIPAY, appId as string).then(({ data }) => { - cashierInfo.value = data + getCashierTypeConfig(CashierTypeEnum.ALIPAY, code as string).then(({ data }) => { + cashierTypeConfig.value = data }).catch((res) => { router.push({ name: 'ErrorResult', query: { msg: res.message } }) }) @@ -114,7 +114,7 @@ function pay() { loading.value = true const from = { amount: amountValue, - appId, + cashierCode: code, cashierType: CashierTypeEnum.ALIPAY, description: description.value, } as CashierPayParam diff --git a/src/views/daxpay/cashier/alipay/AlipayCheckout.vue b/src/views/daxpay/cashier/alipay/AlipayCheckout.vue new file mode 100644 index 0000000..f45a085 --- /dev/null +++ b/src/views/daxpay/cashier/alipay/AlipayCheckout.vue @@ -0,0 +1,111 @@ + + + + + diff --git a/src/views/daxpay/cashier/wechat/WechatCashier.vue b/src/views/daxpay/cashier/wechat/WechatCashierCode.vue similarity index 84% rename from src/views/daxpay/cashier/wechat/WechatCashier.vue rename to src/views/daxpay/cashier/wechat/WechatCashierCode.vue index dce56b3..ff918f3 100644 --- a/src/views/daxpay/cashier/wechat/WechatCashier.vue +++ b/src/views/daxpay/cashier/wechat/WechatCashierCode.vue @@ -2,7 +2,7 @@

- {{ cashierInfo.cashierName || '微信收银台' }} + {{ cashierTypeConfig.cashierName || '微信收银台' }}

@@ -66,38 +66,37 @@ import { showNotify } from 'vant' import type { CashierAuthParam, CashierPayParam, - ChannelCashierConfigResult, + CashierTypeConfigResult, WxJsapiSignResult, -} from '@/views/daxpay/cashier/ChannelCashier.api' +} from '@/views/daxpay/cashier/CashierCode.api' import { auth , cashierPay, generateAuthUrl, - getCashierInfo, -} from '@/views/daxpay/cashier/ChannelCashier.api' + getCashierTypeConfig, +} from '@/views/daxpay/cashier/CashierCode.api' import { CashierTypeEnum } from '@/enums/daxpay/DaxPayEnum' import router from '@/router' import { useKeyboard } from '@/hooks/daxpay/useKeyboard' const route = useRoute() -const { appId } = route.params -const { code } = route.query +const { code } = route.params +const { code : authCode } = route.query const show = ref(false) const showRemark = ref(false) const loading = ref(false) -const cashierInfo = ref({}) +const cashierTypeConfig = ref({}) const amount = ref('0') const description = ref('') const openId = ref('') // 认证参数 const authParam = ref({ - appId: appId as string, - cashierType: CashierTypeEnum.WECHAT_PAY, + code: code as string, + type: CashierTypeEnum.WECHAT_PAY, }) - const { input, del } = useKeyboard(amount) onMounted(() => { @@ -105,13 +104,13 @@ onMounted(() => { }) /** - * 初始化 + * 进入页面的初始化 */ function init() { - // 如果不是重定向跳转过来, 跳转到到重定向地址 - if (!code) { + // 如果不是重定向跳转过来, 跳转到到重定向授权地址 + if (!authCode) { // 重定向跳转到微信授权地址 - generateAuthUrl(authParam.value).then((res) => { + generateAuthUrl({ cashierType: CashierTypeEnum.WECHAT_PAY, cashierCode: code as string}).then((res) => { const url = res.data location.replace(url) }).catch((res) => { @@ -119,7 +118,7 @@ function init() { }) } else { - authParam.value.authCode = code as string + authParam.value.authCode = authCode as string // 初始化数据 initData() } @@ -130,11 +129,14 @@ function init() { */ function initData() { show.value = true - getCashierInfo(CashierTypeEnum.ALIPAY, appId as string).then(({ data }) => { - cashierInfo.value = data + // 获取配置参数 + getCashierTypeConfig(CashierTypeEnum.WECHAT_PAY, code as string).then(({ data }) => { + cashierTypeConfig.value = data }).catch((res) => { router.push({ name: 'ErrorResult', query: { msg: res.message } }) }) + + // 认证获取OpenId auth(authParam.value).then(({ data }) => { openId.value = data.openId as string }).catch((res) => { @@ -154,8 +156,8 @@ function pay() { loading.value = true const from = { + cashierCode: code, amount: amountValue, - appId, openId: openId.value, cashierType: CashierTypeEnum.WECHAT_PAY, description: description.value, diff --git a/src/views/daxpay/cashier/wechat/WechatCheckout.vue b/src/views/daxpay/cashier/wechat/WechatCheckout.vue new file mode 100644 index 0000000..0a8d203 --- /dev/null +++ b/src/views/daxpay/cashier/wechat/WechatCheckout.vue @@ -0,0 +1,11 @@ + + + + + From 85d0bd852c8cc2c6e804e78b005970d7b8b5cd0d Mon Sep 17 00:00:00 2001 From: DaxPay Date: Mon, 2 Dec 2024 19:57:39 +0800 Subject: [PATCH 04/12] =?UTF-8?q?refactor(daxpay):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=94=B6=E9=93=B6=E5=8F=B0=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改路由配置,统一使用 orderNo替代 appId 和 orderId -重命名相关组件和文件,优化目录结构 - 更新错误提示信息,使其更加友好 - 新增 CheckoutPay.api.ts 文件,定义收银台相关 API 接口 --- src/router/daxpay.ts | 12 +- src/views/daxpay/cashier/CashierCode.vue | 2 +- src/views/daxpay/checkout/CheckoutPay.api.ts | 187 ++++++++++++++++++ .../CheckoutPay.vue} | 8 +- .../alipay/AliAggregate.vue} | 13 +- .../wechat/WechatAggregate.vue} | 0 6 files changed, 205 insertions(+), 17 deletions(-) create mode 100644 src/views/daxpay/checkout/CheckoutPay.api.ts rename src/views/daxpay/{cashier/ChannelCheckout.vue => checkout/CheckoutPay.vue} (58%) rename src/views/daxpay/{cashier/alipay/AlipayCheckout.vue => checkout/alipay/AliAggregate.vue} (87%) rename src/views/daxpay/{cashier/wechat/WechatCheckout.vue => checkout/wechat/WechatAggregate.vue} (100%) diff --git a/src/router/daxpay.ts b/src/router/daxpay.ts index e6df393..f0e075c 100644 --- a/src/router/daxpay.ts +++ b/src/router/daxpay.ts @@ -51,25 +51,25 @@ export const DaxPayRoute: RouteRecordRaw = { }, }, { - path: '/checkout/:code', + path: '/checkout/:orderNo', name: 'ChannelCashier', - component: () => import('@/views/daxpay/cashier/ChannelCheckout.vue'), + component: () => import('@/views/daxpay/checkout/CheckoutPay.vue'), meta: { title: '结算台', }, }, { - path: '/alipay/checkout/:appId/:orderId', + path: '/alipay/checkout/:appId/:orderNo', name: 'AlipayCashier', - component: () => import('@/views/daxpay/cashier/alipay/AlipayCheckout.vue'), + component: () => import('@/views/daxpay/checkout/alipay/AliAggregate.vue'), meta: { title: '支付宝结算台', }, }, { - path: '/wechat/checkout/:appId/:orderId', + path: '/wechat/checkout/:appId/:orderNo', name: 'WechatCheckout', - component: () => import('@/views/daxpay/cashier/wechat/WechatCheckout.vue'), + component: () => import('@/views/daxpay/checkout/wechat/WechatAggregate.vue'), meta: { title: '微信结算台', }, diff --git a/src/views/daxpay/cashier/CashierCode.vue b/src/views/daxpay/cashier/CashierCode.vue index 69e5846..19c033c 100644 --- a/src/views/daxpay/cashier/CashierCode.vue +++ b/src/views/daxpay/cashier/CashierCode.vue @@ -16,7 +16,7 @@ else if (ua.includes('Alipay')) { router.push({ path: `/cashier/alipay/${code}`, replace: true }) } else { - router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等支付程序进行扫码支付' }, replace: true }) + router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等软件进行扫码支付' }, replace: true }) } diff --git a/src/views/daxpay/checkout/CheckoutPay.api.ts b/src/views/daxpay/checkout/CheckoutPay.api.ts new file mode 100644 index 0000000..880347d --- /dev/null +++ b/src/views/daxpay/checkout/CheckoutPay.api.ts @@ -0,0 +1,187 @@ +import { http } from '@/utils/http/axios' +import type { Result } from '#/axios' +import {AuthResult} from "@/views/daxpay/auth/ChannelAuth.api"; + +/** + * 获取收银台订单和配置信息 + */ +export function getOrderAndConfig(orderNo, checkoutType){ + return http.request({ + url: '/unipay/checkout/getOrderAndConfig', + method: 'GET', + params: { + orderNo, + checkoutType + } + }) +} +/** + * 获取聚合支付配置 + */ +export function getAggregateConfig(orderNo, aggregateType){ + return http.request>({ + url: '/unipay/checkout/getAggregateConfig', + method: 'GET', + params: { + orderNo, + aggregateType + } + }) + +} +/** + * 获取收银台所需授权链接, 用于获取OpenId一类的信息 + */ +export function generateAuthUrl(param: CheckoutAuthUrlParam){ + return http.request>({ + url: '/unipay/checkout/generateAuthUrl', + method: 'post', + data: param + }) +} +/** + * 获取授权结果 + */ +export function auth(param: CheckoutAuthCodeParam){ + return http.request({ + url: '/unipay/checkout/auth', + method: 'post', + data: param + }) +} +/** + * 发起支付 + */ +export function pay(param: CheckoutPayParam){ + return http.request>({ + url: '/unipay/checkout/pay', + method: 'post', + data: param + }) +} + +/** + * 收银台认证链接生成参数 + */ +export interface CheckoutAuthUrlParam { + /** + * 要支付的订单号 + */ + orderNo?: string; + /** + * 聚合支付类型 + */ + aggregateType?: string; +} +/** + * 获取收银台认证结果参数 + */ +export interface CheckoutAuthCodeParam { + /** + * 要支付的订单号 + */ + orderNo?: string; + /** + * 聚合支付类型 + */ + aggregateType?: string; + /** + * 认证Code + */ + authCode?: string +} + +/** + * 收银台支付参数 + */ +export interface CheckoutPayParam{ + /** + * 订单号 + */ + orderNo?: string; + /** + * 支付配置项ID + */ + itemId?: string; + /** + * 唯一标识 + */ + openId?: string; + /** + * 付款码 + */ + barCode?: string; +} + +/** + * 收银台聚合支付配置 + */ +export interface AggregateOrderAndConfigResult{ + + /** + * 订单信息 + */ + order: CheckoutOrderResult; + /** + * 收银台配置信息 + */ + config: CheckoutConfigResult; + /** + * 收银台聚合配置信息 + */ + aggregateConfig: AggregateConfigResult; +} + +/** + * 订单信息 + */ +export interface CheckoutOrderResult{ + /** 商户订单号 */ + bizOrderNo?: string; + /** 订单号 */ + orderNo?: string; + /** 标题 */ + title?: string; + /** 描述 */ + description?: string; + /** 金额(元) */ + amount?: string; + +} +/** + * 收银台配置信息 + */ +export interface CheckoutConfigResult{ + /** 收银台名称 */ + name?: string; + /** PC收银台是否同时显示聚合收银码 */ + aggregateShow?: boolean; + /** h5收银台自动升级聚合支付 */ + h5AutoUpgrade?: boolean; +} +/** + * 收银台聚合配置信息 + */ +export interface AggregateConfigResult{ + /** 支付类型 */ + type?: string; + /** 通道 */ + channel?: string; + /** 支付方式 */ + payMethod?: string; + /** 自动拉起支付 */ + autoLaunch?: boolean; +} +/** + * 收银台支付结果 + */ +export interface CheckoutPayResult{ + /** + * 链接 + */ + url?: string; + /** + * 支付状态 + */ + payStatus?: string; +} diff --git a/src/views/daxpay/cashier/ChannelCheckout.vue b/src/views/daxpay/checkout/CheckoutPay.vue similarity index 58% rename from src/views/daxpay/cashier/ChannelCheckout.vue rename to src/views/daxpay/checkout/CheckoutPay.vue index 958e4b4..1241995 100644 --- a/src/views/daxpay/cashier/ChannelCheckout.vue +++ b/src/views/daxpay/checkout/CheckoutPay.vue @@ -6,17 +6,17 @@ import { useRoute } from 'vue-router' import router from '@/router' const route = useRoute() -const { appId, orderId } = route.params +const { code: orderNo } = route.params const ua = navigator.userAgent if (ua.includes('MicroMessenger')) { - router.push({ path: `/wechat/checkout/${appId}/${orderId}`, replace: true }) + router.push({ path: `/wechat/checkout/${orderNo}`, replace: true }) } else if (ua.includes('Alipay')) { - router.push({ path: `/alipay/checkout/${appId}/${orderId}`, replace: true }) + router.push({ path: `/alipay/checkout/${orderNo}`, replace: true }) } else { - router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等支付程序进行扫码支付' }, replace: true }) + router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等软件进行扫码支付' }, replace: true }) } diff --git a/src/views/daxpay/cashier/alipay/AlipayCheckout.vue b/src/views/daxpay/checkout/alipay/AliAggregate.vue similarity index 87% rename from src/views/daxpay/cashier/alipay/AlipayCheckout.vue rename to src/views/daxpay/checkout/alipay/AliAggregate.vue index f45a085..33640ae 100644 --- a/src/views/daxpay/cashier/alipay/AlipayCheckout.vue +++ b/src/views/daxpay/checkout/alipay/AliAggregate.vue @@ -31,9 +31,10 @@ import { import { CashierTypeEnum } from '@/enums/daxpay/DaxPayEnum' import router from '@/router' +import {getAggregateConfig} from "@/views/daxpay/checkout/CheckoutPay.api"; const route = useRoute() -const { appId, orderId } = route.params +const { orderNo } = route.params const loading = ref(false) const cashierInfo = ref({}) @@ -49,11 +50,11 @@ onMounted(() => { * 初始化数据 */ function initData() { - // getCashierInfo(CashierTypeEnum.ALIPAY, appId as string).then(({ data }) => { - // cashierInfo.value = data - // }).catch((res) => { - // router.push({ name: 'ErrorResult', query: { msg: res.message } }) - // }) + getAggregateConfig(orderNo, wechat).then(({ data }) => { + cashierInfo.value = data + }).catch((res) => { + router.push({ name: 'ErrorResult', query: { msg: res.message } }) + }) } /** diff --git a/src/views/daxpay/cashier/wechat/WechatCheckout.vue b/src/views/daxpay/checkout/wechat/WechatAggregate.vue similarity index 100% rename from src/views/daxpay/cashier/wechat/WechatCheckout.vue rename to src/views/daxpay/checkout/wechat/WechatAggregate.vue From c022aa8650c9fde685264be41113aaee3cf5d24e Mon Sep 17 00:00:00 2001 From: bootx Date: Mon, 2 Dec 2024 22:35:10 +0800 Subject: [PATCH 05/12] =?UTF-8?q?refactor(daxpay):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E8=81=9A=E5=90=88=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新 AliAggregate.vue 组件,适配新的聚合支付接口和数据结构 - 修改 CheckoutPay.api.ts,统一支付相关 API 接口定义 - 新增 AggregateTypeEnum 枚举,用于区分不同的聚合支付类型 --- src/enums/daxpay/DaxPayEnum.ts | 8 ++ src/views/daxpay/checkout/CheckoutPay.api.ts | 92 +++++++++---------- .../daxpay/checkout/alipay/AliAggregate.vue | 37 ++++---- 3 files changed, 70 insertions(+), 67 deletions(-) diff --git a/src/enums/daxpay/DaxPayEnum.ts b/src/enums/daxpay/DaxPayEnum.ts index 6b3c9f2..f27d300 100644 --- a/src/enums/daxpay/DaxPayEnum.ts +++ b/src/enums/daxpay/DaxPayEnum.ts @@ -26,3 +26,11 @@ export enum CashierTypeEnum { WECHAT_PAY = 'wechat_pay', ALIPAY = 'alipay', } + +/** + * 聚合支付方式 + */ +export enum AggregateTypeEnum { + WECHAT = 'wechat', + ALIPAY = 'alipay', +} diff --git a/src/views/daxpay/checkout/CheckoutPay.api.ts b/src/views/daxpay/checkout/CheckoutPay.api.ts index 880347d..2add11b 100644 --- a/src/views/daxpay/checkout/CheckoutPay.api.ts +++ b/src/views/daxpay/checkout/CheckoutPay.api.ts @@ -1,62 +1,62 @@ import { http } from '@/utils/http/axios' import type { Result } from '#/axios' -import {AuthResult} from "@/views/daxpay/auth/ChannelAuth.api"; +import type { AuthResult } from '@/views/daxpay/auth/ChannelAuth.api' +import {PayResult} from "@/views/daxpay/cashier/CashierCode.api"; /** * 获取收银台订单和配置信息 */ -export function getOrderAndConfig(orderNo, checkoutType){ +export function getOrderAndConfig(orderNo, checkoutType) { return http.request({ url: '/unipay/checkout/getOrderAndConfig', method: 'GET', params: { orderNo, - checkoutType - } + checkoutType, + }, }) } /** * 获取聚合支付配置 */ -export function getAggregateConfig(orderNo, aggregateType){ +export function getAggregateConfig(orderNo, aggregateType) { return http.request>({ url: '/unipay/checkout/getAggregateConfig', method: 'GET', params: { orderNo, - aggregateType - } + aggregateType, + }, }) - } /** * 获取收银台所需授权链接, 用于获取OpenId一类的信息 */ -export function generateAuthUrl(param: CheckoutAuthUrlParam){ +export function generateAuthUrl(param: CheckoutAuthUrlParam) { return http.request>({ url: '/unipay/checkout/generateAuthUrl', method: 'post', - data: param + data: param, }) } /** * 获取授权结果 */ -export function auth(param: CheckoutAuthCodeParam){ +export function auth(param: CheckoutAuthCodeParam) { return http.request({ url: '/unipay/checkout/auth', method: 'post', - data: param + data: param, }) } /** * 发起支付 */ -export function pay(param: CheckoutPayParam){ - return http.request>({ +export function checkoutPay(param: CheckoutPayParam) { + return http.request>({ url: '/unipay/checkout/pay', method: 'post', - data: param + data: param, }) } @@ -67,11 +67,11 @@ export interface CheckoutAuthUrlParam { /** * 要支付的订单号 */ - orderNo?: string; + orderNo?: string /** * 聚合支付类型 */ - aggregateType?: string; + aggregateType?: string } /** * 获取收银台认证结果参数 @@ -80,11 +80,11 @@ export interface CheckoutAuthCodeParam { /** * 要支付的订单号 */ - orderNo?: string; + orderNo?: string /** * 聚合支付类型 */ - aggregateType?: string; + aggregateType?: string /** * 认证Code */ @@ -94,94 +94,94 @@ export interface CheckoutAuthCodeParam { /** * 收银台支付参数 */ -export interface CheckoutPayParam{ +export interface CheckoutPayParam { /** * 订单号 */ - orderNo?: string; + orderNo?: string /** * 支付配置项ID */ - itemId?: string; + itemId?: string /** * 唯一标识 */ - openId?: string; + openId?: string /** * 付款码 */ - barCode?: string; + barCode?: string } /** * 收银台聚合支付配置 */ -export interface AggregateOrderAndConfigResult{ +export interface AggregateOrderAndConfigResult { /** * 订单信息 */ - order: CheckoutOrderResult; + order: CheckoutOrderResult /** * 收银台配置信息 */ - config: CheckoutConfigResult; + config: CheckoutConfigResult /** * 收银台聚合配置信息 */ - aggregateConfig: AggregateConfigResult; + aggregateConfig: AggregateConfigResult } /** * 订单信息 */ -export interface CheckoutOrderResult{ +export interface CheckoutOrderResult { /** 商户订单号 */ - bizOrderNo?: string; + bizOrderNo?: string /** 订单号 */ - orderNo?: string; + orderNo?: string /** 标题 */ - title?: string; + title?: string /** 描述 */ - description?: string; + description?: string /** 金额(元) */ - amount?: string; + amount?: string } /** * 收银台配置信息 */ -export interface CheckoutConfigResult{ +export interface CheckoutConfigResult { /** 收银台名称 */ - name?: string; + name?: string /** PC收银台是否同时显示聚合收银码 */ - aggregateShow?: boolean; + aggregateShow?: boolean /** h5收银台自动升级聚合支付 */ - h5AutoUpgrade?: boolean; + h5AutoUpgrade?: boolean } /** * 收银台聚合配置信息 */ -export interface AggregateConfigResult{ +export interface AggregateConfigResult { /** 支付类型 */ - type?: string; + type?: string /** 通道 */ - channel?: string; + channel?: string /** 支付方式 */ - payMethod?: string; + payMethod?: string /** 自动拉起支付 */ - autoLaunch?: boolean; + autoLaunch?: boolean } /** * 收银台支付结果 */ -export interface CheckoutPayResult{ +export interface CheckoutPayResult { /** * 链接 */ - url?: string; + url?: string /** * 支付状态 */ - payStatus?: string; + payStatus?: string } diff --git a/src/views/daxpay/checkout/alipay/AliAggregate.vue b/src/views/daxpay/checkout/alipay/AliAggregate.vue index 33640ae..8e1c8a4 100644 --- a/src/views/daxpay/checkout/alipay/AliAggregate.vue +++ b/src/views/daxpay/checkout/alipay/AliAggregate.vue @@ -20,28 +20,28 @@ import { onMounted, ref } from 'vue' import { useRoute } from 'vue-router' import { showNotify } from 'vant' -import type { - CashierPayParam, - CashierTypeConfigResult, -} from '@/views/daxpay/cashier/CashierCode.api' -import { - cashierPay, - getCashierTypeConfig, -} from '@/views/daxpay/cashier/CashierCode.api' -import { CashierTypeEnum } from '@/enums/daxpay/DaxPayEnum' +import { AggregateTypeEnum } from '@/enums/daxpay/DaxPayEnum' import router from '@/router' -import {getAggregateConfig} from "@/views/daxpay/checkout/CheckoutPay.api"; +import { + AggregateOrderAndConfigResult, checkoutPay, CheckoutPayParam, +} from '@/views/daxpay/checkout/CheckoutPay.api' +import { + getAggregateConfig, +} from '@/views/daxpay/checkout/CheckoutPay.api' const route = useRoute() const { orderNo } = route.params const loading = ref(false) -const cashierInfo = ref({}) +const cashierInfo = ref({ + aggregateConfig: {}, + config: {}, + order: {}, +}) const amount = ref('0') const description = ref('') - onMounted(() => { initData() }) @@ -50,7 +50,7 @@ onMounted(() => { * 初始化数据 */ function initData() { - getAggregateConfig(orderNo, wechat).then(({ data }) => { + getAggregateConfig(orderNo, AggregateTypeEnum.ALIPAY).then(({ data }) => { cashierInfo.value = data }).catch((res) => { router.push({ name: 'ErrorResult', query: { msg: res.message } }) @@ -68,16 +68,11 @@ function pay() { } loading.value = true const from = { - amount: amountValue, - Code: code, - cashierType: CashierTypeEnum.ALIPAY, - description: description.value, - } as CashierPayParam - cashierPay(from) + } as CheckoutPayParam + checkoutPay(from) .then(({ data }) => { loading.value = false - // 跳转到H5/付款码支付页面 - location.replace(data.payBody) + }) } From ba00dbd561e33e82f76cee9c18b32926274e8e6a Mon Sep 17 00:00:00 2001 From: DaxPay Date: Tue, 3 Dec 2024 17:38:27 +0800 Subject: [PATCH 06/12] =?UTF-8?q?feat(daxpay):=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E8=81=9A=E5=90=88=E6=94=AF=E4=BB=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增聚合支付相关枚举和接口 - 实现聚合支付的路由和页面组件 - 添加聚合支付的API请求和逻辑处理 - 优化普通支付的流程和界面 --- src/enums/daxpay/DaxPayEnum.ts | 20 ++++---- src/router/daxpay.ts | 22 ++++++--- src/views/daxpay/checkout/CheckAggregate.vue | 24 +++++++++ src/views/daxpay/checkout/CheckoutPay.api.ts | 30 +++++++++++- src/views/daxpay/checkout/CheckoutPay.vue | 16 +++--- .../daxpay/checkout/alipay/AliAggregate.vue | 49 ++++++++++--------- 6 files changed, 108 insertions(+), 53 deletions(-) create mode 100644 src/views/daxpay/checkout/CheckAggregate.vue diff --git a/src/enums/daxpay/DaxPayEnum.ts b/src/enums/daxpay/DaxPayEnum.ts index f27d300..352c2e6 100644 --- a/src/enums/daxpay/DaxPayEnum.ts +++ b/src/enums/daxpay/DaxPayEnum.ts @@ -10,7 +10,7 @@ export enum ChannelEnum { /** * 支付方式 */ -export enum payMethodEnum { +export enum PayMethodEnum { WAP = 'wap', APP = 'app', WEB = 'web', @@ -22,15 +22,15 @@ export enum payMethodEnum { /** * 收银台类型 */ -export enum CashierTypeEnum { - WECHAT_PAY = 'wechat_pay', - ALIPAY = 'alipay', +export enum CheckoutTypeEnum { + H5 = 'h5', + PC = 'pc', + MINI_APP = 'mini_app', + AGGREGATE = 'aggregate', } -/** - * 聚合支付方式 - */ -export enum AggregateTypeEnum { - WECHAT = 'wechat', - ALIPAY = 'alipay', +export enum AggregateEnum{ + ALI = 'ali', + WECHAT = 'wechat_pay', } + diff --git a/src/router/daxpay.ts b/src/router/daxpay.ts index f0e075c..91c998d 100644 --- a/src/router/daxpay.ts +++ b/src/router/daxpay.ts @@ -11,7 +11,7 @@ export const DaxPayRoute: RouteRecordRaw = { component: Layout, children: [ { - path: '/alipay/auth/:appId/:channel/:queryCode/:aliAppId', + path: '/auth/alipay/:appId/:channel/:queryCode/:aliAppId', name: 'AlipayAuth', component: () => import('@/views/daxpay/auth/alipay/AlipayAuth.vue'), meta: { @@ -19,7 +19,7 @@ export const DaxPayRoute: RouteRecordRaw = { }, }, { - path: '/wechat/auth/:appId/:channel/:queryCode', + path: '/auth/wechat/:appId/:channel/:queryCode', name: 'WechatAuth', component: () => import('@/views/daxpay/auth/wechat/WechatAuth.vue'), meta: { @@ -55,19 +55,27 @@ export const DaxPayRoute: RouteRecordRaw = { name: 'ChannelCashier', component: () => import('@/views/daxpay/checkout/CheckoutPay.vue'), meta: { - title: '结算台', + title: '手机收银台', }, }, { - path: '/alipay/checkout/:appId/:orderNo', - name: 'AlipayCashier', + path: '/aggregate/:orderNo', + name: 'ChannelCashier', + component: () => import('@/views/daxpay/checkout/CheckAggregate.vue'), + meta: { + title: '手机收银台', + }, + }, + { + path: '/aggregate/alipay/:orderNo', + name: 'AliCheckout', component: () => import('@/views/daxpay/checkout/alipay/AliAggregate.vue'), meta: { - title: '支付宝结算台', + title: '微信收银台', }, }, { - path: '/wechat/checkout/:appId/:orderNo', + path: '/aggregate/wechat/:orderNo', name: 'WechatCheckout', component: () => import('@/views/daxpay/checkout/wechat/WechatAggregate.vue'), meta: { diff --git a/src/views/daxpay/checkout/CheckAggregate.vue b/src/views/daxpay/checkout/CheckAggregate.vue new file mode 100644 index 0000000..cbe31ad --- /dev/null +++ b/src/views/daxpay/checkout/CheckAggregate.vue @@ -0,0 +1,24 @@ + + + + + diff --git a/src/views/daxpay/checkout/CheckoutPay.api.ts b/src/views/daxpay/checkout/CheckoutPay.api.ts index 2add11b..f334ecc 100644 --- a/src/views/daxpay/checkout/CheckoutPay.api.ts +++ b/src/views/daxpay/checkout/CheckoutPay.api.ts @@ -50,16 +50,27 @@ export function auth(param: CheckoutAuthCodeParam) { }) } /** - * 发起支付 + * 发起普通支付 */ export function checkoutPay(param: CheckoutPayParam) { - return http.request>({ + return http.request>({ url: '/unipay/checkout/pay', method: 'post', data: param, }) } +/** + * 发起聚合支付 + */ +export function aggregatePay(param: CheckoutAggregatePayParam) { + return http.request>({ + url: '/unipay/checkout/aggregatePay', + method: 'post', + data: param, + }) +} + /** * 收银台认证链接生成参数 */ @@ -113,6 +124,19 @@ export interface CheckoutPayParam { barCode?: string } + +/** + * 聚合支付参数 + */ +export interface CheckoutAggregatePayParam { + /** 订单号 */ + orderNo?: string + /** 聚合支付类型 */ + aggregateType?: string + /** 唯一标识 */ + openId?: string +} + /** * 收银台聚合支付配置 */ @@ -172,6 +196,8 @@ export interface AggregateConfigResult { /** 自动拉起支付 */ autoLaunch?: boolean } + + /** * 收银台支付结果 */ diff --git a/src/views/daxpay/checkout/CheckoutPay.vue b/src/views/daxpay/checkout/CheckoutPay.vue index 1241995..127cd8a 100644 --- a/src/views/daxpay/checkout/CheckoutPay.vue +++ b/src/views/daxpay/checkout/CheckoutPay.vue @@ -6,18 +6,14 @@ import { useRoute } from 'vue-router' import router from '@/router' const route = useRoute() -const { code: orderNo } = route.params +const { orderNo } = route.params const ua = navigator.userAgent -if (ua.includes('MicroMessenger')) { - router.push({ path: `/wechat/checkout/${orderNo}`, replace: true }) -} -else if (ua.includes('Alipay')) { - router.push({ path: `/alipay/checkout/${orderNo}`, replace: true }) -} -else { - router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等软件进行扫码支付' }, replace: true }) -} + +onMounted(()=>{ + +}) + From db4a87d3ae723d88f43ebe7b64906ef8ab66fd9b Mon Sep 17 00:00:00 2001 From: DaxPay Date: Wed, 4 Dec 2024 15:07:23 +0800 Subject: [PATCH 08/12] =?UTF-8?q?refactor(daxpay):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=94=B6=E9=93=B6=E5=8F=B0=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改枚举名称:将 AggregateTypeEnum重命名为 CheckoutAggregateEnum - 更新路由配置:修改收银台相关页面的路由名称 - 优化支付宝和微信收银台页面:调整页面布局和支付逻辑 - 重构公共方法:统一处理订单和配置信息获取 -调整样式:优化收银台页面样式 --- components.d.ts | 5 -- src/enums/daxpay/DaxPayEnum.ts | 5 +- src/router/daxpay.ts | 6 +-- src/views/daxpay/checkout/CheckAggregate.vue | 6 +-- src/views/daxpay/checkout/CheckoutPay.api.ts | 2 +- src/views/daxpay/checkout/CheckoutPay.vue | 13 ++--- .../daxpay/checkout/alipay/AliAggregate.vue | 8 ++-- .../checkout/wechat/WechatAggregate.vue | 48 +++++++++++++++---- 8 files changed, 60 insertions(+), 33 deletions(-) diff --git a/components.d.ts b/components.d.ts index d688bb4..4b976c5 100644 --- a/components.d.ts +++ b/components.d.ts @@ -12,12 +12,7 @@ declare module 'vue' { SvgIcon: typeof import('./src/components/SvgIcon.vue')['default'] VanButton: typeof import('vant/es')['Button'] VanConfigProvider: typeof import('vant/es')['ConfigProvider'] - VanDialog: typeof import('vant/es')['Dialog'] - VanField: typeof import('vant/es')['Field'] VanLoading: typeof import('vant/es')['Loading'] - VanNumberKeyboard: typeof import('vant/es')['NumberKeyboard'] - VanOverlay: typeof import('vant/es')['Overlay'] VanSubmitBar: typeof import('vant/es')['SubmitBar'] - VanTextEllipsis: typeof import('vant/es')['TextEllipsis'] } } diff --git a/src/enums/daxpay/DaxPayEnum.ts b/src/enums/daxpay/DaxPayEnum.ts index 6f0aaab..13047ce 100644 --- a/src/enums/daxpay/DaxPayEnum.ts +++ b/src/enums/daxpay/DaxPayEnum.ts @@ -37,7 +37,10 @@ export enum CheckoutTypeEnum { AGGREGATE = 'aggregate', } -export enum AggregateTypeEnum { +/** + * 收银台聚合支付类型 + */ +export enum CheckoutAggregateEnum { ALI = 'alipay', WECHAT = 'wechat_pay', } diff --git a/src/router/daxpay.ts b/src/router/daxpay.ts index 91c998d..90bf343 100644 --- a/src/router/daxpay.ts +++ b/src/router/daxpay.ts @@ -52,7 +52,7 @@ export const DaxPayRoute: RouteRecordRaw = { }, { path: '/checkout/:orderNo', - name: 'ChannelCashier', + name: 'CheckoutPay', component: () => import('@/views/daxpay/checkout/CheckoutPay.vue'), meta: { title: '手机收银台', @@ -60,7 +60,7 @@ export const DaxPayRoute: RouteRecordRaw = { }, { path: '/aggregate/:orderNo', - name: 'ChannelCashier', + name: 'CheckAggregate', component: () => import('@/views/daxpay/checkout/CheckAggregate.vue'), meta: { title: '手机收银台', @@ -71,7 +71,7 @@ export const DaxPayRoute: RouteRecordRaw = { name: 'AliCheckout', component: () => import('@/views/daxpay/checkout/alipay/AliAggregate.vue'), meta: { - title: '微信收银台', + title: '支付宝收银台', }, }, { diff --git a/src/views/daxpay/checkout/CheckAggregate.vue b/src/views/daxpay/checkout/CheckAggregate.vue index cbe31ad..0bfa3f4 100644 --- a/src/views/daxpay/checkout/CheckAggregate.vue +++ b/src/views/daxpay/checkout/CheckAggregate.vue @@ -6,14 +6,14 @@ import { useRoute } from 'vue-router' import router from '@/router' const route = useRoute() -const { code: orderNo } = route.params +const { orderNo } = route.params const ua = navigator.userAgent if (ua.includes('MicroMessenger')) { - router.push({ path: `/checkout/wechat/${orderNo}`, replace: true }) + router.push({ path: `/aggregate/wechat/${orderNo}`, replace: true }) } else if (ua.includes('Alipay')) { - router.push({ path: `/checkout/alipay/${orderNo}`, replace: true }) + router.push({ path: `/aggregate/alipay/${orderNo}`, replace: true }) } else { router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等软件进行扫码支付' }, replace: true }) diff --git a/src/views/daxpay/checkout/CheckoutPay.api.ts b/src/views/daxpay/checkout/CheckoutPay.api.ts index bacd223..9e375b5 100644 --- a/src/views/daxpay/checkout/CheckoutPay.api.ts +++ b/src/views/daxpay/checkout/CheckoutPay.api.ts @@ -155,7 +155,7 @@ export interface CheckoutOrderResult { /** 描述 */ description?: string /** 金额(元) */ - amount?: string + amount?: number } /** diff --git a/src/views/daxpay/checkout/CheckoutPay.vue b/src/views/daxpay/checkout/CheckoutPay.vue index a6591c5..8f11e04 100644 --- a/src/views/daxpay/checkout/CheckoutPay.vue +++ b/src/views/daxpay/checkout/CheckoutPay.vue @@ -1,6 +1,6 @@ @@ -16,7 +16,7 @@ const route = useRoute() const { orderNo } = route.params const ua = navigator.userAgent - +const show = ref(false) const orderAndConfig = ref({ order: {}, config: {}, @@ -40,8 +40,9 @@ async function initData() { }) // 判断是否自动升级为聚合控制台 if (orderAndConfig.value.config.h5AutoUpgrade) { - goAggregate() + await goAggregate() } + show.value = true } /** @@ -49,10 +50,10 @@ async function initData() { */ function goAggregate() { if (ua.includes('MicroMessenger')) { - router.push({ path: `/checkout/wechat/${orderNo}`, replace: true }) + router.push({ path: `/aggregate/wechat/${orderNo}`, replace: true }) } else if (ua.includes('Alipay')) { - router.push({ path: `/checkout/alipay/${orderNo}`, replace: true }) + router.push({ path: `/aggregate/alipay/${orderNo}`, replace: true }) } } diff --git a/src/views/daxpay/checkout/alipay/AliAggregate.vue b/src/views/daxpay/checkout/alipay/AliAggregate.vue index 31165e2..3856308 100644 --- a/src/views/daxpay/checkout/alipay/AliAggregate.vue +++ b/src/views/daxpay/checkout/alipay/AliAggregate.vue @@ -13,7 +13,7 @@

- +
@@ -21,7 +21,7 @@ import { onMounted, ref } from 'vue' import { useRoute } from 'vue-router' -import { AggregateTypeEnum } from '@/enums/daxpay/DaxPayEnum' +import { CheckoutAggregateEnum } from '@/enums/daxpay/DaxPayEnum' import router from '@/router' import type { AggregateOrderAndConfigResult, @@ -51,7 +51,7 @@ onMounted(() => { */ async function initData() { // 查询订单和配置 - await getAggregateConfig(orderNo, AggregateTypeEnum.ALI).then(({ data }) => { + await getAggregateConfig(orderNo, CheckoutAggregateEnum.ALI).then(({ data }) => { aggregateInfo.value = data }).catch((res) => { router.push({ name: 'ErrorResult', query: { msg: res.message } }) @@ -69,7 +69,7 @@ function pay() { loading.value = true const from = { orderNo: aggregateInfo.value.order.orderNo, - aggregateType: AggregateTypeEnum.ALI, + aggregateType: CheckoutAggregateEnum.ALI, } as CheckoutAggregatePayParam aggregatePay(from) .then(({ data }) => { diff --git a/src/views/daxpay/checkout/wechat/WechatAggregate.vue b/src/views/daxpay/checkout/wechat/WechatAggregate.vue index d9f7aaa..e5b06b9 100644 --- a/src/views/daxpay/checkout/wechat/WechatAggregate.vue +++ b/src/views/daxpay/checkout/wechat/WechatAggregate.vue @@ -1,18 +1,19 @@ @@ -20,10 +21,10 @@ import { onMounted, ref } from 'vue' import { useRoute } from 'vue-router' -import { AggregateTypeEnum } from '@/enums/daxpay/DaxPayEnum' +import { CheckoutAggregateEnum } from '@/enums/daxpay/DaxPayEnum' import router from '@/router' -import type { - AggregateOrderAndConfigResult, +import { + AggregateOrderAndConfigResult, aggregatePay, CheckoutAggregatePayParam, CheckoutAuthCodeParam, CheckoutPayParam, } from '@/views/daxpay/checkout/CheckoutPay.api' @@ -42,7 +43,8 @@ const openId = ref('') // 认证参数 const authParam = ref({ - aggregateType: AggregateTypeEnum.WECHAT, + orderNo: orderNo as string, + aggregateType: CheckoutAggregateEnum.WECHAT, }) const aggregateInfo = ref({ @@ -62,7 +64,7 @@ function init() { // 如果不是重定向跳转过来, 跳转到到重定向授权地址 if (!authCode) { // 重定向跳转到微信授权地址 - generateAuthUrl({ orderNo: orderNo as string, aggregateType: AggregateTypeEnum.WECHAT }).then((res) => { + generateAuthUrl({ orderNo: orderNo as string, aggregateType: CheckoutAggregateEnum.WECHAT }).then((res) => { const url = res.data location.replace(url) }).catch((res) => { @@ -82,7 +84,7 @@ function init() { async function initData() { show.value = true // 获取聚合配置 - getAggregateConfig(orderNo, AggregateTypeEnum.WECHAT).then(({ data }) => { + getAggregateConfig(orderNo, CheckoutAggregateEnum.WECHAT).then(({ data }) => { aggregateInfo.value = data }).catch((res) => { router.push({ name: 'ErrorResult', query: { msg: res.message } }) @@ -107,9 +109,10 @@ function pay() { loading.value = true const from = { orderNo: orderNo as string, + aggregateType: CheckoutAggregateEnum.WECHAT, openId: openId.value, - } as CheckoutPayParam - checkoutPay(from) + } as CheckoutAggregatePayParam + aggregatePay(from) .then(({ data }) => { loading.value = false // 拉起jsapi支付 @@ -141,5 +144,30 @@ function jsapiPay(data: WxJsapiSignResult) { From 7f95a9bec3ab340792c689455cd238d9a051111a Mon Sep 17 00:00:00 2001 From: DaxPay Date: Wed, 4 Dec 2024 19:22:55 +0800 Subject: [PATCH 09/12] =?UTF-8?q?refactor(daxpay):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=94=B6=E9=93=B6=E5=8F=B0=E7=95=8C=E9=9D=A2=E5=92=8C=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E6=B5=81=E7=A8=8B-=20=E6=9B=B4=E6=96=B0=E4=BA=86=20Al?= =?UTF-8?q?ipayAuth=E3=80=81WechatAuth=E3=80=81AlipayCashierCode=E3=80=81W?= =?UTF-8?q?echatCashierCode=E3=80=81AliAggregate=E3=80=81WechatAggregate?= =?UTF-8?q?=20=E5=92=8C=20CheckoutPay=20=E7=BB=84=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E5=92=8C=E6=A0=B7=E5=BC=8F=20-=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BA=86=E6=94=AF=E4=BB=98=E6=B5=81=E7=A8=8B,?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=8A=A0=E8=BD=BD=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=92=8C=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=20-=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=BA=86=E8=AE=A2=E5=8D=95=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E6=96=B9=E5=BC=8F,=E4=BD=BF=E5=85=B6?= =?UTF-8?q?=E6=9B=B4=E5=8A=A0=E6=B8=85=E6=99=B0=E5=92=8C=E8=AF=A6=E7=BB=86?= =?UTF-8?q?=20-=20=E7=BB=9F=E4=B8=80=E4=BA=86=E6=94=AF=E4=BB=98=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=9A=84=E6=A0=B7=E5=BC=8F=E5=92=8C=E8=A1=8C=E4=B8=BA?= =?UTF-8?q?=20-=20=E9=87=8D=E6=9E=84=E4=BA=86=E9=83=A8=E5=88=86=20API=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3,=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=BB?= =?UTF-8?q?=E9=94=AE=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 9 +++ src/styles/vant.less | 7 ++ src/views/daxpay/auth/alipay/AlipayAuth.vue | 8 +-- src/views/daxpay/auth/wechat/WechatAuth.vue | 8 +-- .../cashier/alipay/AlipayCashierCode.vue | 2 +- .../cashier/wechat/WechatCashierCode.vue | 8 +-- src/views/daxpay/checkout/CheckoutPay.api.ts | 6 +- src/views/daxpay/checkout/CheckoutPay.vue | 54 +++++++++++++-- .../daxpay/checkout/alipay/AliAggregate.vue | 59 ++++++----------- .../checkout/wechat/WechatAggregate.vue | 66 +++++++------------ 10 files changed, 117 insertions(+), 110 deletions(-) diff --git a/components.d.ts b/components.d.ts index 4b976c5..b45d7da 100644 --- a/components.d.ts +++ b/components.d.ts @@ -11,8 +11,17 @@ declare module 'vue' { Logo: typeof import('./src/components/Logo.vue')['default'] SvgIcon: typeof import('./src/components/SvgIcon.vue')['default'] VanButton: typeof import('vant/es')['Button'] + VanCell: typeof import('vant/es')['Cell'] + VanCellGroup: typeof import('vant/es')['CellGroup'] + VanCol: typeof import('vant/es')['Col'] VanConfigProvider: typeof import('vant/es')['ConfigProvider'] + VanField: typeof import('vant/es')['Field'] + VanGrid: typeof import('vant/es')['Grid'] + VanGridItem: typeof import('vant/es')['GridItem'] VanLoading: typeof import('vant/es')['Loading'] + VanOverlay: typeof import('vant/es')['Overlay'] + VanRow: typeof import('vant/es')['Row'] + VanSpace: typeof import('vant/es')['Space'] VanSubmitBar: typeof import('vant/es')['SubmitBar'] } } diff --git a/src/styles/vant.less b/src/styles/vant.less index bdc8e22..7f36ed6 100644 --- a/src/styles/vant.less +++ b/src/styles/vant.less @@ -9,3 +9,10 @@ body { .van-action-sheet__cancel { color: var(--van-primary-color) !important; } + +.loading-wrapper { + display: flex; + align-items: center; + justify-content: center; + height: 100%; +} diff --git a/src/views/daxpay/auth/alipay/AlipayAuth.vue b/src/views/daxpay/auth/alipay/AlipayAuth.vue index 4f81b7c..cfb2f9f 100644 --- a/src/views/daxpay/auth/alipay/AlipayAuth.vue +++ b/src/views/daxpay/auth/alipay/AlipayAuth.vue @@ -1,6 +1,6 @@