Guide.jsx 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. import { useState, useEffect, useRef } from "react";
  2. import Taro, { useDidShow } from '@tarojs/taro'
  3. import MoreGuide from "@/components/MoreGuide";
  4. import BossCard from '@/components/BossCard'
  5. import SpinBox from "@/components/Spin/SpinBox";
  6. import GPS from '@/assets/icons/GuideCheck/GPS.png'
  7. import copy_logo from '@/assets/icons/GuideCheck/copy_logo.png'
  8. import Cup from '@/assets/icons/GuideCheck/Cup.png'
  9. import BlackSpot from '@/assets/icons/GuideCheck/BlackSpot.png'
  10. import { getRecommendList, getExtendContent } from '@/services/home'
  11. import sleep from '@/assets/icons/GuideCheck/sleep_logo.png'
  12. import { getTaRoom, goToRoomForm } from '@/services/taRoom​'
  13. import useTrackClick from '@/utils/hooks/useTrackClick'
  14. import { useModel } from "@/store";
  15. import './GuideCss/style.less'
  16. export default (props) => {
  17. const { router, person, location, } = props
  18. let { roomId, roomOrderId } = router.params
  19. const [extend, setExtend] = useState([])
  20. const [ifroomId, setIfroomId] = useState('havenot')
  21. const [spackage, setPackage] = useState([])
  22. const [loading, setLoading] = useState(false)
  23. const { roomId: rid } = useModel('hotel')
  24. if (!roomId && rid) {
  25. roomId = rid
  26. }
  27. const trackClick = useTrackClick(router)
  28. const [taRoomContent, setTaRoomContent] = useState([])
  29. //没有停车 wifi的就不显示按钮
  30. const [wifiButtonStyle, setWifiButtonStyle] = useState('')
  31. const [parkingButtonStyle, setParkingButtonStyle] = useState('')
  32. const [guideStyle, setGuideStyle] = useState('')
  33. const parkingGps = taRoomContent.parkingLocation || []
  34. const roomGps = taRoomContent.location || []
  35. const goContent = () => {
  36. if (roomOrderId) {
  37. goToRoomForm(roomOrderId).then((res) => {
  38. if (res.status !== 1 && res.personNum > 0) {
  39. Taro.reLaunch({
  40. url: `/pages/RoomOrder/index?roomOrderId=${roomOrderId}&status=${res.status}&roomId=${roomId}`,
  41. })
  42. }
  43. })
  44. }
  45. }
  46. useEffect(() => {
  47. goContent()
  48. }, [roomId, roomOrderId])
  49. useDidShow(() => {
  50. goContent()
  51. })
  52. const geiZy = () => {
  53. setLoading(true)
  54. getExtendContent('room', roomId, { pageSize: 500 }).then((res) => {
  55. // setExtend(res.records || [])
  56. setExtend(res.records)
  57. setIfroomId('reality')
  58. setLoading(false)
  59. })
  60. setLoading(true)
  61. }
  62. useEffect(() => {
  63. if (roomId) {
  64. setLoading(true)
  65. // 点击’去这里‘跳转导航
  66. getTaRoom(roomId).then((res) => {
  67. setTaRoomContent(res || [])
  68. setLoading(false)
  69. })
  70. //更多指引
  71. geiZy()
  72. getRecommendList({ location: roomGps }).then((res) => {
  73. setPackage(res || [])
  74. setLoading(false)
  75. })
  76. } else {
  77. setLoading(true)
  78. getRecommendList({ location: location }).then((res) => {
  79. setPackage(res || [])
  80. setLoading(false)
  81. })
  82. return
  83. }
  84. if (taRoomContent?.wifiPassword === "") {
  85. setWifiButtonStyle('none')
  86. }
  87. if (taRoomContent?.parkingAddress === "") {
  88. setParkingButtonStyle('none')
  89. }
  90. }, [roomId, taRoomContent?.wifiPassword, taRoomContent?.parkingAddress, location])
  91. const goRoomMap = () => {
  92. if (taRoomContent.location) {
  93. const [longitude, latitude] = taRoomContent.location.split(',').map(x => x - 0)
  94. Taro.openLocation({
  95. longitude,
  96. latitude,
  97. name: taRoomContent.roomName,
  98. address: taRoomContent.address,
  99. scale: 12,
  100. })
  101. }
  102. }
  103. const goParkMap = () => {
  104. if (taRoomContent.parkingLocation) {
  105. const [longitude, latitude] = taRoomContent.parkingLocation.split(',').map(x => x - 0)
  106. Taro.openLocation({
  107. longitude,
  108. latitude,
  109. name: taRoomContent.parkingAddress,
  110. address: taRoomContent.parkingAddress,
  111. scale: 12,
  112. })
  113. }
  114. }
  115. const wifiCopy = () => {
  116. Taro.setClipboardData({
  117. data: taRoomContent?.wifiPassword,
  118. success: e => {
  119. Taro.showToast({
  120. title: '密码已复制',
  121. icon: 'success',
  122. duration: 2000,
  123. })
  124. }
  125. })
  126. }
  127. return (
  128. <scroll-view scrollY style={{ height: '100%' }} >
  129. <view className='Guide-Home-box'>
  130. {
  131. ifroomId === 'havenot' && (
  132. <view className='Guide-image-text-box'>
  133. <image className='Guide-images' src={sleep} />
  134. <view className='Guide-text'>您还没有入住订单哟~</view>
  135. </view>
  136. )
  137. }
  138. {/* 有民宿的情况下 */}
  139. {
  140. ifroomId === 'reality' && (
  141. <SpinBox loading={loading}>
  142. <view className='room-box-info-ROOM'>
  143. <view className='room-bi-name-ROOM' >
  144. <view className='room-bin-title-ROOM'>房屋名称</view>
  145. <view className='room-bint-nameInfo-ROOM'>{taRoomContent?.roomName}
  146. </view>
  147. </view>
  148. </view>
  149. {/* --------房屋位置-------- */}
  150. {
  151. !taRoomContent.location ? <view></view>
  152. :
  153. <view className='room-box-info-HouLocation'>
  154. <view className='room-bi-name-HouLocation' >
  155. <view className='room-bin-title-HouLocation'>房屋位置</view>
  156. <view className='room-bint-nameInfo-HouLocation'>
  157. <view className='room-bint-nameInfo-bool-HouLocation' >{taRoomContent?.address}</view>
  158. <view className='room-bintn-button-HouLocation' onClick={() => { goRoomMap() }} style={{ display: wifiButtonStyle }}>
  159. <image className='room-bintn-image-HouLocation' src={GPS} />
  160. <text className='room-bintn-text-HouLocation'>去这里</text>
  161. </view>
  162. </view>
  163. </view>
  164. </view>
  165. }
  166. {/* --------停车场-------- */}
  167. {
  168. !taRoomContent.parkingLocation ? <view></view>
  169. :
  170. <view className='room-box-info-Parking'>
  171. <view className='room-bi-name-Parking' >
  172. <view className='room-bin-title-Parking'>停车位置</view>
  173. <view className='room-bint-nameInfo-Parking'>
  174. <view className='room-bint-nameInfo-bool-Parking' >{taRoomContent?.parkingAddress}</view>
  175. <view className='room-bintn-button-Parking' onClick={() => { goParkMap() }} style={{ display: wifiButtonStyle }}>
  176. <image className='room-bintn-image-Parking' src={GPS} />
  177. <text className='room-bintn-text-Parking'>去这里</text>
  178. </view>
  179. </view>
  180. </view>
  181. </view>
  182. }
  183. {/* --------无线网-------- */}
  184. <view className='room-box-info-WIFIContent'>
  185. <view className='room-bi-name-WIFIContent' >
  186. <view className='room-bin-title-WIFIContent'>WiFi信息</view>
  187. <view className='room-bint-nameInfo-WIFIContent'>
  188. <view className='room-bint-nameInfo-bool-WIFIContent-wifi' >名称:{taRoomContent?.wifiName}</view>
  189. <view className='room-bint-nameInfo-bool-WIFIContent-password' >密码:{taRoomContent?.wifiPassword}</view>
  190. <view className='room-bintn-button-WIFIContent' onClick={() => { wifiCopy() }} style={{ display: wifiButtonStyle }}>
  191. <image className='room-bintn-image-WIFIContent' src={copy_logo} />
  192. <text className='room-bintn-text-WIFIContent'>复制</text>
  193. </view>
  194. </view>
  195. </view>
  196. </view>
  197. <view className='Guide-Content-box' >
  198. <view className='title-image' style={{ display: guideStyle }} >
  199. <image mode='scaleToFill' className='title-image-cup' src={BlackSpot} />
  200. <text className='title-title-boss' >更多指引</text>
  201. </view>
  202. <view style={{ padding: '0 30rpx', boxSizing: 'border-box' }}>
  203. {(extend || []).map((item, index) => <MoreGuide key={(index)} item={item} />)}
  204. </view>
  205. </view>
  206. </SpinBox>
  207. )
  208. }
  209. <view className='Guide-Content-box'>
  210. <view className='title-image'>
  211. <image mode='scaleToFill' className='title-image-cup' src={Cup} />
  212. <text className='title-title-boss' >老板推荐好吃的</text>
  213. </view>
  214. </view>
  215. <view style={{ marginTop: '10rpx', marginBottom: '60rpx' }}>
  216. {(spackage || []).map((item, index) => <BossCard det={item} st={parseFloat(item.score.toFixed(1))} key={(index)} trackClick={trackClick} taRoomContent={taRoomContent} item={item} />)}
  217. </view>
  218. </view>
  219. </scroll-view>
  220. )
  221. }