Guide.jsx 9.2KB

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