Guide.jsx 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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 showMore from '@/assets/icons/housemantj/setMore.png'
  15. import { useModel } from "@/store";
  16. import './GuideCss/style.less'
  17. export default (props) => {
  18. const { router, person, location, } = props
  19. let { roomId, roomOrderId } = router.params
  20. const [extend, setExtend] = useState([])
  21. const [ifroomId, setIfroomId] = useState('havenot')
  22. const [spackage, setPackage] = useState([])
  23. const [loading, setLoading] = useState(false)
  24. const { roomId: rid } = useModel('hotel')
  25. if (!roomId && rid) {
  26. roomId = rid
  27. }
  28. const trackClick = useTrackClick(router)
  29. const [taRoomContent, setTaRoomContent] = useState([])
  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. setTaRoomContent(res || [])
  69. setLoading(false)
  70. })
  71. //更多指引
  72. geiZy()
  73. getRecommendList({ location: roomGps }).then((res) => {
  74. setPackage(res || [])
  75. setLoading(false)
  76. })
  77. } else {
  78. setLoading(true)
  79. getRecommendList({ location: location }).then((res) => {
  80. setPackage(res || [])
  81. setLoading(false)
  82. })
  83. return
  84. }
  85. if (taRoomContent?.wifiPassword === "") {
  86. setWifiButtonStyle('none')
  87. }
  88. if (taRoomContent?.parkingAddress === "") {
  89. setParkingButtonStyle('none')
  90. }
  91. }, [roomId, roomGps, taRoomContent?.wifiPassword, taRoomContent?.parkingAddress, location])
  92. const goRoomMap = () => {
  93. if (taRoomContent.location) {
  94. const [longitude, latitude] = taRoomContent.location.split(',').map(x => x - 0)
  95. Taro.openLocation({
  96. longitude,
  97. latitude,
  98. name: taRoomContent.roomName,
  99. address: taRoomContent.address,
  100. scale: 12,
  101. })
  102. }
  103. }
  104. const goParkMap = () => {
  105. if (taRoomContent.parkingLocation) {
  106. const [longitude, latitude] = taRoomContent.parkingLocation.split(',').map(x => x - 0)
  107. Taro.openLocation({
  108. longitude,
  109. latitude,
  110. name: taRoomContent.parkingAddress,
  111. address: taRoomContent.parkingAddress,
  112. scale: 12,
  113. })
  114. }
  115. }
  116. const wifiCopy = () => {
  117. Taro.setClipboardData({
  118. data: taRoomContent?.wifiPassword,
  119. success: e => {
  120. Taro.showToast({
  121. title: '密码已复制',
  122. icon: 'success',
  123. duration: 2000,
  124. })
  125. }
  126. })
  127. }
  128. return (
  129. <scroll-view scrollY style={{ height: '100%' }} >
  130. <view className='Guide-Home-box'>
  131. {
  132. ifroomId === 'havenot' && (
  133. <view className='Guide-image-text-box'>
  134. <image className='Guide-images' src={sleep} />
  135. <view className='Guide-text'>您还没有入住订单哟~</view>
  136. </view>
  137. )
  138. }
  139. {/* 有民宿的情况下 */}
  140. {
  141. ifroomId === 'reality' && (
  142. <SpinBox loading={loading}>
  143. <view className='room-box-info-ROOM'>
  144. <view className='room-bi-name-ROOM' >
  145. <view className='room-bin-title-ROOM'>房屋名称</view>
  146. <view className='room-bint-nameInfo-ROOM'>{taRoomContent?.roomName}
  147. </view>
  148. </view>
  149. </view>
  150. {/* --------房屋位置-------- */}
  151. {
  152. !roomGps ? <view></view>
  153. :
  154. <view className='room-box-info-HouLocation'>
  155. <view className='room-bi-name-HouLocation' >
  156. <view className='room-bin-title-HouLocation'>房屋位置</view>
  157. <view className='room-bint-nameInfo-HouLocation'>
  158. <view className='room-bint-nameInfo-bool-HouLocation' >{taRoomContent?.address}</view>
  159. <view className='room-bintn-button-HouLocation' onClick={() => { goRoomMap() }} style={{ display: wifiButtonStyle }}>
  160. <image className='room-bintn-image-HouLocation' src={GPS} />
  161. <text className='room-bintn-text-HouLocation'>去这里</text>
  162. </view>
  163. </view>
  164. </view>
  165. </view>
  166. }
  167. {/* --------停车场-------- */}
  168. {
  169. !parkingGps ? <view></view>
  170. :
  171. <view className='room-box-info-Parking'>
  172. <view className='room-bi-name-Parking' >
  173. <view className='room-bin-title-Parking'>停车位置</view>
  174. <view className='room-bint-nameInfo-Parking'>
  175. <view className='room-bint-nameInfo-bool-Parking' >{taRoomContent?.parkingAddress}</view>
  176. <view className='room-bintn-button-Parking' onClick={() => { goParkMap() }} style={{ display: wifiButtonStyle }}>
  177. <image className='room-bintn-image-Parking' src={GPS} />
  178. <text className='room-bintn-text-Parking'>去这里</text>
  179. </view>
  180. </view>
  181. </view>
  182. </view>
  183. }
  184. {/* --------无线网-------- */}
  185. <view className='room-box-info-WIFIContent'>
  186. <view className='room-bi-name-WIFIContent' >
  187. <view className='room-bin-title-WIFIContent'>WiFi信息</view>
  188. <view className='room-bint-nameInfo-WIFIContent'>
  189. <view className='room-bint-nameInfo-bool-WIFIContent-wifi' >名称:{taRoomContent?.wifiName}</view>
  190. <view className='room-bint-nameInfo-bool-WIFIContent-password' >密码:{taRoomContent?.wifiPassword}</view>
  191. <view className='room-bintn-button-WIFIContent' onClick={() => { wifiCopy() }} style={{ display: wifiButtonStyle }}>
  192. <image className='room-bintn-image-WIFIContent' src={copy_logo} />
  193. <text className='room-bintn-text-WIFIContent'>复制</text>
  194. </view>
  195. </view>
  196. </view>
  197. </view>
  198. <view className='Guide-Content-box' >
  199. <view className='title-image' style={{ display: guideStyle }} >
  200. <image mode='scaleToFill' className='title-image-cup' src={BlackSpot} />
  201. <text className='title-title-boss' >更多指引</text>
  202. </view>
  203. <view style={{ padding: '0 30rpx', boxSizing: 'border-box' }}>
  204. {(extend || []).map((item, index) => <MoreGuide key={(index)} item={item} />)}
  205. </view>
  206. </view>
  207. </SpinBox>
  208. )
  209. }
  210. <view className='Guide-Content-box'>
  211. <view className='title-image'>
  212. <image mode='scaleToFill' className='title-image-cup' src={Cup} />
  213. <text className='title-title-boss' >老板推荐好吃的</text>
  214. </view>
  215. </view>
  216. <view style={{ marginTop: '10rpx', marginBottom: '60rpx' }}>
  217. {(spackage || []).map((item, index) => <BossCard det={item} st={parseFloat(item.score.toFixed(1))} key={(index)} trackClick={trackClick} taRoomContent={taRoomContent} item={item} />)}
  218. </view>
  219. </view>
  220. </scroll-view>
  221. )
  222. }