From 0d5eea8b23aa09279514d87029c9d11207de02c9 Mon Sep 17 00:00:00 2001 From: bootx Date: Sat, 12 Apr 2025 20:55:45 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E7=A0=81=E7=89=8C=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +- src/enums/daxpay/DaxPayEnum.ts | 12 + src/router/base.ts | 28 --- src/router/daxpay.ts | 1 - src/router/index.ts | 3 +- src/views/daxpay/h5/aggregate/Aggregate.vue | 5 +- .../h5/aggregate/alipay/AlipayAggregate.vue | 4 +- .../h5/aggregate/wechat/WechatAggregate.vue | 10 +- src/views/daxpay/h5/cashier/Cashier.vue | 4 +- .../daxpay/h5/checkout/CheckAggregate.vue | 24 -- .../daxpay/h5/checkout/CheckoutPay.api.ts | 213 ------------------ src/views/daxpay/h5/checkout/CheckoutPay.vue | 118 ---------- .../h5/checkout/alipay/AliAggregate.vue | 89 -------- .../h5/checkout/wechat/WechatAggregate.vue | 152 ------------- src/views/daxpay/h5/code/CashierCode.api.ts | 97 ++++---- src/views/daxpay/h5/code/CashierCode.vue | 6 +- .../h5/code/alipay/AlipayCashierCode.vue | 13 +- .../h5/code/wechat/WechatCashierCode.vue | 105 ++++----- src/views/daxpay/h5/result/PayFail.vue | 7 +- 19 files changed, 124 insertions(+), 771 deletions(-) delete mode 100644 src/views/daxpay/h5/checkout/CheckAggregate.vue delete mode 100644 src/views/daxpay/h5/checkout/CheckoutPay.api.ts delete mode 100644 src/views/daxpay/h5/checkout/CheckoutPay.vue delete mode 100644 src/views/daxpay/h5/checkout/alipay/AliAggregate.vue delete mode 100644 src/views/daxpay/h5/checkout/wechat/WechatAggregate.vue diff --git a/.env.development b/.env.development index 68ae6a8..3600806 100644 --- a/.env.development +++ b/.env.development @@ -5,8 +5,8 @@ VITE_PORT=9100 VITE_PUBLIC_PATH=/ # 跨域代理,可以配置多个,请注意不要换行 - VITE_PROXY=[["/server","http://daxpay-api.test.yibeiguangnian.cn/"]] -# VITE_PROXY=[["/server","https://pay1.bootx.cn/"]] +# VITE_PROXY=[["/server","http://daxpay-api.test.yibeiguangnian.cn/"]] + VITE_PROXY=[["/server","http://127.0.0.1:19999/"]] # API 接口地址 VITE_GLOB_API_URL= diff --git a/src/enums/daxpay/DaxPayEnum.ts b/src/enums/daxpay/DaxPayEnum.ts index 1f2784b..6f4b550 100644 --- a/src/enums/daxpay/DaxPayEnum.ts +++ b/src/enums/daxpay/DaxPayEnum.ts @@ -50,3 +50,15 @@ export enum GatewayCallTypeEnum { // 二维码 qr_code = 'qr_code', } + +/** + * 码牌类型 + */ +export enum CashierCodeTypeEnum { + // 微信码牌 + WECHAT_PAY = 'wechat_pay', + // 支付宝码牌 + ALIPAY = 'alipay', + // 云闪付码牌 + UNION_PAY = 'union_pay', +} diff --git a/src/router/base.ts b/src/router/base.ts index c55b8bd..0346edc 100644 --- a/src/router/base.ts +++ b/src/router/base.ts @@ -50,31 +50,3 @@ export const routeModuleList: Array = [ ], }, ] - -/** - * 业务模块路由 - */ -export const BusinessRoute: RouteRecordRaw = { - path: '/', - name: '', - redirect: PageEnum.BASE_HOME, - component: Layout, - children: [ - { - path: '/result/success', - name: 'SuccessResult', - component: () => import('@/views/result/SuccessResult.vue'), - meta: { - title: '操作成功', - }, - }, - { - path: '/result/error', - name: 'ErrorResult', - component: () => import('@/views/result/ErrorResult.vue'), - meta: { - title: '错误页', - }, - }, - ], -} diff --git a/src/router/daxpay.ts b/src/router/daxpay.ts index 81ab180..57071e4 100644 --- a/src/router/daxpay.ts +++ b/src/router/daxpay.ts @@ -131,6 +131,5 @@ export const DaxPayPcRoute: RouteRecordRaw = { title: '支付失败页面', }, }, - ], } diff --git a/src/router/index.ts b/src/router/index.ts index 67b9701..d5a13cd 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,7 +1,7 @@ import type { App } from 'vue' import type { RouteRecordRaw } from 'vue-router' import { createRouter, createWebHistory } from 'vue-router' -import { BusinessRoute, ErrorPageRoute, routeModuleList } from '@/router/base' +import { ErrorPageRoute, routeModuleList } from '@/router/base' import { useRouteStoreWidthOut } from '@/store/modules/route' // 菜单 @@ -12,7 +12,6 @@ export const constantRouter: RouteRecordRaw[] = [ DaxPayH5Route, DaxPayPcRoute, ErrorPageRoute, - BusinessRoute, ] const routeStore = useRouteStoreWidthOut() diff --git a/src/views/daxpay/h5/aggregate/Aggregate.vue b/src/views/daxpay/h5/aggregate/Aggregate.vue index 15d9521..a6adf1b 100644 --- a/src/views/daxpay/h5/aggregate/Aggregate.vue +++ b/src/views/daxpay/h5/aggregate/Aggregate.vue @@ -19,8 +19,9 @@ else if (ua === 'alipay') { } else { router.replace({ - path: '/payFail', - query: { msg: '请使用支付宝、微信等软件进行扫码支付' }, + name: 'payFail', + query: { msg: '请使用支付宝、微信等软件进行扫码支付', title: '操作失败' }, + replace: true, }) } diff --git a/src/views/daxpay/h5/aggregate/alipay/AlipayAggregate.vue b/src/views/daxpay/h5/aggregate/alipay/AlipayAggregate.vue index 619922c..0790f5a 100644 --- a/src/views/daxpay/h5/aggregate/alipay/AlipayAggregate.vue +++ b/src/views/daxpay/h5/aggregate/alipay/AlipayAggregate.vue @@ -110,7 +110,7 @@ function init() { if (code !== 0) { // 如果异常,跳转异常页面 router.replace({ - path: '/payFail', + name: 'payFail', query: { msg }, }) return @@ -147,7 +147,7 @@ function pay() { if (code !== 0) { // 如果异常,跳转异常页面 router.replace({ - path: '/payFail', + name: 'payFail', query: { msg }, }) return diff --git a/src/views/daxpay/h5/aggregate/wechat/WechatAggregate.vue b/src/views/daxpay/h5/aggregate/wechat/WechatAggregate.vue index b5b8eea..147b27b 100644 --- a/src/views/daxpay/h5/aggregate/wechat/WechatAggregate.vue +++ b/src/views/daxpay/h5/aggregate/wechat/WechatAggregate.vue @@ -127,7 +127,7 @@ function init() { if (code !== 0) { // 如果异常,跳转异常页面 router.replace({ - path: '/payFail', + name: 'payFail', query: { msg }, }) return @@ -143,7 +143,7 @@ function init() { if (res.code !== 0) { // 如果异常,跳转异常页面 router.replace({ - path: '/payFail', + name: 'payFail', query: { msg }, }) return @@ -151,7 +151,7 @@ function init() { location.replace(res.data) }).catch((res) => { router.replace({ - path: '/payFail', + name: 'payFail', query: { msg: res.message }, }) }) @@ -188,7 +188,7 @@ async function wxAuth() { await auth(authParam.value).then(({ data }) => { openId.value = data.openId as string }).catch((res) => { - router.push({ name: 'ErrorResult', query: { msg: res.message }, replace: true }) + router.push({ name: 'payFail', query: { msg: res.message }, replace: true }) }) } @@ -237,7 +237,7 @@ function jsapiPay(data: WxJsapiSignResult) { else { // 跳转到失败页面 router.replace({ - path: '/payFail', + name: 'payFail', query: { msg: '支付已取消' }, }) } diff --git a/src/views/daxpay/h5/cashier/Cashier.vue b/src/views/daxpay/h5/cashier/Cashier.vue index 20276e0..11b121b 100644 --- a/src/views/daxpay/h5/cashier/Cashier.vue +++ b/src/views/daxpay/h5/cashier/Cashier.vue @@ -194,7 +194,7 @@ function payClick() { if (code !== 0) { // 如果异常,跳转错误页面 router.replace({ - path: '/payFail', + name: 'payFail', query: { msg }, }) return @@ -284,7 +284,7 @@ function init() { if (code !== 0) { // 如果异常,跳转异常页面 router.replace({ - path: '/payFail', + name: 'payFail', query: { msg }, }) return diff --git a/src/views/daxpay/h5/checkout/CheckAggregate.vue b/src/views/daxpay/h5/checkout/CheckAggregate.vue deleted file mode 100644 index 0bfa3f4..0000000 --- a/src/views/daxpay/h5/checkout/CheckAggregate.vue +++ /dev/null @@ -1,24 +0,0 @@ - - - - - diff --git a/src/views/daxpay/h5/checkout/CheckoutPay.api.ts b/src/views/daxpay/h5/checkout/CheckoutPay.api.ts deleted file mode 100644 index 412a0ae..0000000 --- a/src/views/daxpay/h5/checkout/CheckoutPay.api.ts +++ /dev/null @@ -1,213 +0,0 @@ -import { http } from '@/utils/http/axios' -import type { Result } from '#/axios' -import type { AuthResult } from '@/views/daxpay/h5/auth/ChannelAuth.api' -import type { PayResult } from '@/views/daxpay/h5/aggregate/Aggregate.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 checkoutPay(param: CheckoutPayParam) { - 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, - }) -} - -/** - * 收银台认证链接生成参数 - */ -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 CheckoutAggregatePayParam { - /** 订单号 */ - orderNo?: string - /** 聚合支付类型 */ - aggregateType?: string - /** 唯一标识 */ - openId?: string -} - -/** - * 收银台配置 - */ -export interface CheckoutOrderAndConfigResult { - /** 订单信息 */ - order: CheckoutOrderResult - /** 收银台配置信息 */ - config: CheckoutConfigResult - /** 收银台分类配置信息 */ - groupConfigs: CheckoutGroupConfigResult[] -} - -/** - * 收银台聚合支付配置 - */ -export interface AggregateOrderAndConfigResult { - /** 订单信息 */ - order: CheckoutOrderResult - /** 收银台配置信息 */ - config: CheckoutConfigResult - /** 收银台聚合配置信息 */ - aggregateConfig: AggregateConfigResult -} - -/** - * 订单信息 - */ -export interface CheckoutOrderResult { - /** 商户订单号 */ - bizOrderNo?: string - /** 订单号 */ - orderNo?: string - /** 标题 */ - title?: string - /** 描述 */ - description?: string - /** 金额(元) */ - amount?: number - -} -/** - * 收银台配置信息 - */ -export interface CheckoutConfigResult { - /** 收银台名称 */ - name?: string - /** PC收银台是否同时显示聚合收银码 */ - aggregateShow?: boolean - /** h5收银台自动升级聚合支付 */ - h5AutoUpgrade?: boolean -} - -/** - * 收银台分类配置 - */ -export interface CheckoutGroupConfigResult { - /** 主键 */ - id?: string - /** 名称 */ - name?: string - /** 配置项列表 */ - items?: CheckoutItemConfigResult[] -} - -/** - * 收银台配置项 - */ -export interface CheckoutItemConfigResult { - /** 主键 */ - id?: string - /** 发起调用的类型 */ - callType?: string - /** 名称 */ - name?: string - /** 支付通道 */ - channel?: string - /** 支付方式 */ - payMethod?: string -} - -/** - * 收银台聚合配置信息 - */ -export interface AggregateConfigResult { - /** 支付类型 */ - type?: string - /** 通道 */ - channel?: string - /** 支付方式 */ - payMethod?: string - /** 自动拉起支付 */ - autoLaunch?: boolean -} diff --git a/src/views/daxpay/h5/checkout/CheckoutPay.vue b/src/views/daxpay/h5/checkout/CheckoutPay.vue deleted file mode 100644 index b49c3fc..0000000 --- a/src/views/daxpay/h5/checkout/CheckoutPay.vue +++ /dev/null @@ -1,118 +0,0 @@ - - - - - diff --git a/src/views/daxpay/h5/checkout/alipay/AliAggregate.vue b/src/views/daxpay/h5/checkout/alipay/AliAggregate.vue deleted file mode 100644 index 099503d..0000000 --- a/src/views/daxpay/h5/checkout/alipay/AliAggregate.vue +++ /dev/null @@ -1,89 +0,0 @@ - - - - - diff --git a/src/views/daxpay/h5/checkout/wechat/WechatAggregate.vue b/src/views/daxpay/h5/checkout/wechat/WechatAggregate.vue deleted file mode 100644 index 777c4d2..0000000 --- a/src/views/daxpay/h5/checkout/wechat/WechatAggregate.vue +++ /dev/null @@ -1,152 +0,0 @@ - - - - - diff --git a/src/views/daxpay/h5/code/CashierCode.api.ts b/src/views/daxpay/h5/code/CashierCode.api.ts index 8b39ba0..1bce08d 100644 --- a/src/views/daxpay/h5/code/CashierCode.api.ts +++ b/src/views/daxpay/h5/code/CashierCode.api.ts @@ -1,34 +1,35 @@ import { http } from '@/utils/http/axios' import type { Result } from '#/axios' +import type { AuthResult } from '@/views/daxpay/h5/auth/ChannelAuth.api' /** - * 获取商户名称 + * 获取码牌配置 */ -export function getMchName(cashierCode, cashierType) { - return http.request>({ - url: '/unipay/gateway/getCashierCodeConfig', +export function getCashierCodeConfig(cashierCode, cashierType) { + return http.request>({ + url: '/unipay/gateway/cashier/getCodeConfig', method: 'GET', params: { cashierCode, cashierType }, }) } /** - * 获取收银台信息 + * 获取码牌收银台所需授权链接, 用于获取OpenId一类的信息 */ -export function getCashierInfo(cashierType: string, appId: string) { - return http.request>({ - url: '/unipay/ext/channel/cashier/getCashierType', - method: 'GET', - params: { cashierType, appId }, +export function generateAuthUrl(cashierCode, cashierType) { + return http.request>({ + url: '/unipay/gateway/cashier/code/generateAuthUrl', + method: 'POST', + data: { cashierCode, cashierType }, }) } /** - * 获取收银台所需授权链接, 用于获取OpenId一类的信息 + * 获取授权信息 */ -export function generateAuthUrl(param: CashierAuthParam) { - return http.request>({ - url: '/unipay/ext/channel/cashier/generateAuthUrl', +export function auth(param: CashierCodeAuthParam) { + return http.request>({ + url: '/unipay/gateway/cashier/code/auth', method: 'POST', data: param, }) @@ -39,34 +40,18 @@ export function generateAuthUrl(param: CashierAuthParam) { */ export function cashierPay(param: CashierPayParam) { return http.request>({ - url: '/unipay/gateway/cashierCodePay', + url: '/unipay/gateway/cashier/code/pay', method: 'POST', data: param, }) } -/** - * 通道认证参数 - */ -export interface CashierAuthParam { - // 商户号 - mchNo?: string - // 应用号 - appId?: string - // 收银台类型 - cashierType?: string - // 授权码 - authCode?: string -} /** - * 通道收银支付参数 + * 码牌收银支付参数 */ export interface CashierPayParam { - - // 商户号 - mchNo?: string - // 应用号 - appId?: string + // 收银码牌编码 + cashierCode?: string // 收银台类型 cashierType?: string // 支付金额 @@ -112,31 +97,25 @@ export interface WxJsapiSignResult { /** * 收银台配置信息 */ -export interface ChannelCashierConfigResult { - // 商户号 - mchNo?: string - // 应用号 - appId?: string - // 收银台类型 - cashierType?: string - // 收银台名称 - cashierName?: string - // 支付通道 - channel?: string - // 支付方式 - payMethod?: string - // 是否开启分账 - allocation?: boolean - // 自动分账 - autoAllocation?: boolean +export interface GatewayCashierConfig { + // 商家名称 + name?: string + // 支付调起方式 + callType?: string + // 判断是否需要 + needOpenId?: boolean + // 备注 + remark?: string } -// 码牌支付检查信息 -export interface getNameConfig { - // 商家名称 - name: string - // 判断是否需要 - needOpenId: boolean - // 备注 - remark: string +/** + * 码牌用户标识认证类 + */ +export interface CashierCodeAuthParam { + // 收银码牌编码 + cashierCode?: string + // 收银台类型 + cashierType?: string + // 授权码 + authCode: string } diff --git a/src/views/daxpay/h5/code/CashierCode.vue b/src/views/daxpay/h5/code/CashierCode.vue index 2dd8118..2654ef9 100644 --- a/src/views/daxpay/h5/code/CashierCode.vue +++ b/src/views/daxpay/h5/code/CashierCode.vue @@ -11,6 +11,7 @@ const route = useRoute() const { code } = route.params const ua = getBrowserUA() +console.log(code) if (ua === 'wechat') { router.push({ path: `/wechat/cashier/code/${code}`, replace: true }) } @@ -19,8 +20,9 @@ else if (ua === 'alipay') { } else { router.replace({ - path: '/payFail', - query: { msg: '请使用支付宝、微信等软件进行扫码支付' }, + name: 'payFail', + query: { msg: '请使用支付宝、微信等软件进行扫码支付', title: '操作失败' }, + replace: true, }) } diff --git a/src/views/daxpay/h5/code/alipay/AlipayCashierCode.vue b/src/views/daxpay/h5/code/alipay/AlipayCashierCode.vue index d7c8b99..db9fdcb 100644 --- a/src/views/daxpay/h5/code/alipay/AlipayCashierCode.vue +++ b/src/views/daxpay/h5/code/alipay/AlipayCashierCode.vue @@ -62,10 +62,9 @@ import { onMounted, ref } from 'vue' import { useRoute } from 'vue-router' import { showNotify } from 'vant' -import type { CashierPayParam, getNameConfig } from '../CashierCode.api' -import { cashierPay, getMchName } from '../CashierCode.api' -import { AggregateEnum } from '@/enums/daxpay/DaxPayEnum' -import router from '@/router' +import type { CashierPayParam, GatewayCashierConfig } from '../CashierCode.api' +import { cashierPay, getCashierCodeConfig } from '../CashierCode.api' +import { AggregateEnum, CashierCodeTypeEnum } from '@/enums/daxpay/DaxPayEnum' import { useKeyboard } from '@/hooks/daxpay/useKeyboard' const route = useRoute() @@ -73,7 +72,7 @@ const { code } = route.params const showRemark = ref(false) // 是否展示备注 const loading = ref(false) // 加载状态 -const cashierInfo = ref() +const cashierInfo = ref() const amount = ref('0') // 金额 const description = ref('') // 描述 @@ -89,14 +88,14 @@ onMounted(() => { function initData() { // 获取信息 loading.value = true - getMchName(code, AggregateEnum.ALI) + getCashierCodeConfig(code, CashierCodeTypeEnum.ALIPAY) .then(({ data }) => { loading.value = false cashierInfo.value = data as any }) .catch((error) => { console.log(error) - // router.push({ name: 'ErrorResult', query: { msg: res.message } }) + // router.push({ name: 'payFail', query: { msg: res.message } }) }) } diff --git a/src/views/daxpay/h5/code/wechat/WechatCashierCode.vue b/src/views/daxpay/h5/code/wechat/WechatCashierCode.vue index 09743b9..19bc788 100644 --- a/src/views/daxpay/h5/code/wechat/WechatCashierCode.vue +++ b/src/views/daxpay/h5/code/wechat/WechatCashierCode.vue @@ -1,12 +1,9 @@