mirror of
https://gitee.com/bootx/dax-pay-h5.git
synced 2025-10-13 13:43:53 +00:00
@@ -1,12 +1,12 @@
|
|||||||
# 独立部署模式
|
# 独立部署模式
|
||||||
VITE_PUBLIC_PATH=
|
#VITE_PUBLIC_PATH=
|
||||||
# API 接口前缀
|
# API 接口前缀
|
||||||
VITE_GLOB_API_URL_PREFIX=/api
|
#VITE_GLOB_API_URL_PREFIX=/api
|
||||||
|
|
||||||
# 嵌入式模式 与后端部署在一起
|
# 嵌入式模式 与后端部署在一起
|
||||||
#VITE_PUBLIC_PATH=/h5
|
VITE_PUBLIC_PATH=/h5
|
||||||
# API 接口前缀
|
# API 接口前缀
|
||||||
#VITE_GLOB_API_URL_PREFIX=
|
VITE_GLOB_API_URL_PREFIX=
|
||||||
|
|
||||||
# 是否删除console
|
# 是否删除console
|
||||||
VITE_DROP_CONSOLE=true
|
VITE_DROP_CONSOLE=true
|
||||||
|
4
components.d.ts
vendored
4
components.d.ts
vendored
@@ -11,12 +11,16 @@ declare module 'vue' {
|
|||||||
Logo: typeof import('./src/components/Logo.vue')['default']
|
Logo: typeof import('./src/components/Logo.vue')['default']
|
||||||
SvgIcon: typeof import('./src/components/SvgIcon.vue')['default']
|
SvgIcon: typeof import('./src/components/SvgIcon.vue')['default']
|
||||||
VanButton: typeof import('vant/es')['Button']
|
VanButton: typeof import('vant/es')['Button']
|
||||||
|
VanCell: typeof import('vant/es')['Cell']
|
||||||
|
VanCellGroup: typeof import('vant/es')['CellGroup']
|
||||||
VanConfigProvider: typeof import('vant/es')['ConfigProvider']
|
VanConfigProvider: typeof import('vant/es')['ConfigProvider']
|
||||||
VanDialog: typeof import('vant/es')['Dialog']
|
VanDialog: typeof import('vant/es')['Dialog']
|
||||||
VanField: typeof import('vant/es')['Field']
|
VanField: typeof import('vant/es')['Field']
|
||||||
VanLoading: typeof import('vant/es')['Loading']
|
VanLoading: typeof import('vant/es')['Loading']
|
||||||
VanNumberKeyboard: typeof import('vant/es')['NumberKeyboard']
|
VanNumberKeyboard: typeof import('vant/es')['NumberKeyboard']
|
||||||
VanOverlay: typeof import('vant/es')['Overlay']
|
VanOverlay: typeof import('vant/es')['Overlay']
|
||||||
|
VanSpace: typeof import('vant/es')['Space']
|
||||||
|
VanSubmitBar: typeof import('vant/es')['SubmitBar']
|
||||||
VanTextEllipsis: typeof import('vant/es')['TextEllipsis']
|
VanTextEllipsis: typeof import('vant/es')['TextEllipsis']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
40
package.json
40
package.json
@@ -3,7 +3,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.12.0",
|
"node": ">=20.6.0",
|
||||||
"pnpm": ">=9.0.2"
|
"pnpm": ">=9.0.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -27,62 +27,62 @@
|
|||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@unocss/reset": "^0.58.9",
|
"@unocss/reset": "^0.58.9",
|
||||||
"@vueuse/core": "^10.11.1",
|
"@vueuse/core": "^10.11.1",
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.7.9",
|
||||||
"date-fns": "^3.6.0",
|
"date-fns": "^3.6.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"pinia": "^2.2.2",
|
"pinia": "^2.3.0",
|
||||||
"pinia-plugin-persist": "^1.0.0",
|
"pinia-plugin-persist": "^1.0.0",
|
||||||
"qs": "^6.13.0",
|
"qs": "^6.13.1",
|
||||||
"vant": "^4.9.7",
|
"vant": "^4.9.10",
|
||||||
"vue": "^3.5.8",
|
"vue": "^3.5.13",
|
||||||
"vue-router": "4.2.5"
|
"vue-router": "4.2.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@antfu/eslint-config": "^2.27.3",
|
"@antfu/eslint-config": "^2.27.3",
|
||||||
"@commitlint/cli": "^18.6.1",
|
"@commitlint/cli": "^18.6.1",
|
||||||
"@commitlint/config-conventional": "^18.6.3",
|
"@commitlint/config-conventional": "^18.6.3",
|
||||||
"@iconify/json": "^2.2.252",
|
"@iconify/json": "^2.2.281",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/mockjs": "^1.0.10",
|
"@types/mockjs": "^1.0.10",
|
||||||
"@types/node": "^20.16.5",
|
"@types/node": "^20.17.9",
|
||||||
"@types/nprogress": "^0.2.3",
|
"@types/nprogress": "^0.2.3",
|
||||||
"@types/qs": "^6.9.16",
|
"@types/qs": "^6.9.17",
|
||||||
"@unocss/eslint-plugin": "^0.58.9",
|
"@unocss/eslint-plugin": "^0.58.9",
|
||||||
"@unocss/preset-icons": "^0.58.9",
|
"@unocss/preset-icons": "^0.58.9",
|
||||||
"@unocss/preset-rem-to-px": "^0.58.9",
|
"@unocss/preset-rem-to-px": "^0.58.9",
|
||||||
"@unocss/transformer-directives": "^0.58.9",
|
"@unocss/transformer-directives": "^0.58.9",
|
||||||
"@unocss/transformer-variant-group": "^0.58.9",
|
"@unocss/transformer-variant-group": "^0.58.9",
|
||||||
"@vitejs/plugin-vue": "^5.1.4",
|
"@vitejs/plugin-vue": "^5.2.1",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"cz-git": "^1.9.4",
|
"cz-git": "^1.11.0",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.7",
|
||||||
"eslint": "^8.57.1",
|
"eslint": "^8.57.1",
|
||||||
"eslint-plugin-format": "^0.1.2",
|
"eslint-plugin-format": "^0.1.3",
|
||||||
"esno": "^0.16.3",
|
"esno": "^0.16.3",
|
||||||
"fs-extra": "^11.2.0",
|
"fs-extra": "^11.2.0",
|
||||||
"less": "^4.2.0",
|
"less": "^4.2.1",
|
||||||
"lint-staged": "^15.2.10",
|
"lint-staged": "^15.2.10",
|
||||||
"only-allow": "^1.2.1",
|
"only-allow": "^1.2.1",
|
||||||
"picocolors": "^1.1.0",
|
"picocolors": "^1.1.1",
|
||||||
"postcss": "^8.4.47",
|
"postcss": "^8.4.49",
|
||||||
"postcss-mobile-forever": "^4.1.6",
|
"postcss-mobile-forever": "^4.3.1",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rollup": "^4.22.4",
|
"rollup": "^4.28.1",
|
||||||
"rollup-plugin-visualizer": "^5.12.0",
|
"rollup-plugin-visualizer": "^5.12.0",
|
||||||
"simple-git-hooks": "^2.11.1",
|
"simple-git-hooks": "^2.11.1",
|
||||||
"typescript": "^5.6.2",
|
"typescript": "^5.7.2",
|
||||||
"unocss": "^0.58.9",
|
"unocss": "^0.58.9",
|
||||||
"unplugin-auto-import": "^0.17.8",
|
"unplugin-auto-import": "^0.17.8",
|
||||||
"unplugin-vue-components": "^0.26.0",
|
"unplugin-vue-components": "^0.26.0",
|
||||||
"vconsole": "^3.15.1",
|
"vconsole": "^3.15.1",
|
||||||
"vite-plugin-vconsole": "^2.1.1",
|
|
||||||
"vite": "5.4.6",
|
"vite": "5.4.6",
|
||||||
"vite-plugin-compression": "^0.5.1",
|
"vite-plugin-compression": "^0.5.1",
|
||||||
"vite-plugin-html": "^3.2.2",
|
"vite-plugin-html": "^3.2.2",
|
||||||
"vite-plugin-mock": "^2.9.8",
|
"vite-plugin-mock": "^2.9.8",
|
||||||
"vite-plugin-svg-icons": "^2.0.1",
|
"vite-plugin-svg-icons": "^2.0.1",
|
||||||
|
"vite-plugin-vconsole": "^2.1.1",
|
||||||
"vue-tsc": "^1.8.27"
|
"vue-tsc": "^1.8.27"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
|
2440
pnpm-lock.yaml
generated
2440
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ export enum ChannelEnum {
|
|||||||
/**
|
/**
|
||||||
* 支付方式
|
* 支付方式
|
||||||
*/
|
*/
|
||||||
export enum payMethodEnum {
|
export enum PayMethodEnum {
|
||||||
WAP = 'wap',
|
WAP = 'wap',
|
||||||
APP = 'app',
|
APP = 'app',
|
||||||
WEB = 'web',
|
WEB = 'web',
|
||||||
@@ -26,3 +26,21 @@ export enum CashierTypeEnum {
|
|||||||
WECHAT_PAY = 'wechat_pay',
|
WECHAT_PAY = 'wechat_pay',
|
||||||
ALIPAY = 'alipay',
|
ALIPAY = 'alipay',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收银台类型
|
||||||
|
*/
|
||||||
|
export enum CheckoutTypeEnum {
|
||||||
|
H5 = 'h5',
|
||||||
|
PC = 'pc',
|
||||||
|
MINI_APP = 'mini_app',
|
||||||
|
AGGREGATE = 'aggregate',
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收银台聚合支付类型
|
||||||
|
*/
|
||||||
|
export enum CheckoutAggregateEnum {
|
||||||
|
ALI = 'alipay',
|
||||||
|
WECHAT = 'wechat_pay',
|
||||||
|
}
|
||||||
|
@@ -11,7 +11,7 @@ export const DaxPayRoute: RouteRecordRaw = {
|
|||||||
component: Layout,
|
component: Layout,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '/alipay/auth/:appId/:channel/:queryCode/:aliAppId',
|
path: '/auth/alipay/:appId/:channel/:queryCode/:aliAppId',
|
||||||
name: 'AlipayAuth',
|
name: 'AlipayAuth',
|
||||||
component: () => import('@/views/daxpay/auth/alipay/AlipayAuth.vue'),
|
component: () => import('@/views/daxpay/auth/alipay/AlipayAuth.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
@@ -19,7 +19,7 @@ export const DaxPayRoute: RouteRecordRaw = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/wechat/auth/:appId/:channel/:queryCode',
|
path: '/auth/wechat/:appId/:channel/:queryCode',
|
||||||
name: 'WechatAuth',
|
name: 'WechatAuth',
|
||||||
component: () => import('@/views/daxpay/auth/wechat/WechatAuth.vue'),
|
component: () => import('@/views/daxpay/auth/wechat/WechatAuth.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
@@ -27,28 +27,60 @@ export const DaxPayRoute: RouteRecordRaw = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/channel/cashier/:appId',
|
path: '/cashier/:code',
|
||||||
name: 'ChannelCashier',
|
name: 'CashierCode',
|
||||||
component: () => import('@/views/daxpay/cashier/ChannelCashier.vue'),
|
component: () => import('@/views/daxpay/cashier/CashierCode.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '收银台',
|
title: '收银台',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/alipay/cashier/:appId',
|
path: '/cashier/alipay/:code',
|
||||||
name: 'AlipayCashier',
|
name: 'AlipayCashierCode',
|
||||||
component: () => import('@/views/daxpay/cashier/alipay/AlipayCashier.vue'),
|
component: () => import('@/views/daxpay/cashier/alipay/AlipayCashierCode.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '支付宝收银台',
|
title: '支付宝收银台',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/wechat/cashier/:appId',
|
path: '/cashier/wechat/:code',
|
||||||
name: 'WechatCashier',
|
name: 'WechatCashierCode',
|
||||||
component: () => import('@/views/daxpay/cashier/wechat/WechatCashier.vue'),
|
component: () => import('@/views/daxpay/cashier/wechat/WechatCashierCode.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '微信收银台',
|
title: '微信收银台',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/checkout/:orderNo',
|
||||||
|
name: 'CheckoutPay',
|
||||||
|
component: () => import('@/views/daxpay/checkout/CheckoutPay.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '手机收银台',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/aggregate/:orderNo',
|
||||||
|
name: 'CheckAggregate',
|
||||||
|
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: '支付宝收银台',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/aggregate/wechat/:orderNo',
|
||||||
|
name: 'WechatCheckout',
|
||||||
|
component: () => import('@/views/daxpay/checkout/wechat/WechatAggregate.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '微信结算台',
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@@ -9,3 +9,10 @@ body {
|
|||||||
.van-action-sheet__cancel {
|
.van-action-sheet__cancel {
|
||||||
color: var(--van-primary-color) !important;
|
color: var(--van-primary-color) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loading-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<van-overlay v-show="show" :show="true">
|
<van-overlay v-show="show" :show="true">
|
||||||
<div class="wrapper" @click.stop>
|
<div class="loading-wrapper" @click.stop>
|
||||||
<van-loading size="24px">
|
<van-loading size="24px">
|
||||||
获取中...
|
获取中...
|
||||||
</van-loading>
|
</van-loading>
|
||||||
@@ -60,12 +60,6 @@ async function init() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.wrapper {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.block {
|
.block {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<van-overlay v-show="show" :show="true">
|
<van-overlay v-show="show" :show="true">
|
||||||
<div class="wrapper" @click.stop>
|
<div class="loading-wrapper" @click.stop>
|
||||||
<van-loading size="24px">
|
<van-loading size="24px">
|
||||||
获取中...
|
获取中...
|
||||||
</van-loading>
|
</van-loading>
|
||||||
@@ -47,12 +47,6 @@ async function init() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.wrapper {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.block {
|
.block {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
|
@@ -2,24 +2,23 @@ import type { AuthResult } from '../auth/ChannelAuth.api'
|
|||||||
import { http } from '@/utils/http/axios'
|
import { http } from '@/utils/http/axios'
|
||||||
import type { Result } from '#/axios'
|
import type { Result } from '#/axios'
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取收银台信息
|
* 获取收银台配置信息
|
||||||
*/
|
*/
|
||||||
export function getCashierInfo(cashierType: string, appId: string) {
|
export function getCashierTypeConfig(cashierType: string, cashierCode: string) {
|
||||||
return http.request<Result<ChannelCashierConfigResult>>({
|
return http.request<Result<CashierTypeConfigResult>>({
|
||||||
url: '/unipay/ext/channel/cashier/getCashierType',
|
url: '/unipay/cashier/code/findByCashierType',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
params: { cashierType, appId },
|
params: { cashierType, cashierCode },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取收银台所需授权链接, 用于获取OpenId一类的信息
|
* 获取收银台所需授权链接, 用于获取OpenId一类的信息
|
||||||
*/
|
*/
|
||||||
export function generateAuthUrl(param: CashierAuthParam) {
|
export function generateAuthUrl(param: CashierAuthUrlParam) {
|
||||||
return http.request<Result<string>>({
|
return http.request<Result<string>>({
|
||||||
url: '/unipay/ext/channel/cashier/generateAuthUrl',
|
url: '/unipay/cashier/code/generateAuthUrl',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: param,
|
data: param,
|
||||||
})
|
})
|
||||||
@@ -28,9 +27,9 @@ export function generateAuthUrl(param: CashierAuthParam) {
|
|||||||
/**
|
/**
|
||||||
* 获取授权信息
|
* 获取授权信息
|
||||||
*/
|
*/
|
||||||
export function auth(param: CashierPayParam) {
|
export function auth(param: CashierAuthParam) {
|
||||||
return http.request<Result<AuthResult>>({
|
return http.request<Result<AuthResult>>({
|
||||||
url: '/unipay/ext/channel/cashier/auth',
|
url: '/unipay/cashier/code/auth',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: param,
|
data: param,
|
||||||
})
|
})
|
||||||
@@ -41,18 +40,28 @@ export function auth(param: CashierPayParam) {
|
|||||||
*/
|
*/
|
||||||
export function cashierPay(param: CashierPayParam) {
|
export function cashierPay(param: CashierPayParam) {
|
||||||
return http.request<Result<PayResult>>({
|
return http.request<Result<PayResult>>({
|
||||||
url: '/unipay/ext/channel/cashier/pay',
|
url: '/unipay/cashier/code/pay',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: param,
|
data: param,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通道认证参数
|
* 获取认证URL参数
|
||||||
|
*/
|
||||||
|
export interface CashierAuthUrlParam {
|
||||||
|
// 应用号
|
||||||
|
cashierCode?: string
|
||||||
|
// 收银台类型
|
||||||
|
cashierType?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 认证参数
|
||||||
*/
|
*/
|
||||||
export interface CashierAuthParam {
|
export interface CashierAuthParam {
|
||||||
// 应用号
|
// 应用号
|
||||||
appId?: string
|
cashierCode?: string
|
||||||
// 收银台类型
|
// 收银台类型
|
||||||
cashierType?: string
|
cashierType?: string
|
||||||
// 授权码
|
// 授权码
|
||||||
@@ -64,7 +73,7 @@ export interface CashierAuthParam {
|
|||||||
*/
|
*/
|
||||||
export interface CashierPayParam {
|
export interface CashierPayParam {
|
||||||
// 应用号
|
// 应用号
|
||||||
appId?: string
|
cashierCode?: string
|
||||||
// 收银台类型
|
// 收银台类型
|
||||||
cashierType?: string
|
cashierType?: string
|
||||||
// 支付金额
|
// 支付金额
|
||||||
@@ -79,7 +88,6 @@ export interface CashierPayParam {
|
|||||||
* 支付结果
|
* 支付结果
|
||||||
*/
|
*/
|
||||||
export interface PayResult {
|
export interface PayResult {
|
||||||
|
|
||||||
// 支付状态
|
// 支付状态
|
||||||
status: string
|
status: string
|
||||||
// 支付参数体
|
// 支付参数体
|
||||||
@@ -109,21 +117,17 @@ export interface WxJsapiSignResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 收银台配置信息
|
* 收银码牌配置信息
|
||||||
*/
|
*/
|
||||||
export interface ChannelCashierConfigResult {
|
export interface CashierTypeConfigResult {
|
||||||
// 应用号
|
// 应用号
|
||||||
appId?: string
|
appId?: string
|
||||||
// 收银台类型
|
// 码牌名称
|
||||||
cashierType?: string
|
name?: string
|
||||||
// 收银台名称
|
|
||||||
cashierName?: string
|
|
||||||
// 支付通道
|
// 支付通道
|
||||||
channel?: string
|
channel?: string
|
||||||
// 支付方式
|
// 支付方式
|
||||||
payMethod?: string
|
payMethod?: string
|
||||||
// 是否开启分账
|
// 是否开启分账
|
||||||
allocation?: boolean
|
allocation?: boolean
|
||||||
// 自动分账
|
|
||||||
autoAllocation?: boolean
|
|
||||||
}
|
}
|
@@ -6,17 +6,17 @@ import { useRoute } from 'vue-router'
|
|||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { appId } = route.params
|
const { code } = route.params
|
||||||
|
|
||||||
const ua = navigator.userAgent
|
const ua = navigator.userAgent
|
||||||
if (ua.includes('MicroMessenger')) {
|
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')) {
|
else if (ua.includes('Alipay')) {
|
||||||
router.push({ path: `/alipay/cashier/${appId}`, replace: true })
|
router.push({ path: `/cashier/alipay/${code}`, replace: true })
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等支付程序进行扫码支付' }, replace: true })
|
router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等软件进行扫码支付' }, replace: true })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@@ -2,7 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div style="font-size: 28px;margin-top: 10px;">
|
<div style="font-size: 28px;margin-top: 10px;">
|
||||||
{{ cashierInfo.cashierName || '支付宝收银台' }}
|
{{ cashierTypeConfig.name || '支付宝收银台' }}
|
||||||
</div>
|
</div>
|
||||||
<div class="amount-display">
|
<div class="amount-display">
|
||||||
<p style="font-size: 20px">
|
<p style="font-size: 20px">
|
||||||
@@ -65,23 +65,23 @@ import { useRoute } from 'vue-router'
|
|||||||
import { showNotify } from 'vant'
|
import { showNotify } from 'vant'
|
||||||
import type {
|
import type {
|
||||||
CashierPayParam,
|
CashierPayParam,
|
||||||
ChannelCashierConfigResult,
|
CashierTypeConfigResult,
|
||||||
} from '@/views/daxpay/cashier/ChannelCashier.api'
|
} from '@/views/daxpay/cashier/CashierCode.api'
|
||||||
import {
|
import {
|
||||||
cashierPay,
|
cashierPay,
|
||||||
getCashierInfo,
|
getCashierTypeConfig,
|
||||||
} from '@/views/daxpay/cashier/ChannelCashier.api'
|
} from '@/views/daxpay/cashier/CashierCode.api'
|
||||||
|
|
||||||
import { CashierTypeEnum } from '@/enums/daxpay/DaxPayEnum'
|
import { CashierTypeEnum } from '@/enums/daxpay/DaxPayEnum'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { useKeyboard } from '@/hooks/daxpay/useKeyboard'
|
import { useKeyboard } from '@/hooks/daxpay/useKeyboard'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { appId } = route.params
|
const { code } = route.params
|
||||||
|
|
||||||
const showRemark = ref<boolean>(false)
|
const showRemark = ref<boolean>(false)
|
||||||
const loading = ref<boolean>(false)
|
const loading = ref<boolean>(false)
|
||||||
const cashierInfo = ref<ChannelCashierConfigResult>({})
|
const cashierTypeConfig = ref<CashierTypeConfigResult>({})
|
||||||
const amount = ref<string>('0')
|
const amount = ref<string>('0')
|
||||||
const description = ref<string>('')
|
const description = ref<string>('')
|
||||||
|
|
||||||
@@ -95,10 +95,10 @@ onMounted(() => {
|
|||||||
* 初始化数据
|
* 初始化数据
|
||||||
*/
|
*/
|
||||||
function initData() {
|
function initData() {
|
||||||
getCashierInfo(CashierTypeEnum.ALIPAY, appId as string).then(({ data }) => {
|
getCashierTypeConfig(CashierTypeEnum.ALIPAY, code as string).then(({ data }) => {
|
||||||
cashierInfo.value = data
|
cashierTypeConfig.value = data
|
||||||
}).catch((res) => {
|
}).catch((res) => {
|
||||||
router.push({ name: 'ErrorResult', query: { msg: res.message } })
|
router.push({ name: 'ErrorResult', query: { msg: res.message }, replace: true })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ function pay() {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
const from = {
|
const from = {
|
||||||
amount: amountValue,
|
amount: amountValue,
|
||||||
appId,
|
cashierCode: code,
|
||||||
cashierType: CashierTypeEnum.ALIPAY,
|
cashierType: CashierTypeEnum.ALIPAY,
|
||||||
description: description.value,
|
description: description.value,
|
||||||
} as CashierPayParam
|
} as CashierPayParam
|
@@ -2,7 +2,7 @@
|
|||||||
<div v-if="show">
|
<div v-if="show">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div style="font-size: 28px;margin-top: 10px;">
|
<div style="font-size: 28px;margin-top: 10px;">
|
||||||
{{ cashierInfo.cashierName || '微信收银台' }}
|
{{ cashierTypeConfig.name || '微信收银台' }}
|
||||||
</div>
|
</div>
|
||||||
<div class="amount-display">
|
<div class="amount-display">
|
||||||
<p style="font-size: 20px">
|
<p style="font-size: 20px">
|
||||||
@@ -66,38 +66,37 @@ import { showNotify } from 'vant'
|
|||||||
import type {
|
import type {
|
||||||
CashierAuthParam,
|
CashierAuthParam,
|
||||||
CashierPayParam,
|
CashierPayParam,
|
||||||
ChannelCashierConfigResult,
|
CashierTypeConfigResult,
|
||||||
WxJsapiSignResult,
|
WxJsapiSignResult,
|
||||||
} from '@/views/daxpay/cashier/ChannelCashier.api'
|
} from '@/views/daxpay/cashier/CashierCode.api'
|
||||||
import {
|
import {
|
||||||
auth
|
auth
|
||||||
, cashierPay,
|
, cashierPay,
|
||||||
generateAuthUrl,
|
generateAuthUrl,
|
||||||
getCashierInfo,
|
getCashierTypeConfig,
|
||||||
} from '@/views/daxpay/cashier/ChannelCashier.api'
|
} from '@/views/daxpay/cashier/CashierCode.api'
|
||||||
|
|
||||||
import { CashierTypeEnum } from '@/enums/daxpay/DaxPayEnum'
|
import { CashierTypeEnum } from '@/enums/daxpay/DaxPayEnum'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { useKeyboard } from '@/hooks/daxpay/useKeyboard'
|
import { useKeyboard } from '@/hooks/daxpay/useKeyboard'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { appId } = route.params
|
const { code } = route.params
|
||||||
const { code } = route.query
|
const { code: authCode } = route.query
|
||||||
|
|
||||||
const show = ref<boolean>(false)
|
const show = ref<boolean>(false)
|
||||||
const showRemark = ref<boolean>(false)
|
const showRemark = ref<boolean>(false)
|
||||||
const loading = ref<boolean>(false)
|
const loading = ref<boolean>(false)
|
||||||
const cashierInfo = ref<ChannelCashierConfigResult>({})
|
const cashierTypeConfig = ref<CashierTypeConfigResult>({})
|
||||||
const amount = ref<string>('0')
|
const amount = ref<string>('0')
|
||||||
const description = ref<string>('')
|
const description = ref<string>('')
|
||||||
const openId = ref<string>('')
|
const openId = ref<string>('')
|
||||||
|
|
||||||
// 认证参数
|
// 认证参数
|
||||||
const authParam = ref<CashierAuthParam>({
|
const authParam = ref<CashierAuthParam>({
|
||||||
appId: appId as string,
|
cashierCode: code as string,
|
||||||
cashierType: CashierTypeEnum.WECHAT_PAY,
|
cashierType: CashierTypeEnum.WECHAT_PAY,
|
||||||
})
|
})
|
||||||
|
|
||||||
const { input, del } = useKeyboard(amount)
|
const { input, del } = useKeyboard(amount)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -105,21 +104,21 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化
|
* 进入页面的初始化
|
||||||
*/
|
*/
|
||||||
function init() {
|
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
|
const url = res.data
|
||||||
location.replace(url)
|
location.replace(url)
|
||||||
}).catch((res) => {
|
}).catch((res) => {
|
||||||
router.push({ name: 'ErrorResult', query: { msg: res.message } })
|
router.push({ name: 'ErrorResult', query: { msg: res.message }, replace: true })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
authParam.value.authCode = code as string
|
authParam.value.authCode = authCode as string
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
initData()
|
initData()
|
||||||
}
|
}
|
||||||
@@ -130,15 +129,18 @@ function init() {
|
|||||||
*/
|
*/
|
||||||
function initData() {
|
function initData() {
|
||||||
show.value = true
|
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) => {
|
}).catch((res) => {
|
||||||
router.push({ name: 'ErrorResult', query: { msg: res.message } })
|
router.push({ name: 'ErrorResult', query: { msg: res.message }, replace: true })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 认证获取OpenId
|
||||||
auth(authParam.value).then(({ data }) => {
|
auth(authParam.value).then(({ data }) => {
|
||||||
openId.value = data.openId as string
|
openId.value = data.openId as string
|
||||||
}).catch((res) => {
|
}).catch((res) => {
|
||||||
router.push({ name: 'ErrorResult', query: { msg: res.message } })
|
router.push({ name: 'ErrorResult', query: { msg: res.message }, replace: true })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,8 +156,8 @@ function pay() {
|
|||||||
|
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const from = {
|
const from = {
|
||||||
|
cashierCode: code,
|
||||||
amount: amountValue,
|
amount: amountValue,
|
||||||
appId,
|
|
||||||
openId: openId.value,
|
openId: openId.value,
|
||||||
cashierType: CashierTypeEnum.WECHAT_PAY,
|
cashierType: CashierTypeEnum.WECHAT_PAY,
|
||||||
description: description.value,
|
description: description.value,
|
24
src/views/daxpay/checkout/CheckAggregate.vue
Normal file
24
src/views/daxpay/checkout/CheckAggregate.vue
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<template>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const { orderNo } = route.params
|
||||||
|
|
||||||
|
const ua = navigator.userAgent
|
||||||
|
if (ua.includes('MicroMessenger')) {
|
||||||
|
router.push({ path: `/aggregate/wechat/${orderNo}`, replace: true })
|
||||||
|
}
|
||||||
|
else if (ua.includes('Alipay')) {
|
||||||
|
router.push({ path: `/aggregate/alipay/${orderNo}`, replace: true })
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
router.push({ name: 'ErrorResult', query: { msg: '请使用支付宝、微信等软件进行扫码支付' }, replace: true })
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
</style>
|
213
src/views/daxpay/checkout/CheckoutPay.api.ts
Normal file
213
src/views/daxpay/checkout/CheckoutPay.api.ts
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
import { http } from '@/utils/http/axios'
|
||||||
|
import type { Result } from '#/axios'
|
||||||
|
import type { AuthResult } from '@/views/daxpay/auth/ChannelAuth.api'
|
||||||
|
import type { PayResult } from '@/views/daxpay/cashier/CashierCode.api'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取收银台订单和配置信息
|
||||||
|
*/
|
||||||
|
export function getOrderAndConfig(orderNo, checkoutType) {
|
||||||
|
return http.request<Result<CheckoutOrderAndConfigResult>>({
|
||||||
|
url: '/unipay/checkout/getOrderAndConfig',
|
||||||
|
method: 'GET',
|
||||||
|
params: {
|
||||||
|
orderNo,
|
||||||
|
checkoutType,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取聚合支付配置
|
||||||
|
*/
|
||||||
|
export function getAggregateConfig(orderNo, aggregateType) {
|
||||||
|
return http.request<Result<AggregateOrderAndConfigResult>>({
|
||||||
|
url: '/unipay/checkout/getAggregateConfig',
|
||||||
|
method: 'GET',
|
||||||
|
params: {
|
||||||
|
orderNo,
|
||||||
|
aggregateType,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取收银台所需授权链接, 用于获取OpenId一类的信息
|
||||||
|
*/
|
||||||
|
export function generateAuthUrl(param: CheckoutAuthUrlParam) {
|
||||||
|
return http.request<Result<string>>({
|
||||||
|
url: '/unipay/checkout/generateAuthUrl',
|
||||||
|
method: 'post',
|
||||||
|
data: param,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取授权结果
|
||||||
|
*/
|
||||||
|
export function auth(param: CheckoutAuthCodeParam) {
|
||||||
|
return http.request<Result<AuthResult>>({
|
||||||
|
url: '/unipay/checkout/auth',
|
||||||
|
method: 'post',
|
||||||
|
data: param,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 发起普通支付
|
||||||
|
*/
|
||||||
|
export function checkoutPay(param: CheckoutPayParam) {
|
||||||
|
return http.request<Result<PayResult>>({
|
||||||
|
url: '/unipay/checkout/pay',
|
||||||
|
method: 'post',
|
||||||
|
data: param,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发起聚合支付
|
||||||
|
*/
|
||||||
|
export function aggregatePay(param: CheckoutAggregatePayParam) {
|
||||||
|
return http.request<Result<PayResult>>({
|
||||||
|
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
|
||||||
|
}
|
118
src/views/daxpay/checkout/CheckoutPay.vue
Normal file
118
src/views/daxpay/checkout/CheckoutPay.vue
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="show">
|
||||||
|
<van-overlay :show="loading">
|
||||||
|
<div class="loading-wrapper" @click.stop>
|
||||||
|
<van-loading size="24px">
|
||||||
|
支付中...
|
||||||
|
</van-loading>
|
||||||
|
</div>
|
||||||
|
</van-overlay>
|
||||||
|
<van-cell-group inset title="订单信息">
|
||||||
|
<van-cell title="金额" title-style="font-size: 22px;color: red">
|
||||||
|
<template #default>
|
||||||
|
<span style="font-size: 22px;color: red">{{ orderAndConfig.order.amount }}元</span>
|
||||||
|
</template>
|
||||||
|
</van-cell>
|
||||||
|
<van-field label="标题" :model-value="orderAndConfig.order.title" readonly />
|
||||||
|
<van-field label="订单号" :model-value="orderAndConfig.order.bizOrderNo" readonly />
|
||||||
|
<van-field label="支付号" :model-value="orderAndConfig.order.orderNo" readonly />
|
||||||
|
<van-field label="描述" rows="2" type="textarea" :model-value="orderAndConfig.order.description" readonly />
|
||||||
|
</van-cell-group>
|
||||||
|
|
||||||
|
<van-cell-group v-for="group in orderAndConfig.groupConfigs" :key="group.id" inset :title="group.name">
|
||||||
|
<van-space direction="vertical" fill>
|
||||||
|
<van-button v-for="config in group.items" :key="config.id" type="primary" block @click="pay(config)">
|
||||||
|
{{ config.name }}
|
||||||
|
</van-button>
|
||||||
|
</van-space>
|
||||||
|
</van-cell-group>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import type {
|
||||||
|
CheckoutItemConfigResult,
|
||||||
|
CheckoutOrderAndConfigResult,
|
||||||
|
CheckoutPayParam,
|
||||||
|
} from './CheckoutPay.api'
|
||||||
|
import {
|
||||||
|
checkoutPay
|
||||||
|
, getOrderAndConfig,
|
||||||
|
} from './CheckoutPay.api'
|
||||||
|
|
||||||
|
import { CheckoutTypeEnum } from '@/enums/daxpay/DaxPayEnum'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const { orderNo } = route.params
|
||||||
|
const ua = navigator.userAgent
|
||||||
|
const show = ref(false)
|
||||||
|
const loading = ref(false)
|
||||||
|
const orderAndConfig = ref<CheckoutOrderAndConfigResult>({
|
||||||
|
order: {},
|
||||||
|
config: {},
|
||||||
|
groupConfigs: [],
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化
|
||||||
|
*/
|
||||||
|
onMounted(() => {
|
||||||
|
initData()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化数据
|
||||||
|
*/
|
||||||
|
async function initData() {
|
||||||
|
// 获取收银台配置
|
||||||
|
await getOrderAndConfig(orderNo, CheckoutTypeEnum.H5).then(({ data }) => {
|
||||||
|
orderAndConfig.value = data
|
||||||
|
}).catch((res) => {
|
||||||
|
router.push({ name: 'ErrorResult', query: { msg: res.message }, replace: true })
|
||||||
|
})
|
||||||
|
// 判断是否自动升级为聚合控制台
|
||||||
|
if (orderAndConfig.value.config.h5AutoUpgrade) {
|
||||||
|
goAggregate()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
show.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到聚合收银台
|
||||||
|
*/
|
||||||
|
function goAggregate() {
|
||||||
|
if (ua.includes('MicroMessenger')) {
|
||||||
|
router.push({ path: `/aggregate/wechat/${orderNo}`, replace: true })
|
||||||
|
}
|
||||||
|
else if (ua.includes('Alipay')) {
|
||||||
|
router.push({ path: `/aggregate/alipay/${orderNo}`, replace: true })
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
show.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发起支付
|
||||||
|
*/
|
||||||
|
function pay(config: CheckoutItemConfigResult) {
|
||||||
|
loading.value = true
|
||||||
|
const from = {
|
||||||
|
orderNo,
|
||||||
|
itemId: config.id,
|
||||||
|
} as CheckoutPayParam
|
||||||
|
checkoutPay(from).then(({ data }) => {
|
||||||
|
loading.value = false
|
||||||
|
// 跳转到支付页面
|
||||||
|
location.replace(data.payBody)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
</style>
|
89
src/views/daxpay/checkout/alipay/AliAggregate.vue
Normal file
89
src/views/daxpay/checkout/alipay/AliAggregate.vue
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<van-overlay :show="loading">
|
||||||
|
<div class="loading-wrapper" @click.stop>
|
||||||
|
<van-loading size="24px">
|
||||||
|
支付中...
|
||||||
|
</van-loading>
|
||||||
|
</div>
|
||||||
|
</van-overlay>
|
||||||
|
<van-cell-group inset title="订单信息">
|
||||||
|
<van-cell title="金额" title-style="font-size: 22px;color: red">
|
||||||
|
<template #default>
|
||||||
|
<span style="font-size: 22px;color: red">{{ aggregateInfo.order.amount }}元</span>
|
||||||
|
</template>
|
||||||
|
</van-cell>
|
||||||
|
<van-field label="标题" :model-value="aggregateInfo.order.title" readonly />
|
||||||
|
<van-field label="订单号" :model-value="aggregateInfo.order.bizOrderNo" readonly />
|
||||||
|
<van-field label="支付号" :model-value="aggregateInfo.order.orderNo" readonly />
|
||||||
|
<van-field label="描述" rows="2" type="textarea" :model-value="aggregateInfo.order.description" readonly />
|
||||||
|
</van-cell-group>
|
||||||
|
<van-submit-bar safe-area-inset-bottom :price="(aggregateInfo.order.amount || 0)*100" button-text="支付" @submit="pay" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
import { CheckoutAggregateEnum } from '@/enums/daxpay/DaxPayEnum'
|
||||||
|
import router from '@/router'
|
||||||
|
import type {
|
||||||
|
AggregateOrderAndConfigResult,
|
||||||
|
CheckoutAggregatePayParam,
|
||||||
|
} from '@/views/daxpay/checkout/CheckoutPay.api'
|
||||||
|
import {
|
||||||
|
aggregatePay,
|
||||||
|
getAggregateConfig,
|
||||||
|
} from '@/views/daxpay/checkout/CheckoutPay.api'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const { orderNo } = route.params
|
||||||
|
|
||||||
|
const loading = ref<boolean>(false)
|
||||||
|
const aggregateInfo = ref<AggregateOrderAndConfigResult>({
|
||||||
|
aggregateConfig: {},
|
||||||
|
config: {},
|
||||||
|
order: {},
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
initData()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化数据
|
||||||
|
*/
|
||||||
|
async function initData() {
|
||||||
|
// 查询订单和配置
|
||||||
|
await getAggregateConfig(orderNo, CheckoutAggregateEnum.ALI).then(({ data }) => {
|
||||||
|
aggregateInfo.value = data
|
||||||
|
}).catch((res) => {
|
||||||
|
router.push({ name: 'ErrorResult', query: { msg: res.message }, replace: true })
|
||||||
|
})
|
||||||
|
// 判断是否自动拉起支付
|
||||||
|
if (aggregateInfo.value.aggregateConfig.autoLaunch) {
|
||||||
|
pay()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付
|
||||||
|
*/
|
||||||
|
function pay() {
|
||||||
|
loading.value = true
|
||||||
|
const from = {
|
||||||
|
orderNo: aggregateInfo.value.order.orderNo,
|
||||||
|
aggregateType: CheckoutAggregateEnum.ALI,
|
||||||
|
} as CheckoutAggregatePayParam
|
||||||
|
aggregatePay(from)
|
||||||
|
.then(({ data }) => {
|
||||||
|
loading.value = false
|
||||||
|
// 跳转到H5/扫码支付页面
|
||||||
|
location.replace(data.payBody)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
</style>
|
152
src/views/daxpay/checkout/wechat/WechatAggregate.vue
Normal file
152
src/views/daxpay/checkout/wechat/WechatAggregate.vue
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="show">
|
||||||
|
<van-overlay :show="loading">
|
||||||
|
<div class="loading-wrapper" @click.stop>
|
||||||
|
<van-loading size="24px">
|
||||||
|
支付中...
|
||||||
|
</van-loading>
|
||||||
|
</div>
|
||||||
|
</van-overlay>
|
||||||
|
<van-cell-group inset>
|
||||||
|
<van-cell title="金额" title-style="font-size: 22px;color: red">
|
||||||
|
<template #default>
|
||||||
|
<span style="font-size: 22px;color: red">{{ aggregateInfo.order.amount }}元</span>
|
||||||
|
</template>
|
||||||
|
</van-cell>
|
||||||
|
<van-field label="标题" :model-value="aggregateInfo.order.title" readonly />
|
||||||
|
<van-field label="订单号" :model-value="aggregateInfo.order.bizOrderNo" readonly />
|
||||||
|
<van-field label="支付号" :model-value="aggregateInfo.order.orderNo" readonly />
|
||||||
|
<van-field label="描述" rows="2" type="textarea" :model-value="aggregateInfo.order.description" readonly />
|
||||||
|
</van-cell-group>
|
||||||
|
<van-submit-bar safe-area-inset-bottom :price="(aggregateInfo.order.amount || 0) * 100" button-text="支付" @submit="pay" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
import { CheckoutAggregateEnum } from '@/enums/daxpay/DaxPayEnum'
|
||||||
|
import router from '@/router'
|
||||||
|
import type {
|
||||||
|
AggregateOrderAndConfigResult, CheckoutAggregatePayParam,
|
||||||
|
CheckoutAuthCodeParam} from '@/views/daxpay/checkout/CheckoutPay.api';
|
||||||
|
import { aggregatePay,
|
||||||
|
auth, generateAuthUrl, getAggregateConfig } from '@/views/daxpay/checkout/CheckoutPay.api'
|
||||||
|
|
||||||
|
|
||||||
|
import type { WxJsapiSignResult } from '@/views/daxpay/cashier/CashierCode.api'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const { orderNo } = route.params
|
||||||
|
const { code: authCode } = route.query
|
||||||
|
|
||||||
|
const show = ref<boolean>(false)
|
||||||
|
const loading = ref<boolean>(false)
|
||||||
|
|
||||||
|
const openId = ref<string>('')
|
||||||
|
|
||||||
|
// 认证参数
|
||||||
|
const authParam = ref<CheckoutAuthCodeParam>({
|
||||||
|
orderNo: orderNo as string,
|
||||||
|
aggregateType: CheckoutAggregateEnum.WECHAT,
|
||||||
|
})
|
||||||
|
|
||||||
|
const aggregateInfo = ref<AggregateOrderAndConfigResult>({
|
||||||
|
aggregateConfig: {},
|
||||||
|
config: {},
|
||||||
|
order: {},
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
init()
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进入页面的初始化
|
||||||
|
*/
|
||||||
|
function init() {
|
||||||
|
// 如果不是重定向跳转过来, 跳转到到重定向授权地址
|
||||||
|
if (!authCode) {
|
||||||
|
// 重定向跳转到微信授权地址
|
||||||
|
generateAuthUrl({ orderNo: orderNo as string, aggregateType: CheckoutAggregateEnum.WECHAT }).then((res) => {
|
||||||
|
const url = res.data
|
||||||
|
location.replace(url)
|
||||||
|
}).catch((res) => {
|
||||||
|
router.push({ name: 'ErrorResult', query: { msg: res.message }, replace: true })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
authParam.value.authCode = authCode as string
|
||||||
|
// 初始化数据
|
||||||
|
initData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化数据
|
||||||
|
*/
|
||||||
|
async function initData() {
|
||||||
|
show.value = true
|
||||||
|
// 获取聚合配置
|
||||||
|
getAggregateConfig(orderNo, CheckoutAggregateEnum.WECHAT).then(({ data }) => {
|
||||||
|
aggregateInfo.value = data
|
||||||
|
}).catch((res) => {
|
||||||
|
router.push({ name: 'ErrorResult', query: { msg: res.message }, replace: true })
|
||||||
|
})
|
||||||
|
|
||||||
|
// 认证获取OpenId
|
||||||
|
await auth(authParam.value).then(({ data }) => {
|
||||||
|
openId.value = data.openId as string
|
||||||
|
}).catch((res) => {
|
||||||
|
router.push({ name: 'ErrorResult', query: { msg: res.message }, replace: true })
|
||||||
|
})
|
||||||
|
// 判断是否自动拉起支付
|
||||||
|
if (aggregateInfo.value.aggregateConfig.autoLaunch) {
|
||||||
|
pay()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信jsapi方式支付
|
||||||
|
*/
|
||||||
|
function pay() {
|
||||||
|
loading.value = true
|
||||||
|
const from = {
|
||||||
|
orderNo: orderNo as string,
|
||||||
|
aggregateType: CheckoutAggregateEnum.WECHAT,
|
||||||
|
openId: openId.value,
|
||||||
|
} as CheckoutAggregatePayParam
|
||||||
|
aggregatePay(from)
|
||||||
|
.then(({ data }) => {
|
||||||
|
loading.value = false
|
||||||
|
// 拉起jsapi支付
|
||||||
|
const json = JSON.parse(data.payBody)
|
||||||
|
jsapiPay(json)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉起Jsapi支付窗口
|
||||||
|
*/
|
||||||
|
function jsapiPay(data: WxJsapiSignResult) {
|
||||||
|
const form = {
|
||||||
|
appId: data.appId, // 公众号ID,由商户传入
|
||||||
|
timeStamp: data.timeStamp, // 时间戳,自1970年以来的秒数
|
||||||
|
nonceStr: data.nonceStr, // 随机串
|
||||||
|
package: data.package, // 预支付ID
|
||||||
|
signType: data.signType, // 微信签名方式:
|
||||||
|
paySign: data.paySign, // 微信签名
|
||||||
|
}
|
||||||
|
// 使用微信JsSdk拉起支付
|
||||||
|
WeixinJSBridge.invoke('getBrandWCPayRequest', form, (res) => {
|
||||||
|
if (res.err_msg === 'get_brand_wcpay_request:ok') {
|
||||||
|
// 跳转到成功页面
|
||||||
|
router.push({ name: 'SuccessResult', query: { msg: '支付成功' }, replace: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
</style>
|
2
types/auto-imports.d.ts
vendored
2
types/auto-imports.d.ts
vendored
@@ -303,6 +303,6 @@ declare global {
|
|||||||
// for type re-export
|
// for type re-export
|
||||||
declare global {
|
declare global {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
|
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
|
||||||
import('vue')
|
import('vue')
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user