Guide.jsx 9.4KB

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