283e6651aa
Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { View, Text } from '@tarojs/components';
|
|
import Taro, { useLoad } from '@tarojs/taro';
|
|
import PageShell from '../../components/PageShell';
|
|
import { goLogin } from '../../lib/auth-nav';
|
|
import { isLoggedIn } from '../../lib/api';
|
|
|
|
function goHome() {
|
|
Taro.switchTab({ url: '/pages/home/index' }).catch(() => {
|
|
Taro.reLaunch({ url: '/pages/home/index' });
|
|
});
|
|
}
|
|
|
|
function openOrder(orderId: string) {
|
|
const detail = `/pages/order-detail/index?id=${encodeURIComponent(orderId)}`;
|
|
if (!isLoggedIn()) {
|
|
goLogin(detail);
|
|
return;
|
|
}
|
|
Taro.redirectTo({ url: detail }).catch(() => {
|
|
Taro.reLaunch({ url: detail });
|
|
});
|
|
}
|
|
|
|
/** 主包落地:客服卡片 / 外链打开分包页(订单详情)前先落到这里,避免白屏 */
|
|
export default function OpenPage() {
|
|
useLoad((query?: Record<string, string | undefined>) => {
|
|
const orderId = String(query?.id || query?.orderId || '').trim();
|
|
if (!orderId) {
|
|
goHome();
|
|
return;
|
|
}
|
|
openOrder(orderId);
|
|
});
|
|
|
|
return (
|
|
<PageShell variant="plain">
|
|
<View className="u-empty">
|
|
<Text>正在打开…</Text>
|
|
</View>
|
|
</PageShell>
|
|
);
|
|
}
|