| | |
| | | |
| | | export default function Home() { |
| | | |
| | | const [showPrivacy, setShowPrivacy] = useState(false); |
| | | const [showPrivacy, setShowPrivacy] = useState(false); // |
| | | const [showCustomerService, setShowCustomerService] = useState(false); |
| | | const [longitude, setLongitude] = useState<number | null>(null); |
| | | const [latitude, setLatitude] = useState<number | null>(null); |
| | | const [showToolTip, setShowToolTip] = useState(true); |
| | | const [bounce, setBounce] = useState(false); |
| | | const [isLocationAuthDenied, setIsLocationAuthDenied] = useState(false); |
| | | const [isMaintain, setIsMaintain] = useState(false); |
| | | const [isOperatingArea, setIsOperatingArea] = useState(false); |
| | | |
| | | const [boxHeight, setBoxHeight] = useState<number | string>('auto'); |
| | | const startY = useRef(0); |
| | |
| | | const fullHeight = useRef(0); |
| | | const minHeight = useRef(0); |
| | | const isDragging = useRef(false); |
| | | |
| | | const getLocationInfo = () => { |
| | | Taro.getLocation({ type: 'gcj02' }) |
| | | .then(res => { |
| | | setLatitude(res.latitude); |
| | | setLongitude(res.longitude); |
| | | const myAmapFun = new amapFile.AMapWX({ key: AMAP_KEY }); |
| | | myAmapFun.getPoiAround({ |
| | | location: `${res.latitude},${res.longitude}`, |
| | | success: () => { }, |
| | | fail: () => { } |
| | | }); |
| | | }) |
| | | .catch(() => { |
| | | setIsLocationAuthDenied(true); |
| | | }); |
| | | } |
| | | |
| | | useEffect(() => { |
| | | setShowPrivacy(Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true'); |
| | |
| | | }).exec(); |
| | | }, 500); |
| | | |
| | | Taro.getLocation({ type: 'gcj02' }) |
| | | .then(res => { |
| | | setLatitude(res.latitude); |
| | | setLongitude(res.longitude); |
| | | const myAmapFun = new amapFile.AMapWX({ key: AMAP_KEY }); |
| | | myAmapFun.getPoiAround({ |
| | | location: `${res.latitude},${res.longitude}`, |
| | | success: () => { }, |
| | | fail: () => { } |
| | | }); |
| | | }) |
| | | .catch(() => { }); |
| | | Taro.getSetting({ |
| | | success: (res) => { |
| | | const auth = res.authSetting['scope.userLocation']; |
| | | if (auth === false) { |
| | | setIsLocationAuthDenied(true); |
| | | } else { |
| | | getLocationInfo(); |
| | | } |
| | | }, |
| | | fail: (err) => { |
| | | console.error('获取位置授权信息失败', err); |
| | | } |
| | | }); |
| | | }, []); |
| | | |
| | | const handleClosePrivacy = () => { |
| | |
| | | setShowCustomerService(true); |
| | | } |
| | | |
| | | const handleOpenSetting = () => { |
| | | Taro.openSetting({ |
| | | success: (res) => { |
| | | if (res.authSetting['scope.userLocation']) { |
| | | setIsLocationAuthDenied(false); |
| | | getLocationInfo(); |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | return ( |
| | | <View className="home-container"> |
| | | <Map |
| | |
| | | <View className="origin-box"> |
| | | <Image onClick={toOrigin} className="origin-icon" src={originIcon} /> |
| | | </View> |
| | | <View className="position-box"> |
| | | {/* 游客模式展示同意协议 */} |
| | | { |
| | | Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true' && <View className="visitor-stste"> |
| | | <View className="visitor-stste-tip">同意隐私协议体验更多约车体验</View> |
| | | <View onClick={() => setShowPrivacy(true)} className="visitor-stste-go">去同意</View> |
| | | </View> |
| | | } |
| | | {/* 未开启位置权限 */} |
| | | { |
| | | isLocationAuthDenied && <View className="visitor-stste"> |
| | | <View className="visitor-stste-tip">未开启位置权限,开启后即可发布行程</View> |
| | | <View onClick={handleOpenSetting} className="visitor-stste-go">去开启</View> |
| | | </View> |
| | | } |
| | | {/* 系统维护 */} |
| | | { |
| | | isMaintain && <View className="is-maintain">系统维护中,预计今日11:00恢复服务</View> |
| | | } |
| | | {/* 查看运营区域 */} |
| | | { |
| | | isOperatingArea && <View className="is-operating-area">查看运营区域</View> |
| | | } |
| | | </View> |
| | | </Map> |
| | | {/* 选择站点 */} |
| | | <View |