This commit is contained in:
parent
d61d8e67a1
commit
1a09941460
15
App.vue
15
App.vue
|
|
@ -1,7 +1,10 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onLaunch, onShow } from '@dcloudio/uni-app'
|
import { onLaunch, onShow } from '@dcloudio/uni-app'
|
||||||
import { APP_CONFIG, DEFAULT_MERCHANT } from '@/config'
|
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'
|
import { VersionUpdate } from '@/utils/common'
|
||||||
|
|
||||||
// 定义全局数据
|
// 定义全局数据
|
||||||
|
|
@ -18,11 +21,17 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
uni.$globalData = $globalData
|
uni.$globalData = $globalData
|
||||||
|
|
||||||
|
/** 直接进 → 个人中心;扫码有商家码 → 跳收款页 */
|
||||||
|
const handleLaunchEntry = (options: Record<string, any> = {}) => {
|
||||||
|
const merchantUrl = captureMerchantUrlFromLaunchOptions(options)
|
||||||
|
redirectToPayIfMerchantUrl(merchantUrl, options)
|
||||||
|
}
|
||||||
|
|
||||||
onLaunch((options) => {
|
onLaunch((options) => {
|
||||||
captureMerchantUrlFromLaunchOptions(options || {})
|
handleLaunchEntry(options || {})
|
||||||
})
|
})
|
||||||
onShow((options) => {
|
onShow((options) => {
|
||||||
captureMerchantUrlFromLaunchOptions(options || {})
|
handleLaunchEntry(options || {})
|
||||||
// 检测小程序热更新
|
// 检测小程序热更新
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
VersionUpdate()
|
VersionUpdate()
|
||||||
|
|
|
||||||
20
pages.json
20
pages.json
|
|
@ -1,11 +1,19 @@
|
||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
|
{
|
||||||
|
"path": "pages/mine/index",
|
||||||
|
"style": {
|
||||||
|
"enablePullDownRefresh": true,
|
||||||
|
"navigationBarTextStyle": "black",
|
||||||
|
"navigationBarTitleText": "卓享汇服务"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/pay/pay",
|
"path": "pages/pay/pay",
|
||||||
"style": {
|
"style": {
|
||||||
"enablePullDownRefresh": false,
|
"enablePullDownRefresh": false,
|
||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "black",
|
||||||
"navigationBarTitleText": "卓享汇收银台"
|
"navigationBarTitleText": "卓享汇服务"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -34,14 +42,6 @@
|
||||||
"navigationBarTitleText": "付款记录"
|
"navigationBarTitleText": "付款记录"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "pages/mine/index",
|
|
||||||
"style": {
|
|
||||||
"enablePullDownRefresh": true,
|
|
||||||
"navigationBarTextStyle": "black",
|
|
||||||
"navigationBarTitleText": "个人中心"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "pages/mine/score-records",
|
"path": "pages/mine/score-records",
|
||||||
"style": {
|
"style": {
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
],
|
],
|
||||||
"globalStyle": {
|
"globalStyle": {
|
||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "black",
|
||||||
"navigationBarTitleText": "卓享汇收银台",
|
"navigationBarTitleText": "卓享汇服务",
|
||||||
"navigationBarBackgroundColor": "#FFFFFF",
|
"navigationBarBackgroundColor": "#FFFFFF",
|
||||||
"backgroundColor": "#F4F6F8"
|
"backgroundColor": "#F4F6F8"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<text class="score-value">¥ {{ platformScoreText }}</text>
|
<text class="score-value">¥ {{ platformScoreText }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- #ifndef MP-ALIPAY -->
|
||||||
<view class="fund-card" hover-class="fund-card-hover" @tap="goPropertyFund">
|
<view class="fund-card" hover-class="fund-card-hover" @tap="goPropertyFund">
|
||||||
<view class="fund-card-left">
|
<view class="fund-card-left">
|
||||||
<image class="fund-icon-image" :src="fundIconUrl" mode="aspectFit" />
|
<image class="fund-icon-image" :src="fundIconUrl" mode="aspectFit" />
|
||||||
|
|
@ -18,6 +19,7 @@
|
||||||
<text class="ri-arrow-right-s-line fund-action-arrow"></text>
|
<text class="ri-arrow-right-s-line fund-action-arrow"></text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- #endif -->
|
||||||
|
|
||||||
<view class="menu-card">
|
<view class="menu-card">
|
||||||
<view class="menu-item" hover-class="menu-item-hover" @tap="goRecords">
|
<view class="menu-item" hover-class="menu-item-hover" @tap="goRecords">
|
||||||
|
|
@ -36,17 +38,16 @@
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { onPullDownRefresh, onShow } from '@dcloudio/uni-app';
|
import { onPullDownRefresh, onShow } from '@dcloudio/uni-app';
|
||||||
import { platformScore } from '@/api/cashier';
|
import { platformScore } from '@/api/cashier';
|
||||||
import { resolveLoginPlatform } from '@/api/auth';
|
// #ifndef MP-ALIPAY
|
||||||
import { APP_CONFIG, PROPERTY_APP } from '@/config';
|
import { APP_CONFIG, PROPERTY_APP } from '@/config';
|
||||||
|
// #endif
|
||||||
const IS_ALIPAY = resolveLoginPlatform() === 'mp-alipay';
|
|
||||||
|
|
||||||
const platformScoreText = ref('0.00');
|
const platformScoreText = ref('0.00');
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
// #ifndef MP-ALIPAY
|
||||||
const fundIconUrl = `${APP_CONFIG.PROPERTY_IMG_URL}property/new/cashier/fangwu.png`;
|
const fundIconUrl = `${APP_CONFIG.PROPERTY_IMG_URL}property/new/cashier/fangwu.png`;
|
||||||
const propertyFundDesc = IS_ALIPAY
|
const propertyFundDesc = '查看我的物业基金余额';
|
||||||
? `请前往微信「${PROPERTY_APP.WECHAT_NAME}」查看`
|
// #endif
|
||||||
: '查看我的物业基金余额';
|
|
||||||
|
|
||||||
const loadPlatformScore = async () => {
|
const loadPlatformScore = async () => {
|
||||||
const response = await platformScore();
|
const response = await platformScore();
|
||||||
|
|
@ -72,56 +73,8 @@ const refreshPage = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const copyPropertyWechatName = () => {
|
// #ifndef MP-ALIPAY
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const goPropertyFund = () => {
|
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({
|
uni.navigateToMiniProgram({
|
||||||
appId: PROPERTY_APP.APP_ID,
|
appId: PROPERTY_APP.APP_ID,
|
||||||
path: PROPERTY_APP.MINE_PATH,
|
path: PROPERTY_APP.MINE_PATH,
|
||||||
|
|
@ -132,6 +85,7 @@ const goPropertyFund = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
// #endif
|
||||||
|
|
||||||
const goRecords = () => {
|
const goRecords = () => {
|
||||||
uni.navigateTo({ url: '/pages/records/index' });
|
uni.navigateTo({ url: '/pages/records/index' });
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ const propertyRowText = computed(() => {
|
||||||
if (propertyList.value.length) return '选择物业';
|
if (propertyList.value.length) return '选择物业';
|
||||||
if (IS_ALIPAY) {
|
if (IS_ALIPAY) {
|
||||||
if (alipayPropertyUnbound.value) {
|
if (alipayPropertyUnbound.value) {
|
||||||
return `未绑定,微信搜「${PROPERTY_APP.WECHAT_NAME}」绑定房源`;
|
return `未绑定,小程序搜「${PROPERTY_APP.WECHAT_NAME}」绑房源`;
|
||||||
}
|
}
|
||||||
return '绑定手机号查看房源';
|
return '绑定手机号查看房源';
|
||||||
}
|
}
|
||||||
|
|
@ -594,7 +594,7 @@ const resolvePropertyListFallback = async (merchantUrl: string) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝:无物业名/列表时,用 open.info 的 user_id 判断是否已绑过手机号。
|
* 支付宝:无物业名/列表时,用 open.info 的 user_id 判断是否已绑过手机号。
|
||||||
* 有 user_id → 显示「未绑定,微信搜「乐享云…」绑定房源」;否则 → 「绑定手机号查看房源」。
|
* 有 user_id → 显示「未绑定,小程序搜「乐享云…」绑房源」;否则 → 「绑定手机号查看房源」。
|
||||||
*/
|
*/
|
||||||
const resolveAlipayEmptyPropertyState = async (options: { assumeBoundIfEmpty?: boolean } = {}) => {
|
const resolveAlipayEmptyPropertyState = async (options: { assumeBoundIfEmpty?: boolean } = {}) => {
|
||||||
if (!IS_ALIPAY) return;
|
if (!IS_ALIPAY) return;
|
||||||
|
|
@ -693,7 +693,7 @@ const deleteKey = () => {
|
||||||
const showAlipayUnboundTip = () => {
|
const showAlipayUnboundTip = () => {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '暂未绑定房源',
|
title: '暂未绑定房源',
|
||||||
content: `请打开微信,搜索并进入「${PROPERTY_APP.WECHAT_NAME}」小程序,完成房源绑定后消费即可获得物业基金。`,
|
content: `请搜索并进入「${PROPERTY_APP.WECHAT_NAME}」小程序,完成房源绑定后消费即可获得物业基金。`,
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
confirmText: '知道了'
|
confirmText: '知道了'
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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> = {}) => {
|
export const captureMerchantUrlFromLaunchOptions = (options: Record<string, any> = {}) => {
|
||||||
const query = options.query || {};
|
const query = (options.query || {}) as Record<string, string>;
|
||||||
const qrCode = query.qrCode || query.qr_code || '';
|
|
||||||
if (!qrCode) return '';
|
|
||||||
|
|
||||||
const merchantUrl = resolveMerchantUrlFromRawEntry(String(qrCode));
|
|
||||||
if (!merchantUrl) return '';
|
|
||||||
|
|
||||||
|
const fromDirect = resolveMerchantUrlFromOptions(query);
|
||||||
|
if (fromDirect) {
|
||||||
|
const merchantUrl = resolveMerchantUrlFromScanResult(fromDirect) || fromDirect;
|
||||||
|
if (merchantUrl) {
|
||||||
setPendingMerchantUrl(merchantUrl);
|
setPendingMerchantUrl(merchantUrl);
|
||||||
return 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) {
|
||||||
|
const merchantUrl = resolveMerchantUrlFromRawEntry(String(qrCode));
|
||||||
|
if (merchantUrl) {
|
||||||
|
setPendingMerchantUrl(merchantUrl);
|
||||||
|
return merchantUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 启动 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue