index.jsx 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import React, { useEffect, useState } from 'react'
  2. import Taro, { useDidShow } from '@tarojs/taro'
  3. import { View, Text, Image } from '@tarojs/components'
  4. import ContainerLayout from '../../compents/container/index'
  5. import icon from '../../assets/icon.png'
  6. import './index.scss'
  7. import userRloe from '../../util/userRole'
  8. import { useSelector } from 'react-redux'
  9. import request from '@/util/request'
  10. import uploadicon from '../../assets/uploadicon.png'
  11. const guide = (props) => {
  12. const user = useSelector(state => state.user)
  13. // const guide = useSelector(state => state.guide)
  14. const { value, houseId, ...prop } = props
  15. const [state, setState] = useState(1)
  16. const [imgurl, setImgurl] = useState('')
  17. // const [detail, setDetail] = useState({})
  18. const detail = props.dataSource || {}
  19. // useDidShow(() => {
  20. // if (houseId) {
  21. // getDetail()
  22. // }
  23. // })
  24. // useEffect(() => {
  25. // console.log(houseId, 'params33')
  26. // if (houseId) {
  27. // getDetail()
  28. // }
  29. // }, [])
  30. // const getDetail = () => {
  31. // request({ url: `/taHouse/${houseId}` }).then((res) => {
  32. // setDetail(res.data.data)
  33. // wx.setNavigationBarTitle({
  34. // title: res.data.data.title
  35. // })
  36. // })
  37. // }
  38. const onOpenLocation = (lngLat) => {
  39. const [latitude, longitude] = lngLat.split(',')
  40. console.log(lngLat, latitude, longitude)
  41. wx.openLocation({
  42. latitude: Number(latitude),
  43. longitude: Number(longitude),
  44. scale: 18,
  45. fail: (err) => {
  46. console.log(err)
  47. }
  48. })
  49. }
  50. const onToMap = (type) => {
  51. if (user.role == userRloe.customer) return
  52. switch (type) {
  53. case 'address': Taro.navigateTo({ url: `/pages/map/index?houseId=${houseId}&type=${type}` }); break;
  54. case 'park': Taro.navigateTo({ url: `/pages/map/index?houseId=${houseId}&type=${type}` }); break;
  55. case 'wifi': Taro.navigateTo({ url: `/pages/wifi/index?houseId=${houseId}` }); break;
  56. case 'image': {
  57. if (user.role == userRloe.customer) return
  58. wx.chooseImage({
  59. count: 1,
  60. sizeType: ['original', 'compressed'],
  61. sourceType: ['album',],
  62. success: (res) => {
  63. // tempFilePath可以作为img标签的src属性显示图片
  64. console.log(res)
  65. const tempFilePaths = res.tempFilePaths
  66. setImgurl(tempFilePaths[0])
  67. }
  68. }); break;
  69. }
  70. }
  71. // Taro.navigateTo({ url: `/pages/map/index?type=${type}` })
  72. }
  73. //
  74. return <View className='guide'>
  75. {!!houseId&&<View>
  76. <View className='guide-view'>
  77. <Text className='guide-view-info'>房屋位置</Text>
  78. <ContainerLayout className='guide-view-layout' style={{ display: 'flex', justifyContent: 'space-between' }} onClick={() => onToMap('address')}>
  79. <View >
  80. <View className='guide-view-layout-text1' >{detail.address}</View>
  81. {/* <View className='guide-view-layout-text2'>{detail.lngLat}</View> */}
  82. </View>
  83. {user.role == userRloe.customer && <View style={{ float: 'right' }} onClick={() => onOpenLocation(detail.lngLat)}>
  84. <Image className='icon' src={icon} />
  85. <View className='icontext' >去这里</View>
  86. </View>}
  87. </ContainerLayout>
  88. </View>
  89. <View className='guide-view'>
  90. <Text className='guide-view-info'>停车位置</Text>
  91. <ContainerLayout className='guide-view-layout' style={{ display: 'flex', justifyContent: 'space-between' }} onClick={() => onToMap('park')}>
  92. <View >
  93. <View className='guide-view-layout-text1' >{detail.parking}</View>
  94. {/* <View className='guide-view-layout-text2'>{detail.parkLngLat}</View> */}
  95. </View>
  96. {user.role == userRloe.customer && <View style={{ float: 'right' }} onClick={() => onOpenLocation(detail.parkLngLat)}>
  97. <Image className='icon' src={icon} />
  98. <View className='icontext'>去这里</View>
  99. </View>}
  100. </ContainerLayout>
  101. </View>
  102. <View className='guide-view'>
  103. <Text className='guide-view-info'>wifi信息</Text>
  104. <ContainerLayout className='guide-view-layout guide-view-wifi' onClick={() => onToMap('wifi')}>
  105. <View>
  106. <Text>名称:</Text><Text>{detail.wifiName}</Text>
  107. </View>
  108. <View>
  109. <Text>密码:</Text><Text>{detail.wifiPassword}</Text>
  110. </View>
  111. </ContainerLayout>
  112. </View>
  113. <View className='guide-view'>
  114. <Text className='guide-view-info'>其他指引</Text>
  115. {/* <ContainerLayout className='guide-view-layout guide-view-img'> */}
  116. {(detail.desc || imgurl) && <Image className='guide-view-img' mode='widthFix' onClick={() => onToMap('image')} src={imgurl || detail.desc}></Image>}
  117. {!detail.desc && !imgurl && <View style={{ padding: "300rpx" }} >
  118. <Image className='guide-view-img' mode='widthFix' onClick={() => onToMap('image')} src={uploadicon}></Image>
  119. </View>
  120. }
  121. </View>
  122. </View>}
  123. {
  124. !houseId && <View className='recommend-noorder' style={{ marginTop: 'calc(40vh)',textAlign:'center' }}>
  125. <Text>哎呀</Text>
  126. <Text>暂时没发现您的入住订单呢~</Text>
  127. </View>
  128. }
  129. </View>
  130. };
  131. export default guide