mirror of
https://gitee.com/bootx/dax-pay-h5.git
synced 2025-10-13 21:50:26 +00:00
码牌支付
This commit is contained in:
@@ -34,9 +34,16 @@ export const DaxPayH5Route: RouteRecordRaw = {
|
||||
title: '收银台',
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
path: '/alipay/cashier/code/:orderNo',
|
||||
path: '/cashier/code/:code',
|
||||
name: 'CashierCode',
|
||||
component: () => import('@/views/daxpay/h5/code/CashierCode.vue'),
|
||||
meta: {
|
||||
title: '收银台',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/alipay/cashier/code/:code',
|
||||
name: 'AlipayCashierCode',
|
||||
component: () => import('@/views/daxpay/h5/code/alipay/AlipayCashierCode.vue'),
|
||||
meta: {
|
||||
@@ -44,7 +51,7 @@ export const DaxPayH5Route: RouteRecordRaw = {
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/wechat/cashier/code/:orderNo',
|
||||
path: '/wechat/cashier/code/:code',
|
||||
name: 'WechatCashierCode',
|
||||
component: () => import('@/views/daxpay/h5/code/wechat/WechatCashierCode.vue'),
|
||||
meta: {
|
||||
|
@@ -4,11 +4,11 @@ import type { Result } from '#/axios'
|
||||
/**
|
||||
* 获取商户名称
|
||||
*/
|
||||
export function getMchName(mchNo: string) {
|
||||
export function getMchName(cashierCode, cashierType) {
|
||||
return http.request<Result<string>>({
|
||||
url: '/unipay/ext/channel/cashier/getMchName',
|
||||
url: '/unipay/gateway/getCashierCodeConfig',
|
||||
method: 'GET',
|
||||
params: { mchNo },
|
||||
params: { cashierCode, cashierType },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -39,12 +39,11 @@ export function generateAuthUrl(param: CashierAuthParam) {
|
||||
*/
|
||||
export function cashierPay(param: CashierPayParam) {
|
||||
return http.request<Result<PayResult>>({
|
||||
url: '/unipay/ext/channel/cashier/pay',
|
||||
url: '/unipay/gateway/cashierCodePay',
|
||||
method: 'POST',
|
||||
data: param,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 通道认证参数
|
||||
*/
|
||||
@@ -82,7 +81,6 @@ export interface CashierPayParam {
|
||||
* 支付结果
|
||||
*/
|
||||
export interface PayResult {
|
||||
|
||||
// 支付状态
|
||||
status: string
|
||||
// 支付参数体
|
||||
@@ -132,3 +130,13 @@ export interface ChannelCashierConfigResult {
|
||||
// 自动分账
|
||||
autoAllocation?: boolean
|
||||
}
|
||||
|
||||
// 码牌支付检查信息
|
||||
export interface getNameConfig {
|
||||
// 商家名称
|
||||
name: string
|
||||
// 判断是否需要
|
||||
needOpenId: boolean
|
||||
// 备注
|
||||
remark: string
|
||||
}
|
||||
|
@@ -8,14 +8,14 @@ import { getBrowserUA } from '@/utils/uaUtil'
|
||||
import router from '@/router'
|
||||
|
||||
const route = useRoute()
|
||||
const { orderNo } = route.params
|
||||
const { code } = route.params
|
||||
|
||||
const ua = getBrowserUA()
|
||||
if (ua === 'wechat') {
|
||||
router.push({ path: `/wechat/cashier/code/${orderNo}`, replace: true })
|
||||
router.push({ path: `/wechat/cashier/code/${code}`, replace: true })
|
||||
}
|
||||
else if (ua === 'alipay') {
|
||||
router.push({ path: `/alipay/cashier/code/${orderNo}`, replace: true })
|
||||
router.push({ path: `/alipay/cashier/code/${code}`, replace: true })
|
||||
}
|
||||
else {
|
||||
router.replace({
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<div class="container">
|
||||
<div class="payName">
|
||||
<span>付款给</span>
|
||||
<span class="paytext">杨家臭豆腐{{ mchName }}</span>
|
||||
<span class="paytext">{{ cashierInfo?.name }}</span>
|
||||
</div>
|
||||
<div class="amount-display">
|
||||
<p class="title">
|
||||
@@ -62,45 +62,41 @@
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { showNotify } from 'vant'
|
||||
import type { CashierPayParam, ChannelCashierConfigResult } from '../CashierCode.api'
|
||||
import { cashierPay, getCashierInfo, getMchName } from '../CashierCode.api'
|
||||
import { AggregateEnum, CashierTypeEnum } from '@/enums/daxpay/DaxPayEnum'
|
||||
import type { CashierPayParam, getNameConfig } from '../CashierCode.api'
|
||||
import { cashierPay, getMchName } from '../CashierCode.api'
|
||||
import { AggregateEnum } from '@/enums/daxpay/DaxPayEnum'
|
||||
import router from '@/router'
|
||||
import { useKeyboard } from '@/hooks/daxpay/useKeyboard'
|
||||
|
||||
const route = useRoute()
|
||||
const { mchNo, appId } = route.params
|
||||
const { code } = route.params
|
||||
|
||||
const showRemark = ref<boolean>(false)
|
||||
const loading = ref<boolean>(false)
|
||||
const cashierInfo = ref<ChannelCashierConfigResult>({})
|
||||
const amount = ref<string>('0')
|
||||
const description = ref<string>('')
|
||||
const mchName = ref<string>('')
|
||||
const showRemark = ref<boolean>(false) // 是否展示备注
|
||||
const loading = ref<boolean>(false) // 加载状态
|
||||
const cashierInfo = ref<getNameConfig>()
|
||||
const amount = ref<string>('0') // 金额
|
||||
const description = ref<string>('') // 描述
|
||||
|
||||
const { input, del } = useKeyboard(amount)
|
||||
|
||||
onMounted(() => {
|
||||
// initData()
|
||||
initData()
|
||||
})
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
function initData() {
|
||||
getCashierInfo(AggregateEnum.ALI, appId as string)
|
||||
// 获取信息
|
||||
loading.value = true
|
||||
getMchName(code, AggregateEnum.ALI)
|
||||
.then(({ data }) => {
|
||||
cashierInfo.value = data
|
||||
loading.value = false
|
||||
cashierInfo.value = data as any
|
||||
})
|
||||
.catch((res) => {
|
||||
router.push({ name: 'ErrorResult', query: { msg: res.message } })
|
||||
})
|
||||
getMchName(mchNo as string)
|
||||
.then(({ data }) => {
|
||||
mchName.value = data
|
||||
})
|
||||
.catch((res) => {
|
||||
router.push({ name: 'ErrorResult', query: { msg: res.message } })
|
||||
.catch((error) => {
|
||||
console.log(error)
|
||||
// router.push({ name: 'ErrorResult', query: { msg: res.message } })
|
||||
})
|
||||
}
|
||||
|
||||
@@ -116,10 +112,9 @@ function pay() {
|
||||
loading.value = true
|
||||
const from = {
|
||||
amount: amountValue,
|
||||
appId,
|
||||
cashierType: CashierTypeEnum.ALIPAY,
|
||||
cashierCode: code,
|
||||
cashierType: AggregateEnum.ALI,
|
||||
description: description.value,
|
||||
mchNo,
|
||||
} as CashierPayParam
|
||||
cashierPay(from).then(({ data }) => {
|
||||
loading.value = false
|
||||
|
@@ -76,7 +76,7 @@ import {
|
||||
getMchName,
|
||||
} from '../CashierCode.api'
|
||||
|
||||
import { AggregateEnum, CashierTypeEnum } from "@/enums/daxpay/DaxPayEnum";
|
||||
import { AggregateEnum, CashierTypeEnum } from '@/enums/daxpay/DaxPayEnum'
|
||||
import router from '@/router'
|
||||
import { useKeyboard } from '@/hooks/daxpay/useKeyboard'
|
||||
|
||||
@@ -105,7 +105,6 @@ const { input, del } = useKeyboard(amount)
|
||||
onMounted(() => {
|
||||
// init()
|
||||
show.value = true
|
||||
|
||||
})
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user