This commit is contained in:
Austin 2026-07-22 14:45:49 +08:00
parent 85a8e7f9bd
commit faf62d659c
4 changed files with 68 additions and 217 deletions

View File

@ -1,20 +1,20 @@
// #ifdef MP-ALIPAY
const APP_ID = '123019';
// const APP_ID = '12317';
// const APP_ID = '123019';
const APP_ID = '12317';
// #endif
// #ifdef MP-WEIXIN
const APP_ID = '123018';
// const APP_ID = '12316';
// const APP_ID = '123018';
const APP_ID = '12316';
// #endif
// #ifndef MP-WEIXIN
// #ifndef MP-ALIPAY
const APP_ID = '123018';
// const APP_ID = '12316';
// const APP_ID = '123018';
const APP_ID = '12316';
// #endif
// #endif
export const APP_CONFIG = {
API_BASE_URL: 'https://dev.api.leapy.cn',
API_BASE_URL: 'https://api.leapy.cn',
APP_ID,
RESOURCE_URL: 'https://resource.leapy.cn/staff/',
PROPERTY_IMG_URL: 'https://resource.leapy.cn/',

View File

@ -21,7 +21,7 @@
"style": {
"enablePullDownRefresh": false,
"navigationBarTextStyle": "black",
"navigationBarTitleText": "支付结果"
"navigationBarTitleText": "详情"
}
},
{

View File

@ -1,5 +1,10 @@
<template>
<view class="result-page">
<view v-if="!isValidEntry" class="empty-page">
<wd-status-tip :image="emptyImage" tip="暂无内容" />
</view>
<block v-else>
<view class="result-card">
<view v-if="status === 'pending'" class="status-block">
<view class="pending-icon">
@ -45,6 +50,7 @@
{{ status === 'failed' ? '返回收银台' : '继续付款' }}
</button>
</view>
</block>
</view>
</template>
@ -52,12 +58,17 @@
import { computed, onUnmounted, ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { queryTrade } from '@/api/cashier';
import { APP_CONFIG } from '@/config';
const POLL_INTERVAL_MS = 1000;
const POLL_MAX_ATTEMPTS = 240;
const PAY_RESULT_TITLE = '支付结果';
const NEUTRAL_TITLE = '详情';
type ResultStatus = 'pending' | 'success' | 'failed';
const emptyImage = `${APP_CONFIG.RESOURCE_URL}tip/message.png`;
const isValidEntry = ref(false);
const amount = ref('0.00');
const accumulation = ref('0.00');
const merchantName = ref('');
@ -97,12 +108,6 @@ const stopPolling = () => {
};
const pollTradeStatus = async () => {
if (!tradeNo.value) {
status.value = 'failed';
statusMessage.value = '缺少交易单号';
return;
}
for (let attempt = 0; attempt < POLL_MAX_ATTEMPTS; attempt++) {
if (pollStopped) return;
@ -127,6 +132,10 @@ const pollTradeStatus = async () => {
}
};
const setPageTitle = (title: string) => {
uni.setNavigationBarTitle({ title });
};
const goMine = () => {
uni.navigateTo({
url: '/pages/mine/index'
@ -147,12 +156,20 @@ const goCashier = () => {
};
onLoad((options: any) => {
const nextTradeNo = decodeOption(options?.trade_no || options?.order_id || options?.orderId).trim();
if (!nextTradeNo) {
setPageTitle(NEUTRAL_TITLE);
return;
}
isValidEntry.value = true;
setPageTitle(PAY_RESULT_TITLE);
amount.value = options?.amount || '0.00';
accumulation.value = options?.accumulation || '0.00';
merchantName.value = decodeOption(options?.merchant_name || options?.merchantName);
merchantUrl.value = decodeOption(options?.merchant_url || options?.url);
scoreName.value = decodeOption(options?.score_name) || '物业抵扣金';
tradeNo.value = decodeOption(options?.trade_no || options?.order_id || options?.orderId);
tradeNo.value = nextTradeNo;
pollTradeStatus();
});
@ -168,6 +185,10 @@ onUnmounted(() => {
background: #f4f6f8;
}
.empty-page {
padding-top: 300rpx;
}
.result-card {
padding: 72rpx 36rpx 48rpx;
border-radius: 14rpx;

View File

@ -1,34 +1,11 @@
<template>
<view class="cashier-page">
<block v-if="hasMerchantUrl">
<view class="mine-entry" @tap="goMine">
<text class="ri-user-3-line mine-entry-icon"></text>
<text>我的</text>
</view>
<block v-if="!hasMerchantUrl">
<view class="empty-page">
<image class="empty-bg" :src="emptyStateBackground" mode="aspectFill" />
<view class="empty-overlay"></view>
<view class="empty-inner">
<view class="empty-brand-block">
<text class="empty-brand">{{ brandName }}</text>
<text class="empty-subtitle">扫描商家收款码快速完成付款</text>
</view>
<view class="empty-action">
<button class="empty-scan-button" hover-class="empty-scan-button-hover" :loading="scanning" @tap="handleScan">
<text class="ri-qr-scan-2-line empty-scan-button-icon"></text>
<text>扫一扫商家收款码</text>
</button>
<view class="empty-mine-link" hover-class="empty-mine-link-hover" @tap="goMine">
<text class="ri-user-3-line empty-mine-link-icon"></text>
<text>个人中心</text>
</view>
</view>
</view>
</view>
</block>
<block v-else>
<view class="pay-header" :style="{ backgroundImage: `url(${merchant.background})` }">
<view class="pay-header-mask"></view>
<view class="pay-header-scrim"></view>
@ -199,7 +176,6 @@ import {
clearPendingMerchantUrl,
clearActiveMerchantContext,
resolveMerchantUrlFromEntry,
resolveMerchantUrlFromScanResult,
syncActiveMerchantContext
} from '@/utils/merchant-context';
import { authStorage, encryptedStorage } from '@/utils/storage';
@ -215,8 +191,6 @@ interface MerchantInfo {
const defaultMerchant = (uni as any).$globalData?.defaultMerchant || DEFAULT_MERCHANT;
const PROPERTY_CACHE_TTL_SECONDS = 10 * 60;
const SUPPLIER_CACHE_TTL_SECONDS = 10 * 60;
const emptyStateBackground = '/static/cashier/bg-image.png';
const brandName = '卓享汇支付';
const IS_ALIPAY = resolveLoginPlatform() === 'mp-alipay';
const hasMerchantUrl = ref(false);
@ -233,9 +207,11 @@ const propertySheetVisible = ref(false);
const switchingProperty = ref(false);
const bindingPhone = ref(false);
const alipayPropertyUnbound = ref(false);
const scanning = ref(false);
/** 已判定无效的进页码,避免 onShow 用同一 launch qrCode 反复弹窗 */
/** 已判定无效的进页码,避免 onShow 用同一 launch qrCode 反复处理 */
const rejectedMerchantUrl = ref('');
const leavingToMine = ref(false);
/** onLoad 完成前onShow 不要误判无码并跳回个人中心 */
const bootstrapped = ref(false);
const numberKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
const canPay = computed(() => Number(amount.value) > 0 && !paying.value);
@ -447,24 +423,24 @@ const resetToEmptyMerchantState = () => {
clearActiveMerchantContext();
};
const promptScan = (message?: string) => {
uni.showModal({
title: '提示',
content: message || '未识别到商家码,请扫描商家收款码进入收银台',
confirmText: '去扫码',
showCancel: false,
success: (res) => {
if (res.confirm) {
handleScan();
}
}
const leaveToMine = (message?: string) => {
if (leavingToMine.value) return;
leavingToMine.value = true;
resetToEmptyMerchantState();
if (message) {
uni.showToast({
title: message,
icon: 'none'
});
}
uni.reLaunch({
url: '/pages/mine/index'
});
};
const failInvalidMerchant = (merchantUrl: string, message?: string) => {
rejectedMerchantUrl.value = merchantUrl;
resetToEmptyMerchantState();
promptScan(message);
leaveToMine(message || '商家码无效');
};
const fetchSupplierByUrl = async (merchantUrl: string) => {
@ -472,7 +448,7 @@ const fetchSupplierByUrl = async (merchantUrl: string) => {
if (Number(response?.code) !== 200 || !response?.data) {
return {
ok: false as const,
msg: response?.msg || '未识别到商家码,请扫描商家收款码进入收银台'
msg: response?.msg || '商家码无效'
};
}
@ -483,7 +459,7 @@ const fetchSupplierByUrl = async (merchantUrl: string) => {
if (!latestSupplier.supplier_name && !latestSupplier.supplier_id) {
return {
ok: false as const,
msg: response?.msg || '未识别到商家码,请扫描商家收款码进入收银台'
msg: response?.msg || '商家码无效'
};
}
@ -498,7 +474,7 @@ const initWithMerchantUrl = async (
options: { force?: boolean } = {}
) => {
if (!options.force && rejectedMerchantUrl.value === merchantUrl) {
resetToEmptyMerchantState();
leaveToMine();
return;
}
@ -534,46 +510,13 @@ const initWithMerchantUrl = async (
} catch (error: any) {
failInvalidMerchant(
merchantUrl,
error?.message || '未识别到商家码,请扫描商家收款码进入收银台'
error?.message || '商家码无效'
);
}
};
const handleScan = () => {
if (scanning.value) return;
scanning.value = true;
uni.scanCode({
onlyFromCamera: false,
scanType: ['qrCode'],
success: async (res) => {
const merchantUrl = resolveMerchantUrlFromScanResult(res.result || '');
if (!merchantUrl) {
uni.showToast({
title: '未识别到商家码',
icon: 'none'
});
promptScan();
return;
}
await initWithMerchantUrl(merchantUrl, { force: true });
},
fail: (err: any) => {
const errMsg = err?.errMsg || '';
if (errMsg.includes('cancel')) return;
uni.showToast({
title: '扫码失败,请重试',
icon: 'none'
});
},
complete: () => {
scanning.value = false;
}
});
};
const handleMissingMerchantUrl = () => {
promptScan();
leaveToMine();
};
const resolvePropertyListFallback = async (merchantUrl: string) => {
@ -1046,17 +989,22 @@ const handlePay = async () => {
}
};
onLoad((options: any) => {
onLoad(async (options: any) => {
const merchantUrl = resolveMerchantUrlFromEntry(options || {});
if (!merchantUrl) {
handleMissingMerchantUrl();
return;
}
clearPendingMerchantUrl();
initWithMerchantUrl(merchantUrl);
await initWithMerchantUrl(merchantUrl);
if (!leavingToMine.value) {
bootstrapped.value = true;
}
});
onShow(() => {
if (leavingToMine.value || !bootstrapped.value) return;
if (!hasMerchantUrl.value || !activeMerchantUrl.value) {
const merchantUrl = resolveMerchantUrlFromEntry({});
if (merchantUrl && merchantUrl !== rejectedMerchantUrl.value) {
@ -1064,9 +1012,10 @@ onShow(() => {
initWithMerchantUrl(merchantUrl);
return;
}
leaveToMine();
return;
}
if (!hasMerchantUrl.value || !activeMerchantUrl.value) return;
loadPropertyBinding(activeMerchantUrl.value);
loadSupplier(activeMerchantUrl.value);
});
@ -1104,125 +1053,6 @@ onShow(() => {
line-height: 1;
}
.empty-page {
position: relative;
min-height: 100vh;
overflow: hidden;
}
.empty-bg {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
.empty-overlay {
position: absolute;
inset: 0;
background: linear-gradient(
180deg,
rgba(15, 35, 95, 0.18) 0%,
rgba(15, 35, 95, 0.42) 42%,
rgba(255, 255, 255, 0.92) 78%,
#ffffff 100%
);
}
.empty-inner {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
min-height: 100vh;
padding: 160rpx 48rpx calc(72rpx + env(safe-area-inset-bottom));
box-sizing: border-box;
}
.empty-brand-block {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.empty-brand {
font-family: SourceHanSansCN, -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
color: #ffffff;
font-size: 60rpx;
font-weight: 600;
line-height: 1.25;
letter-spacing: 2rpx;
text-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.2);
}
.empty-subtitle {
margin-top: 20rpx;
color: rgba(255, 255, 255, 0.92);
font-size: 28rpx;
line-height: 1.5;
text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.18);
}
.empty-action {
padding-top: 48rpx;
}
.empty-scan-button {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 104rpx;
padding: 0;
border-radius: 16rpx;
background: #1f5bd8;
color: #ffffff;
font-size: 32rpx;
font-weight: 800;
line-height: 1;
box-shadow: 0 12rpx 32rpx rgba(31, 91, 216, 0.28);
}
.empty-scan-button::after {
border: none;
}
.empty-scan-button-icon {
margin-right: 12rpx;
font-size: 40rpx;
line-height: 1;
}
.empty-scan-button-hover {
background: #174dc1;
}
.empty-mine-link {
display: flex;
align-items: center;
justify-content: center;
margin-top: 24rpx;
color: rgba(255, 255, 255, 0.96);
font-size: 28rpx;
font-weight: 600;
}
.empty-mine-link-hover {
opacity: 0.86;
}
.empty-mine-link-icon {
margin-right: 8rpx;
font-size: 32rpx;
line-height: 1;
}
.brand-only {
margin: 0;
}
.pay-header {
position: relative;
flex-shrink: 0;