| | |
| | | import Taro, { useDidShow } from "@tarojs/taro" |
| | | import { useEffect, useState, useRef } from 'react'; |
| | | import { View, Map, Text, Image } from '@tarojs/components'; |
| | | import { View, Map, Text, Image, Button } from '@tarojs/components'; |
| | | import './index.less'; |
| | | import PrivacyPopup from './components/privacy-popup'; |
| | | import CustomerServicePopup from '../../../robotaxi/components/customer-service'; |
| | |
| | | getCityInfoWithId, |
| | | getLocationByIP |
| | | } from '../../../utils/Robotaxi-public-method'; |
| | | import { _ROBOTAXI_WS_HOST } from '../../../constants/api'; |
| | | import { jumpTo } from '../../../utils/jump'; |
| | | import { _ROBOTAXI_WS_HOST, CDN } from '../../../constants/api'; |
| | | import { getGeofence, getBannerList, getAgreement, getOrderActive } from '../../../robotaxi/api/home'; |
| | | import { getServicePhone } from '../../../robotaxi/api/customer-service'; |
| | | import { getOrderDistance } from '../../../robotaxi/api/select-map-site'; |
| | |
| | | const [electronicAreaId, setElectronicAreaId] = useState(''); // 大头针所在电子围栏ID |
| | | const [adsorptionDistance, setAdsorptionDistance] = useState(null); // 吸附距离 |
| | | const [orderData, setOrderData] = useState<any>({}); // 订单数据 |
| | | const [isLogin, setIsLogin] = useState(false); // 是否登录 |
| | | |
| | | const [boxHeight, setBoxHeight] = useState<number>(266); // 活动区域高度 |
| | | const startY = useRef(0); // 拖动开始时的Y坐标 |
| | |
| | | // 从本地存储中获取行程状态 |
| | | const tripStatus = Taro.getStorageSync('tripStatus'); |
| | | setTripStatus(Number(tripStatus) || 0); |
| | | checkOtp(true, true).then(otp => { |
| | | checkOtp(false).then(otp => { |
| | | setIsLogin(!otp); |
| | | if (otp) { |
| | | wsManager.connect(_ROBOTAXI_WS_HOST); |
| | | getAgreement().then((res: any) => { |
| | | // 如果接口返回未同意,则显示弹窗 |
| | | if (res === false) { |
| | | setShowPrivacy(true); |
| | | Taro.setStorageSync('has_show_privicy_Robotaxi', 'false'); |
| | | } else { |
| | | setShowPrivacy(false); |
| | | Taro.setStorageSync('has_show_privicy_Robotaxi', 'true'); |
| | | } |
| | | }) |
| | | getOrderActive().then(res => { |
| | | if (!res) { |
| | | Taro.removeStorageSync('orderRouteDuration'); |
| | |
| | | Taro.getSetting({ |
| | | success: (res) => { |
| | | const auth = res.authSetting['scope.userLocation']; |
| | | console.log('getSetting获取scope.userLocation授权状态', auth); |
| | | if (auth == undefined) { |
| | | getLocationInfo(); |
| | | return; |
| | | } |
| | | if (auth === false) { |
| | | setIsLocationAuthDenied(true); |
| | | // 检查是否有选中的城市缓存 |
| | |
| | | |
| | | // 监听隐私政策显示状态 |
| | | useEffect(() => { |
| | | checkOtp(false).then(otp => { |
| | | if (otp) { |
| | | getAgreement().then((res: any) => { |
| | | console.log('获取协议状态:', res); |
| | | // 如果接口返回未同意,则显示弹窗 |
| | | if (res === false) { |
| | | setShowPrivacy(true); |
| | | Taro.setStorageSync('has_show_privicy_Robotaxi', 'false'); |
| | | } else { |
| | | setShowPrivacy(false); |
| | | Taro.setStorageSync('has_show_privicy_Robotaxi', 'true'); |
| | | } |
| | | }).catch(err => { |
| | | console.error('获取协议状态失败', err); |
| | | // 兜底逻辑:如果接口报错,根据本地缓存判断 |
| | | setShowPrivacy(Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true'); |
| | | }); |
| | | } else { |
| | | // 未登录时,根据本地缓存判断 |
| | | setShowPrivacy(Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true'); |
| | | } |
| | | }); |
| | | |
| | | getBannerList().then((res: any) => { |
| | | if (res && Array.isArray(res)) { |
| | | setBannerList(res); |
| | |
| | | |
| | | // 获取用户位置信息 |
| | | const getLocationInfo = (updateCenter = true) => { |
| | | console.log('getLocation获取用户位置信息'); |
| | | Taro.getLocation({ type: 'gcj02' }) |
| | | .then(async res => { |
| | | setIsLocationAuthDenied(false); |
| | |
| | | setCurrentSite({ name: '未知位置' }); |
| | | }); |
| | | }) |
| | | .catch(() => { |
| | | .catch((err) => { |
| | | console.log('getLocation获取用户位置失败', err); |
| | | Taro.getSetting({ |
| | | success: (res) => { |
| | | const auth = res.authSetting['scope.userLocation']; |
| | |
| | | } |
| | | </View> |
| | | </Map> |
| | | {/* 是否登录 */} |
| | | { |
| | | isLogin && |
| | | <View className={`login-bar ${isLogin ? '' : 'hide'}`}> |
| | | <View className='text'>立即登录,即可体验Robotaxi行程服务</View> |
| | | <View className='more' |
| | | onClick={() => { |
| | | jumpTo({ url: '/pages/user/login?hideBack=1' }); |
| | | }} |
| | | > |
| | | <Button className='more-btn'>立即登录</Button> |
| | | <Image src={`${CDN}/common/arrow-white-new.png`} className='more-icon'></Image> |
| | | </View> |
| | | </View> |
| | | } |
| | | {/* 选择站点 */} |
| | | <View |
| | | className="content-box" |
| | |
| | | </View> |
| | | </View> |
| | | } |
| | | |
| | | |
| | | <View onClick={toOrderDetail} className="order-status-btn">查看</View> |
| | | <Image className="order-status-bg" src={require('../../../robotaxi/assets/order-card-bg.png')} /> |
| | | </View> |