This commit is contained in:
Austin 2026-07-16 15:59:12 +08:00
parent d61d8e67a1
commit 1a09941460
5 changed files with 96 additions and 78 deletions

15
App.vue
View File

@ -1,7 +1,10 @@
<script setup lang="ts">
import { onLaunch, onShow } from '@dcloudio/uni-app'
import { APP_CONFIG, DEFAULT_MERCHANT } from '@/config'
import { captureMerchantUrlFromLaunchOptions } from '@/utils/merchant-context'
import {
captureMerchantUrlFromLaunchOptions,
redirectToPayIfMerchantUrl
} from '@/utils/merchant-context'
import { VersionUpdate } from '@/utils/common'
//
@ -18,11 +21,17 @@
// @ts-ignore
uni.$globalData = $globalData
/** 直接进 → 个人中心;扫码有商家码 → 跳收款页 */
const handleLaunchEntry = (options: Record<string, any> = {}) => {
const merchantUrl = captureMerchantUrlFromLaunchOptions(options)
redirectToPayIfMerchantUrl(merchantUrl, options)
}
onLaunch((options) => {
captureMerchantUrlFromLaunchOptions(options || {})
handleLaunchEntry(options || {})
})
onShow((options) => {
captureMerchantUrlFromLaunchOptions(options || {})
handleLaunchEntry(options || {})
//
// #ifdef MP-WEIXIN
VersionUpdate()

View File

@ -1,11 +1,19 @@
{
"pages": [
{
"path": "pages/mine/index",
"style": {
"enablePullDownRefresh": true,
"navigationBarTextStyle": "black",
"navigationBarTitleText": "卓享汇服务"
}
},
{
"path": "pages/pay/pay",
"style": {
"enablePullDownRefresh": false,
"navigationBarTextStyle": "black",
"navigationBarTitleText": "卓享汇收银台"
"navigationBarTitleText": "卓享汇服务"
}
},
{
@ -34,14 +42,6 @@
"navigationBarTitleText": "付款记录"
}
},
{
"path": "pages/mine/index",
"style": {
"enablePullDownRefresh": true,
"navigationBarTextStyle": "black",
"navigationBarTitleText": "个人中心"
}
},
{
"path": "pages/mine/score-records",
"style": {
@ -61,7 +61,7 @@
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "卓享汇收银台",
"navigationBarTitleText": "卓享汇服务",
"navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#F4F6F8"
},

View File

@ -5,6 +5,7 @@
<text class="score-value">¥ {{ platformScoreText }}</text>
</view>
<!-- #ifndef MP-ALIPAY -->
<view class="fund-card" hover-class="fund-card-hover" @tap="goPropertyFund">
<view class="fund-card-left">
<image class="fund-icon-image" :src="fundIconUrl" mode="aspectFit" />
@ -18,6 +19,7 @@
<text class="ri-arrow-right-s-line fund-action-arrow"></text>
</view>
</view>
<!-- #endif -->
<view class="menu-card">
<view class="menu-item" hover-class="menu-item-hover" @tap="goRecords">
@ -36,17 +38,16 @@
import { ref } from 'vue';
import { onPullDownRefresh, onShow } from '@dcloudio/uni-app';
import { platformScore } from '@/api/cashier';
import { resolveLoginPlatform } from '@/api/auth';
// #ifndef MP-ALIPAY
import { APP_CONFIG, PROPERTY_APP } from '@/config';
const IS_ALIPAY = resolveLoginPlatform() === 'mp-alipay';
// #endif
const platformScoreText = ref('0.00');
const loading = ref(false);
// #ifndef MP-ALIPAY
const fundIconUrl = `${APP_CONFIG.PROPERTY_IMG_URL}property/new/cashier/fangwu.png`;
const propertyFundDesc = IS_ALIPAY
? `请前往微信「${PROPERTY_APP.WECHAT_NAME}」查看`
: '查看我的物业基金余额';
const propertyFundDesc = '查看我的物业基金余额';
// #endif
const loadPlatformScore = async () => {
const response = await platformScore();
@ -72,56 +73,8 @@ const refreshPage = async () => {
}
};
const copyPropertyWechatName = () => {
uni.setClipboardData({
data: PROPERTY_APP.WECHAT_NAME,
success: () => {
uni.showToast({
title: '已复制,请到微信搜索',
icon: 'none'
});
},
fail: () => {
uni.showToast({
title: '复制失败,请手动搜索',
icon: 'none'
});
}
});
};
const showPropertyFundWechatTip = () => {
uni.showModal({
title: '查看物业基金',
content: `请打开微信,搜索并进入「${PROPERTY_APP.WECHAT_NAME}」小程序,在「我的」中查看物业基金。`,
cancelText: '知道了',
confirmText: '复制名称',
success: (res) => {
if (res.confirm) {
copyPropertyWechatName();
}
}
});
};
// #ifndef MP-ALIPAY
const goPropertyFund = () => {
if (IS_ALIPAY) {
if (PROPERTY_APP.ALIPAY_APP_ID) {
uni.navigateToMiniProgram({
appId: PROPERTY_APP.ALIPAY_APP_ID,
path: PROPERTY_APP.MINE_PATH,
extraData: { from: 'cashier' },
envVersion: APP_CONFIG.API_BASE_URL.includes('dev.') ? 'trial' : 'release',
fail: () => {
showPropertyFundWechatTip();
}
});
return;
}
showPropertyFundWechatTip();
return;
}
uni.navigateToMiniProgram({
appId: PROPERTY_APP.APP_ID,
path: PROPERTY_APP.MINE_PATH,
@ -132,6 +85,7 @@ const goPropertyFund = () => {
}
});
};
// #endif
const goRecords = () => {
uni.navigateTo({ url: '/pages/records/index' });

View File

@ -260,7 +260,7 @@ const propertyRowText = computed(() => {
if (propertyList.value.length) return '选择物业';
if (IS_ALIPAY) {
if (alipayPropertyUnbound.value) {
return `未绑定,微信搜「${PROPERTY_APP.WECHAT_NAME}」绑房源`;
return `未绑定,小程序搜「${PROPERTY_APP.WECHAT_NAME}」绑房源`;
}
return '绑定手机号查看房源';
}
@ -594,7 +594,7 @@ const resolvePropertyListFallback = async (merchantUrl: string) => {
/**
* 支付宝无物业名/列表时 open.info user_id 判断是否已绑过手机号
* user_id 显示未绑定微信乐享云房源否则 绑定手机号查看房源
* user_id 显示未绑定小程序乐享云房源否则 绑定手机号查看房源
*/
const resolveAlipayEmptyPropertyState = async (options: { assumeBoundIfEmpty?: boolean } = {}) => {
if (!IS_ALIPAY) return;
@ -693,7 +693,7 @@ const deleteKey = () => {
const showAlipayUnboundTip = () => {
uni.showModal({
title: '暂未绑定房源',
content: `打开微信,搜索并进入「${PROPERTY_APP.WECHAT_NAME}」小程序,完成房源绑定后消费即可获得物业基金。`,
content: `搜索并进入「${PROPERTY_APP.WECHAT_NAME}」小程序,完成房源绑定后消费即可获得物业基金。`,
showCancel: false,
confirmText: '知道了'
});

View File

@ -81,17 +81,72 @@ const getLaunchQuery = () => {
}
};
/** App.onLaunch / App.onShow捕获支付宝普通二维码 qrCode */
/**
* App.onLaunch / App.onShow
* qrCode q url / qr_url
*/
export const captureMerchantUrlFromLaunchOptions = (options: Record<string, any> = {}) => {
const query = options.query || {};
const query = (options.query || {}) as Record<string, string>;
const fromDirect = resolveMerchantUrlFromOptions(query);
if (fromDirect) {
const merchantUrl = resolveMerchantUrlFromScanResult(fromDirect) || fromDirect;
if (merchantUrl) {
setPendingMerchantUrl(merchantUrl);
return merchantUrl;
}
}
if (query.q) {
const fromQ = resolveMerchantUrlFromRawEntry(String(query.q));
if (fromQ) {
setPendingMerchantUrl(fromQ);
return fromQ;
}
}
const qrCode = query.qrCode || query.qr_code || '';
if (!qrCode) return '';
if (qrCode) {
const merchantUrl = resolveMerchantUrlFromRawEntry(String(qrCode));
if (merchantUrl) {
setPendingMerchantUrl(merchantUrl);
return merchantUrl;
}
}
const merchantUrl = resolveMerchantUrlFromRawEntry(String(qrCode));
if (!merchantUrl) return '';
return '';
};
setPendingMerchantUrl(merchantUrl);
return merchantUrl;
/** 启动 path 已是收款/半屏支付页时,不必再 reLaunch */
export const isPayEntryPath = (path?: string) => {
const normalized = String(path || '')
.replace(/^\//, '')
.split('?')[0];
return normalized === 'pages/pay/pay' || normalized === 'pages/pay/checkout';
};
/** 当前栈顶已是收款相关页时,避免重复跳转 */
export const isCurrentRoutePayPage = () => {
try {
const pages = getCurrentPages();
const current = pages[pages.length - 1] as { route?: string } | undefined;
const route = String(current?.route || '');
return route === 'pages/pay/pay' || route === 'pages/pay/checkout';
} catch {
return false;
}
};
/** 有扫码商家码且当前不是收款入口时,跳到收银台收款页 */
export const redirectToPayIfMerchantUrl = (merchantUrl: string, options: Record<string, any> = {}) => {
if (!merchantUrl) return false;
if (isPayEntryPath(options.path)) return false;
if (isCurrentRoutePayPage()) return false;
uni.reLaunch({
url: `/pages/pay/pay?url=${encodeURIComponent(merchantUrl)}`
});
return true;
};
/**