From 9adc2a760ae9752a1aebb5946053f176231bba2b Mon Sep 17 00:00:00 2001 From: DaxPay Date: Sun, 29 Sep 2024 18:53:27 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=94=B6=E9=93=B6=E5=8F=B0=E5=BC=80?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 4 +- src/enums/daxpay/DaxPayEnum.ts | 28 +++ src/enums/payment/payChannelEnum.ts | 13 -- src/enums/payment/payMethodEnum.ts | 12 -- src/router/business.ts | 2 +- .../daxpay/channel/ChannelCashier.api.ts | 122 ++++++++++- src/views/daxpay/channel/ChannelCashier.vue | 2 +- .../channel/alipay/cashier/AlipayCashier.vue | 196 +++++++++++++++++- .../channel/wechat/cashier/WechatCashier.vue | 57 +++-- 9 files changed, 380 insertions(+), 56 deletions(-) create mode 100644 src/enums/daxpay/DaxPayEnum.ts delete mode 100644 src/enums/payment/payChannelEnum.ts delete mode 100644 src/enums/payment/payMethodEnum.ts diff --git a/components.d.ts b/components.d.ts index fea5529..b68051a 100644 --- a/components.d.ts +++ b/components.d.ts @@ -10,8 +10,10 @@ declare module 'vue' { Loading: typeof import('./src/components/Loading.vue')['default'] Logo: typeof import('./src/components/Logo.vue')['default'] 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'] } } diff --git a/src/enums/daxpay/DaxPayEnum.ts b/src/enums/daxpay/DaxPayEnum.ts new file mode 100644 index 0000000..6b3c9f2 --- /dev/null +++ b/src/enums/daxpay/DaxPayEnum.ts @@ -0,0 +1,28 @@ +/** + * 支付通道 + */ +export enum ChannelEnum { + ALI = 'ali_pay', + WECHAT = 'wechat_pay', + UNION_PAY = 'union_pay', +} + +/** + * 支付方式 + */ +export enum payMethodEnum { + WAP = 'wap', + APP = 'app', + WEB = 'web', + QRCODE = 'qrcode', + BARCODE = 'barcode', + JSAPI = 'jsapi', +} + +/** + * 收银台类型 + */ +export enum CashierTypeEnum { + WECHAT_PAY = 'wechat_pay', + ALIPAY = 'alipay', +} diff --git a/src/enums/payment/payChannelEnum.ts b/src/enums/payment/payChannelEnum.ts deleted file mode 100644 index 4d12281..0000000 --- a/src/enums/payment/payChannelEnum.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * 支付通道 - */ -export enum payChannelEnum { - ALI = 'ali_pay', - WECHAT = 'wechat_pay', - UNION_PAY = 'union_pay', - CASH = 'cash_pay', - WALLET = 'wallet_pay', - VOUCHER = 'voucher_pay', - CREDIT_CARD = 'credit_pay', - AGGREGATION = 'aggregation_pay', -} diff --git a/src/enums/payment/payMethodEnum.ts b/src/enums/payment/payMethodEnum.ts deleted file mode 100644 index 2eb7222..0000000 --- a/src/enums/payment/payMethodEnum.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * 支付通道 - */ -export enum payMethodEnum { - NORMAL = 'normal', - WAP = 'wap', - APP = 'app', - WEB = 'web', - QRCODE = 'qrcode', - BARCODE = 'barcode', - JSAPI = 'jsapi', -} diff --git a/src/router/business.ts b/src/router/business.ts index 90dc0bc..5e3d281 100644 --- a/src/router/business.ts +++ b/src/router/business.ts @@ -25,7 +25,7 @@ export const BusinessRoute: RouteRecordRaw = { name: 'SuccessResult', component: () => import('@/views/result/SuccessResult.vue'), meta: { - title: '支付成功', + title: '操作成功', }, }, { diff --git a/src/views/daxpay/channel/ChannelCashier.api.ts b/src/views/daxpay/channel/ChannelCashier.api.ts index dd11827..eae49dd 100644 --- a/src/views/daxpay/channel/ChannelCashier.api.ts +++ b/src/views/daxpay/channel/ChannelCashier.api.ts @@ -1,14 +1,54 @@ import { http } from '@/utils/http/axios' import type { Result } from '#/axios' +/** + * 获取商户名称 + */ +export function getMchName(mchNo: string) { + return http.request>({ + url: '/unipay/ext/channel/cashier/getMchName', + method: 'GET', + params: { mchNo }, + }) +} + +/** + * 获取收银台信息 + */ +export function getCashierInfo(cashierType: string, appId: string) { + return http.request>({ + url: '/unipay/ext/channel/cashier/getCashierType', + method: 'GET', + params: { cashierType, appId }, + }) +} + +/** + * 获取收银台所需授权链接, 用于获取OpenId一类的信息 + */ +export function generateAuthUrl(param: CashierAuthCodeParam) { + return http.request>({ + url: '/unipay/ext/channel/cashier/authCode', + method: 'POST', + data: param, + }) +} + +/** + * 发起支付 + */ +export function cashierPay(param: CashierPayParam) { + return http.request>({ + url: '/unipay/ext/channel/cashier/pay', + method: 'POST', + data: param, + }) +} + /** * 通道认证参数 */ export interface CashierAuthCodeParam { - // 标识码 - authCode?: string - // 查询Code - queryCode?: string // 商户号 mchNo?: string // 应用号 @@ -16,3 +56,77 @@ export interface CashierAuthCodeParam { // 收银台类型 cashierType?: string } + +/** + * 通道收银支付参数 + */ +export interface CashierPayParam { + + // 商户号 + mchNo?: string + // 应用号 + appId?: string + // 收银台类型 + cashierType?: string + // 支付金额 + amount?: number + // 标识码 + authCode?: string + // 支付描述 + description?: string +} + +/** + * 支付结果 + */ +export interface PayResult { + + // 支付状态 + status: string + // 支付参数体 + payBody: string + // 商户订单号 + bizOrderNo: string + // 订单号 + orderNo: string +} + +/** + * 微信Jsapi预支付签名返回信息 + */ +export interface WxJsapiSignResult { + // 公众号ID,由商户传入 + appId?: string + // 时间戳,自1970年以来的秒数 + timeStamp?: string + // 随机串 + nonceStr?: string + // 预支付ID + package?: string + // 微信签名方式: + signType?: string + // 微信签名 + paySign?: string +} + +/** + * 收银台配置信息 + */ +export interface ChannelCashierConfigResult { + // 商户号 + mchNo?: string + // 应用号 + appId?: string + // 收银台类型 + cashierType?: string + // 收银台名称 + cashierName?: string + // 支付通道 + channel?: string + // 支付方式 + payMethod?: string + // 是否开启分账 + allocation?: boolean + // 自动分账 + autoAllocation?: boolean +} diff --git a/src/views/daxpay/channel/ChannelCashier.vue b/src/views/daxpay/channel/ChannelCashier.vue index 9d2c839..c99c4f0 100644 --- a/src/views/daxpay/channel/ChannelCashier.vue +++ b/src/views/daxpay/channel/ChannelCashier.vue @@ -13,8 +13,8 @@ - diff --git a/src/views/daxpay/channel/wechat/cashier/WechatCashier.vue b/src/views/daxpay/channel/wechat/cashier/WechatCashier.vue index c2e8420..0f963a4 100644 --- a/src/views/daxpay/channel/wechat/cashier/WechatCashier.vue +++ b/src/views/daxpay/channel/wechat/cashier/WechatCashier.vue @@ -1,11 +1,30 @@