refactor(gateway): 聚合支付 scene 对齐 clientEnv

H5/PC 聚合页 UA 识别与请求字段改为 clientEnv,与后端 ClientEnvEnum 一致。
This commit is contained in:
bootx
2026-07-14 21:17:44 +08:00
parent 949d265ff4
commit 031606ac53
13 changed files with 33 additions and 33 deletions

View File

@@ -41,7 +41,7 @@ const paid = computed(() => order.value.status === 'paid')
/**
* 根据 UA 识别收银场景
*/
function detectScene(): string {
function detectClientEnv(): string {
const ua = navigator.userAgent.toLowerCase()
if (ua.includes('micromessenger')) {
return 'wechat_pay'
@@ -59,14 +59,14 @@ function detectScene(): string {
/**
* 场景展示名
*/
function sceneLabel(scene: string) {
if (scene === 'alipay') {
return t('aggregate.scene.alipay')
function clientEnvLabel(clientEnv: string) {
if (clientEnv === 'alipay') {
return t('aggregate.clientEnv.alipay')
}
if (scene === 'union_pay') {
return t('aggregate.scene.union')
if (clientEnv === 'union_pay') {
return t('aggregate.clientEnv.union')
}
return t('aggregate.scene.wechat')
return t('aggregate.clientEnv.wechat')
}
onMounted(async () => {
@@ -123,10 +123,10 @@ async function doPay() {
}
paying.value = true
try {
const scene = detectScene()
const clientEnv = detectClientEnv()
payResult.value = await aggregatePay({
orderNo,
scene,
clientEnv,
device: 'mobile',
})
// 同步成功
@@ -216,7 +216,7 @@ function redirectIfNeeded() {
<div v-if="remainSeconds > 0 && !paid">
{{ t('aggregate.countdown') }}: {{ countdown }}
</div>
<div>{{ t('aggregate.sceneLabel') }}: {{ sceneLabel(detectScene()) }}</div>
<div>{{ t('aggregate.clientEnvLabel') }}: {{ clientEnvLabel(detectClientEnv()) }}</div>
</div>
</div>

View File

@@ -29,7 +29,7 @@ const amountYuan = computed(() => {
const paid = computed(() => order.value.status === 'paid')
function detectScene(): string {
function detectClientEnv(): string {
const ua = navigator.userAgent.toLowerCase()
if (ua.includes('micromessenger')) {
return 'wechat_pay'
@@ -78,7 +78,7 @@ async function doPay() {
try {
payResult.value = await aggregatePay({
orderNo,
scene: detectScene(),
clientEnv: detectClientEnv(),
device: 'pc',
})
if (payResult.value?.status === 'success') {

View File

@@ -50,7 +50,7 @@ export function getGatewayOrder(orderNo: string): Promise<GatewayOrderInfo> {
/** 聚合扫码发起支付 */
export function aggregatePay(data: {
orderNo: string
scene: string
clientEnv: string
openId?: string
device?: string
clientIp?: string

View File

@@ -2,8 +2,8 @@
"defaultTitle": "Aggregate Pay",
"orderNo": "Order No",
"countdown": "Time left",
"sceneLabel": "Scene",
"scene": {
"clientEnvLabel": "Scene",
"clientEnv": {
"wechat": "WeChat",
"alipay": "Alipay",
"union": "UnionPay"

View File

@@ -2,8 +2,8 @@
"defaultTitle": "Pembayaran Agregat",
"orderNo": "Nomor Pesanan",
"countdown": "Waktu tersisa",
"sceneLabel": "Pemandangan",
"scene": {
"clientEnvLabel": "Pemandangan",
"clientEnv": {
"wechat": "Wechat wechat",
"alipay": "Alipay",
"union": "UnionPay"

View File

@@ -2,8 +2,8 @@
"defaultTitle": "総支払額",
"orderNo": "注文番号",
"countdown": "残り時間",
"sceneLabel": "シーン",
"scene": {
"clientEnvLabel": "シーン",
"clientEnv": {
"wechat": "微信",
"alipay": "アリペイ",
"union": "銀聯"

View File

@@ -2,8 +2,8 @@
"defaultTitle": "총액지불",
"orderNo": "주문 번호",
"countdown": "남은 시간",
"sceneLabel": "장면",
"scene": {
"clientEnvLabel": "장면",
"clientEnv": {
"wechat": "위챗",
"alipay": "알리페이",
"union": "유니온페이"

View File

@@ -2,8 +2,8 @@
"defaultTitle": "Bayaran Agregat",
"orderNo": "Pesanan No",
"countdown": "Masa yang tinggal",
"sceneLabel": "tempat kejadian",
"scene": {
"clientEnvLabel": "tempat kejadian",
"clientEnv": {
"wechat": "WeChat",
"alipay": "Alipay",
"union": "UnionPay"

View File

@@ -2,8 +2,8 @@
"defaultTitle": "จ่ายเงินรวม",
"orderNo": "หมายเลขคำสั่งซื้อ",
"countdown": "เหลือเวลา",
"sceneLabel": "ฉาก",
"scene": {
"clientEnvLabel": "ฉาก",
"clientEnv": {
"wechat": "วีแชท",
"alipay": "อาลีเพย์",
"union": "ยูเนี่ยนเพย์"

View File

@@ -2,8 +2,8 @@
"defaultTitle": "Tổng lương",
"orderNo": "Số thứ tự",
"countdown": "Thời gian còn lại",
"sceneLabel": "Bối cảnh",
"scene": {
"clientEnvLabel": "Bối cảnh",
"clientEnv": {
"wechat": "WeChat",
"alipay": "Alipay",
"union": "UnionPay"

View File

@@ -2,8 +2,8 @@
"defaultTitle": "聚合支付",
"orderNo": "订单号",
"countdown": "剩余时间",
"sceneLabel": "支付环境",
"scene": {
"clientEnvLabel": "支付环境",
"clientEnv": {
"wechat": "微信",
"alipay": "支付宝",
"union": "云闪付"

View File

@@ -2,8 +2,8 @@
"defaultTitle": "聚合支付",
"orderNo": "訂單號",
"countdown": "剩餘時間",
"sceneLabel": "支付環境",
"scene": {
"clientEnvLabel": "支付環境",
"clientEnv": {
"wechat": "微信",
"alipay": "支付寶",
"union": "雲閃付"

View File

@@ -2,8 +2,8 @@
"defaultTitle": "聚合支付",
"orderNo": "訂單號",
"countdown": "剩餘時間",
"sceneLabel": "支付環境",
"scene": {
"clientEnvLabel": "支付環境",
"clientEnv": {
"wechat": "微信",
"alipay": "支付寶",
"union": "雲閃付"