liaofang
2026-06-11 f62f614d891dbad1f9c1774a712e5de10e57ff1d
fix: 修改not-on-whitelist页面的逻辑https://xpd.x-peng.com/task-manage/dicpro/project/detail/X202606110003630003?parentUrl=%2Fdicpro%2Fproject%2Flist%2FGZX20260408184325000001&tabuncode=GZXL20260427111251000002
2个文件已修改
46 ■■■■■ 已修改文件
src/pages/not-on-whitelist/index.tsx 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/whitelist.ts 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/not-on-whitelist/index.tsx
@@ -1,28 +1,56 @@
import Taro, { useDidShow } from '@tarojs/taro';
import { Image, View } from '@tarojs/components';
import { useState } from 'react';
import { syncWhitelistBlockPageAccess } from '../../utils/whitelist';
import { checkOtp } from '../../utils/tools';
import { isWhiteList } from '../../robotaxi/api/home';
import { redirectToRobotaxiHomePage } from '../../utils/whitelist';
import { jumpTo } from '../../utils/jump';
import './index.less';
/** 白名单拦截图 CDN 地址。 */
// const NOT_ON_WHITELIST_IMAGE_URL = 'https://s.xiaopeng.com/xp-fe/robot-taxi/imgs/not-on-whitelist.png';
const NOT_ON_WHITELIST_IMAGE_URL = 'https://s.xiaopeng.com/xp-fe/robot-taxi/imgs/not-on-whitelist-v2.png';
const BACK_ICON = 'https://s.xiaopeng.com/xp-fe/robot-taxi/imgs/back-icon.png';
const LOGIN_PAGE_URL = '/pages/user/login';
/**
 * 非白名单拦截页。
 *
 * 进入页面后顺序执行:
 * 1. 检查是否已登录,未登录 → 跳转登录页,登录后重新触发本页 useDidShow
 * 2. 已登录 → 查询白名单
 * 3. 在白名单内 → 自动跳转 Robotaxi 首页
 * 4. 不在白名单内(含接口异常)→ 展示拦截图
 */
export default function NotOnWhitelist() {
  const [shouldRenderImage, setShouldRenderImage] = useState(false); // 白名单接口确认非白名单后才展示图片
  const [shouldRenderImage, setShouldRenderImage] = useState(false);
  useDidShow(() => {
  useDidShow(async () => {
    if (typeof Taro.hideHomeButton === 'function') {
      Taro.hideHomeButton();
    }
    setShouldRenderImage(false);
    void syncWhitelistBlockPageAccess().then((whitelistAccessResult) => {
      setShouldRenderImage(whitelistAccessResult === 'deny');
    });
    // 1. 检查登录态
    const otp = await checkOtp(false);
    if (!otp) {
      jumpTo({ url: LOGIN_PAGE_URL });
      return;
    }
    // 2. 查询白名单
    try {
      const onWhitelist = await isWhiteList();
      if (onWhitelist) {
        // 3. 在白名单内 → 回首页
        await redirectToRobotaxiHomePage();
      } else {
        // 4. 不在白名单内 → 展示拦截图
        setShouldRenderImage(true);
      }
    } catch (error) {
      console.error('白名单校验失败', error);
      // 接口异常时按不在白名单处理
      setShouldRenderImage(true);
    }
  });
  const handleBack = () => {
src/utils/whitelist.ts
@@ -118,7 +118,7 @@
    return;
  }
  await Taro.reLaunch({
  await Taro.redirectTo({
    url: ROBOTAXI_HOME_PAGE_URL,
  });
}