Guide.jsx 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. if (roomId) {
  67. // 点击’去这里‘跳转导航
  68. getTaRoom(roomId).then((res) => {
  69. Roomlog.current = (res.location).toString().split(',')[0]
  70. Roomlat.current = (res.location).toString().split(',')[1]
  71. Parklog.current = (res.parkingLocation).toString().split(',')[0]
  72. Parklat.current = (res.parkingLocation).toString().split(',')[1]
  73. setTaRoomContent(res || [])
  74. })
  75. //更多指引
  76. getExtendContent('room', roomId).then((res) => {
  77. setExtend(res.records || [])
  78. setIfroomId('reality')
  79. setAllextNum(res.total)
  80. setNewextNum(res.records.length)
  81. })
  82. getRecommendList({ location: location }).then((res) => {
  83. setPackage(res || [])
  84. })
  85. } else {
  86. getRecommendList({ location: location }).then((res) => {
  87. setPackage(res || [])
  88. })
  89. return
  90. }
  91. if (taRoomContent?.wifiPassword === "") {
  92. setWifiButtonStyle('none')
  93. }
  94. if (taRoomContent?.parkingAddress === "") {
  95. setParkingButtonStyle('none')
  96. }
  97. })
  98. useEffect(() => {
  99. if (roomId) {
  100. // 点击’去这里‘跳转导航
  101. getTaRoom(roomId).then((res) => {
  102. Roomlog.current = (res.location).toString().split(',')[0]
  103. Roomlat.current = (res.location).toString().split(',')[1]
  104. Parklog.current = (res.parkingLocation).toString().split(',')[0]
  105. Parklat.current = (res.parkingLocation).toString().split(',')[1]
  106. setTaRoomContent(res || [])
  107. })
  108. //更多指引
  109. getExtendContent('room', roomId).then((res) => {
  110. setExtend(res.records || [])
  111. setIfroomId('reality')
  112. setAllextNum(res.total)
  113. setNewextNum(res.records.length)
  114. })
  115. getRecommendList({ location: location }).then((res) => {
  116. setPackage(res || [])
  117. })
  118. } else {
  119. getRecommendList({ location: location }).then((res) => {
  120. setPackage(res || [])
  121. })
  122. return
  123. }
  124. if (taRoomContent?.wifiPassword === "") {
  125. setWifiButtonStyle('none')
  126. }
  127. if (taRoomContent?.parkingAddress === "") {
  128. setParkingButtonStyle('none')
  129. }
  130. }, [roomId, RoomLocation, taRoomContent?.wifiPassword, taRoomContent?.parkingAddress, location])
  131. const goRoomMap = () => {
  132. Taro.openLocation({
  133. longitude: Roomlog.current - 0,
  134. latitude: Roomlat.current - 0,
  135. name: taRoomContent.roomName,
  136. address: taRoomContent.address,
  137. scale: 12,
  138. })
  139. }
  140. const goParkMap = () => {
  141. Taro.openLocation({
  142. longitude: Parklog.current - 0,
  143. latitude: Parklat.current - 0,
  144. name: taRoomContent.parkingAddress,
  145. address: taRoomContent.parkingAddress,
  146. scale: 12,
  147. })
  148. }
  149. const wifiCopy = () => {
  150. Taro.setClipboardData({
  151. data: taRoomContent?.wifiPassword,
  152. success: e => {
  153. Taro.showToast({
  154. title: '密码已复制',
  155. icon: 'success',
  156. duration: 2000,
  157. })
  158. }
  159. })
  160. }
  161. return (
  162. <scroll-view scrollY style='height:100%;' >
  163. <view className='Guide-Home-box'>
  164. {
  165. ifroomId === 'havenot' && (
  166. <view className='Guide-image-text-box'>
  167. <image className='Guide-images' src={sleep} />
  168. <view className='Guide-text'>您还没有入住订单哟~</view>
  169. </view>
  170. )
  171. }
  172. {/* 有民宿的情况下 */}
  173. {
  174. ifroomId === 'reality' && (
  175. <view>
  176. <view className='room-box-info-ROOM'>
  177. <view className='room-bi-name-ROOM' >
  178. <view className='room-bin-title-ROOM'>房屋名称</view>
  179. <view className='room-bint-nameInfo-ROOM'>{taRoomContent?.roomName}
  180. </view>
  181. </view>
  182. </view>
  183. {/* --------房屋位置-------- */}
  184. <view className='room-box-info-HouLocation'>
  185. <view className='room-bi-name-HouLocation' >
  186. <view className='room-bin-title-HouLocation'>房屋位置</view>
  187. <view className='room-bint-nameInfo-HouLocation'>
  188. <view className='room-bint-nameInfo-bool-HouLocation' >{taRoomContent?.address}</view>
  189. <view className='room-bintn-button-HouLocation' onClick={() => { goRoomMap() }} style={{ display: wifiButtonStyle }}>
  190. <image className='room-bintn-image-HouLocation' src={GPS} />
  191. <text className='room-bintn-text-HouLocation'>去这里</text>
  192. </view>
  193. </view>
  194. </view>
  195. </view>
  196. {/* --------停车场-------- */}
  197. <view className='room-box-info-Parking'>
  198. <view className='room-bi-name-Parking' >
  199. <view className='room-bin-title-Parking'>停车位置</view>
  200. <view className='room-bint-nameInfo-Parking'>
  201. <view className='room-bint-nameInfo-bool-Parking' >{taRoomContent?.parkingAddress}</view>
  202. <view className='room-bintn-button-Parking' onClick={() => { goParkMap() }} style={{ display: wifiButtonStyle }}>
  203. <image className='room-bintn-image-Parking' src={GPS} />
  204. <text className='room-bintn-text-Parking'>去这里</text>
  205. </view>
  206. </view>
  207. </view>
  208. </view>
  209. {/* --------无线网-------- */}
  210. <view className='room-box-info-WIFIContent'>
  211. <view className='room-bi-name-WIFIContent' >
  212. <view className='room-bin-title-WIFIContent'>WiFi信息</view>
  213. <view className='room-bint-nameInfo-WIFIContent'>
  214. <view className='room-bint-nameInfo-bool-WIFIContent-wifi' >名称:{taRoomContent?.wifiName}</view>
  215. <view className='room-bint-nameInfo-bool-WIFIContent-password' >密码:{taRoomContent?.wifiPassword}</view>
  216. <view className='room-bintn-button-WIFIContent' onClick={() => { wifiCopy() }} style={{ display: wifiButtonStyle }}>
  217. <image className='room-bintn-image-WIFIContent' src={copy_logo} />
  218. <text className='room-bintn-text-WIFIContent'>复制</text>
  219. </view>
  220. </view>
  221. </view>
  222. </view>
  223. <view className='Guide-Content-box' >
  224. <view className='title-image' style={{ display: guideStyle }} >
  225. <image mode='scaleToFill' className='title-image-cup' src={BlackSpot} />
  226. <text className='title-title-boss' >更多指引</text>
  227. </view>
  228. {(extend || []).map((item, index) => <MoreGuide key={(index)} item={item} />)}
  229. {/*
  230. <view className='showMore' style={{ display: newextNum == AllextNum ? 'none' : '' }} onClick={extendMore}>
  231. <view>点击查看更多</view>
  232. <image src={showMore} className='moreTip' />
  233. </view> */}
  234. </view>
  235. </view>
  236. )
  237. }
  238. <view className='Guide-Content-box'>
  239. <view className='title-image'>
  240. <image mode='scaleToFill' className='title-image-cup' src={Cup} />
  241. <text className='title-title-boss' >老板推荐好吃的</text>
  242. </view>
  243. </view>
  244. <view style={{ marginTop: '10rpx', marginBottom: '60rpx' }}>
  245. {(spackage || []).map((item, index) => <BossCard det={item} st={parseFloat(item.score.toFixed(1))} key={(index)} trackClick={trackClick} taRoomContent={taRoomContent} item={item} />)}
  246. </view>
  247. </view>
  248. </scroll-view>
  249. )
  250. }