import React, { useEffect, useState } from 'react' import Taro, { useDidShow } from '@tarojs/taro' import { View, Text, Image } from '@tarojs/components' import ContainerLayout from '../../compents/container/index' import icon from '../../assets/icon.png' import './index.scss' import userRloe from '../../util/userRole' import { useSelector } from 'react-redux' import request from '@/util/request' import uploadicon from '../../assets/uploadicon.png' const guide = (props) => { const user = useSelector(state => state.user) // const guide = useSelector(state => state.guide) const { value, houseId, ...prop } = props const [state, setState] = useState(1) const [imgurl, setImgurl] = useState('') // const [detail, setDetail] = useState({}) const detail = props.dataSource || {} // useDidShow(() => { // if (houseId) { // getDetail() // } // }) // useEffect(() => { // console.log(houseId, 'params33') // if (houseId) { // getDetail() // } // }, []) // const getDetail = () => { // request({ url: `/taHouse/${houseId}` }).then((res) => { // setDetail(res.data.data) // wx.setNavigationBarTitle({ // title: res.data.data.title // }) // }) // } const onOpenLocation = (lngLat) => { const [latitude, longitude] = lngLat.split(',') console.log(lngLat, latitude, longitude) wx.openLocation({ latitude: Number(latitude), longitude: Number(longitude), scale: 18, fail: (err) => { console.log(err) } }) } const onToMap = (type) => { if (user.role == userRloe.customer) return switch (type) { case 'address': Taro.navigateTo({ url: `/pages/map/index?houseId=${houseId}&type=${type}` }); break; case 'park': Taro.navigateTo({ url: `/pages/map/index?houseId=${houseId}&type=${type}` }); break; case 'wifi': Taro.navigateTo({ url: `/pages/wifi/index?houseId=${houseId}` }); break; case 'image': { if (user.role == userRloe.customer) return wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album',], success: (res) => { // tempFilePath可以作为img标签的src属性显示图片 console.log(res) const tempFilePaths = res.tempFilePaths setImgurl(tempFilePaths[0]) } }); break; } } // Taro.navigateTo({ url: `/pages/map/index?type=${type}` }) } // return {!!houseId&& 房屋位置 onToMap('address')}> {detail.address} {/* {detail.lngLat} */} {user.role == userRloe.customer && onOpenLocation(detail.lngLat)}> 去这里 } 停车位置 onToMap('park')}> {detail.parking} {/* {detail.parkLngLat} */} {user.role == userRloe.customer && onOpenLocation(detail.parkLngLat)}> 去这里 } wifi信息 onToMap('wifi')}> 名称:{detail.wifiName} 密码:{detail.wifiPassword} 其他指引 {/* */} {(detail.desc || imgurl) && onToMap('image')} src={imgurl || detail.desc}>} {!detail.desc && !imgurl && onToMap('image')} src={uploadicon}> } } { !houseId && 哎呀 暂时没发现您的入住订单呢~ } }; export default guide