diff --git a/src/router/daxpay.ts b/src/router/daxpay.ts index 6ec01dc..81ab180 100644 --- a/src/router/daxpay.ts +++ b/src/router/daxpay.ts @@ -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: { diff --git a/src/views/daxpay/h5/code/CashierCode.api.ts b/src/views/daxpay/h5/code/CashierCode.api.ts index 1ec9773..8b39ba0 100644 --- a/src/views/daxpay/h5/code/CashierCode.api.ts +++ b/src/views/daxpay/h5/code/CashierCode.api.ts @@ -4,11 +4,11 @@ import type { Result } from '#/axios' /** * 获取商户名称 */ -export function getMchName(mchNo: string) { +export function getMchName(cashierCode, cashierType) { return http.request>({ - 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>({ - 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 +} diff --git a/src/views/daxpay/h5/code/CashierCode.vue b/src/views/daxpay/h5/code/CashierCode.vue index c2eb059..2dd8118 100644 --- a/src/views/daxpay/h5/code/CashierCode.vue +++ b/src/views/daxpay/h5/code/CashierCode.vue @@ -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({ diff --git a/src/views/daxpay/h5/code/alipay/AlipayCashierCode.vue b/src/views/daxpay/h5/code/alipay/AlipayCashierCode.vue index 6163fff..d7c8b99 100644 --- a/src/views/daxpay/h5/code/alipay/AlipayCashierCode.vue +++ b/src/views/daxpay/h5/code/alipay/AlipayCashierCode.vue @@ -3,7 +3,7 @@
付款给 - 杨家臭豆腐{{ mchName }} + {{ cashierInfo?.name }}

@@ -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(false) -const loading = ref(false) -const cashierInfo = ref({}) -const amount = ref('0') -const description = ref('') -const mchName = ref('') +const showRemark = ref(false) // 是否展示备注 +const loading = ref(false) // 加载状态 +const cashierInfo = ref() +const amount = ref('0') // 金额 +const description = ref('') // 描述 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 diff --git a/src/views/daxpay/h5/code/wechat/WechatCashierCode.vue b/src/views/daxpay/h5/code/wechat/WechatCashierCode.vue index 430a8a3..09743b9 100644 --- a/src/views/daxpay/h5/code/wechat/WechatCashierCode.vue +++ b/src/views/daxpay/h5/code/wechat/WechatCashierCode.vue @@ -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 - }) /**