Guide.jsx 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. import { useState, useEffect, useRef } from "react";
  2. import Taro 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 [epage, setEpage] = useState(2)
  45. const extendMore = () => {
  46. setEpage(epage + 1)
  47. getExtendContent('room', roomId, { pageNum: epage }).then((res) => {
  48. setExtend([...extend, ...res.records])
  49. setNewextNum(newextNum + res.records.length)
  50. })
  51. }
  52. useEffect(() => {
  53. if (roomOrderId) {
  54. goToRoomForm(roomOrderId).then((res) => {
  55. console.log("🚀 ~ file: Guide.jsx ~ line 65 ~ goToRoomForm ~ res", res)
  56. if (res.status !== 1 && res.personNum > 0) {
  57. Taro.navigateTo({
  58. url: `/pages/RoomOrder/index?roomOrderId=${roomOrderId}&status=${res.status}&roomId=${roomId}`,
  59. })
  60. }
  61. })
  62. }
  63. }, [roomId, roomOrderId])
  64. useEffect(() => {
  65. if (roomId) {
  66. console.log('--------------------------');
  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: RoomLocation }).then((res) => {
  83. // setPackage(res || [])
  84. // })
  85. getRecommendList({ location: location }).then((res) => {
  86. setPackage(res || [])
  87. })
  88. } else {
  89. getRecommendList({ location: location }).then((res) => {
  90. setPackage(res || [])
  91. })
  92. return
  93. }
  94. // extend?.records === []
  95. if (taRoomContent?.wifiPassword === "") {
  96. setWifiButtonStyle('none')
  97. }
  98. if (taRoomContent?.parkingAddress === "") {
  99. setParkingButtonStyle('none')
  100. }
  101. }, [roomId, RoomLocation, taRoomContent?.wifiPassword, taRoomContent?.parkingAddress, location])
  102. const goRoomMap = () => {
  103. Taro.openLocation({
  104. longitude: Roomlog.current - 0,
  105. latitude: Roomlat.current - 0,
  106. name: taRoomContent.roomName,
  107. address: taRoomContent.address,
  108. scale: 12,
  109. })
  110. }
  111. const goParkMap = () => {
  112. Taro.openLocation({
  113. longitude: Parklog.current - 0,
  114. latitude: Parklat.current - 0,
  115. name: taRoomContent.parkingAddress,
  116. address: taRoomContent.parkingAddress,
  117. scale: 12,
  118. })
  119. }
  120. const wifiCopy = () => {
  121. Taro.setClipboardData({
  122. data: taRoomContent?.wifiPassword,
  123. success: e => {
  124. Taro.showToast({
  125. title: '密码已复制',
  126. icon: 'success',
  127. duration: 2000,
  128. })
  129. }
  130. })
  131. }
  132. return (
  133. <scroll-view scrollY style='height:100%;' >
  134. <view className='Guide-Home-box'>
  135. {
  136. ifroomId === 'havenot' && (
  137. <view className='Guide-image-text-box'>
  138. <image className='Guide-images' src={sleep} />
  139. <view className='Guide-text'>休息一下,休息一下~</view>
  140. </view>
  141. )
  142. }
  143. {/* 有民宿的情况下 */}
  144. {
  145. ifroomId === 'reality' && (
  146. <view>
  147. {/*
  148. <view className='MessageCard'>
  149. <view className='MessageCard-title1'>
  150. <text className='MessageCard-left'>----------</text>
  151. 名称
  152. <text className='MessageCard-right'>----------</text>
  153. </view>
  154. <view className='MessageCard-content'>
  155. <view className='MessageCard-name' >{taRoomContent?.roomName}</view>
  156. </view>
  157. </view>
  158. <view className='MessageCard-hotle'>
  159. <view className='MessageCard-title1-hotle'>
  160. <text className='MessageCard-left-hotle'>----------</text>
  161. 民宿位置
  162. <text className='MessageCard-right-hotle'>----------</text>
  163. </view>
  164. <view className='MessageCard-content-hotle'>
  165. <view className='MessageCard-name-hotle' >{taRoomContent?.address}</view>
  166. </view>
  167. <view className='MessageCard-button-RoomName-hotle' onClick={() => { goRoomMap() }}>
  168. <image className='MessageCard-image-hotle' src={GoHere} />
  169. <text className='MessageCard-text-hotle' >去这里</text>
  170. </view>
  171. </view>
  172. <view className='MessageCard-parkView'>
  173. <view className='MessageCard-title1-parkView'>
  174. <text className='MessageCard-left-parkView'>----------</text>
  175. 停车位置
  176. <text className='MessageCard-right-parkView'>----------</text>
  177. </view>
  178. <view className='MessageCard-content-parkView'>
  179. <view className='MessageCard-name-parkView' >{taRoomContent?.parkingAddress}</view>
  180. </view>
  181. <view className='MessageCard-button-Park-parkView' onClick={() => { goParkMap() }} style={{ display: parkingButtonStyle }} >
  182. <image className='MessageCard-image-parkView' src={Taxi} />
  183. <text className='MessageCard-text-parkView' >去这里</text>
  184. </view>
  185. </view>
  186. <view className='MessageCard'>
  187. <view className='MessageCard-title1'>
  188. <text className='MessageCard-left'>----------</text>
  189. WiFi信息
  190. <text className='MessageCard-right'>----------</text>
  191. </view>
  192. <view className='MessageCard-content' style={{ display: wifiButtonStyle }} >
  193. <view className='MessageCard-name' >名称:{taRoomContent?.wifiName}</view>
  194. <view className='MessageCard-info' ><text className='MessageCard-name'>密码:</text>{taRoomContent?.wifiPassword}</view>
  195. </view>
  196. <view className='MessageCard-button' onClick={() => { wifiCopy() }} style={{ display: wifiButtonStyle }}>
  197. <image className='MessageCard-image' src={WiFi} />
  198. <text className='MessageCard-text'>复制</text>
  199. </view>
  200. </view> */}
  201. <view className='room-box-info-ROOM'>
  202. <view className='room-bi-name-ROOM' >
  203. <view className='room-bin-title-ROOM'>房屋名称</view>
  204. <view className='room-bint-nameInfo-ROOM'>{taRoomContent?.roomName}
  205. </view>
  206. </view>
  207. </view>
  208. {/* --------房屋位置-------- */}
  209. <view className='room-box-info-HouLocation'>
  210. <view className='room-bi-name-HouLocation' >
  211. <view className='room-bin-title-HouLocation'>房屋位置</view>
  212. <view className='room-bint-nameInfo-HouLocation'>
  213. <view className='room-bint-nameInfo-bool-HouLocation' >{taRoomContent?.address}</view>
  214. <view className='room-bintn-button-HouLocation' onClick={() => { goRoomMap() }} style={{ display: wifiButtonStyle }}>
  215. <image className='room-bintn-image-HouLocation' src={GPS} />
  216. <text className='room-bintn-text-HouLocation'>去这里</text>
  217. </view>
  218. </view>
  219. </view>
  220. </view>
  221. {/* --------停车场-------- */}
  222. <view className='room-box-info-Parking'>
  223. <view className='room-bi-name-Parking' >
  224. <view className='room-bin-title-Parking'>停车位置</view>
  225. <view className='room-bint-nameInfo-Parking'>
  226. <view className='room-bint-nameInfo-bool-Parking' >{taRoomContent?.parkingAddress}</view>
  227. <view className='room-bintn-button-Parking' onClick={() => { goParkMap() }} style={{ display: wifiButtonStyle }}>
  228. <image className='room-bintn-image-Parking' src={GPS} />
  229. <text className='room-bintn-text-Parking'>去这里</text>
  230. </view>
  231. </view>
  232. </view>
  233. </view>
  234. {/* --------无线网-------- */}
  235. <view className='room-box-info-WIFIContent'>
  236. <view className='room-bi-name-WIFIContent' >
  237. <view className='room-bin-title-WIFIContent'>WiFi信息</view>
  238. <view className='room-bint-nameInfo-WIFIContent'>
  239. <view className='room-bint-nameInfo-bool-WIFIContent-wifi' >名称:{taRoomContent?.wifiName}</view>
  240. <view className='room-bint-nameInfo-bool-WIFIContent-password' >密码:{taRoomContent?.wifiPassword}</view>
  241. <view className='room-bintn-button-WIFIContent' onClick={() => { wifiCopy() }} style={{ display: wifiButtonStyle }}>
  242. <image className='room-bintn-image-WIFIContent' src={copy_logo} />
  243. <text className='room-bintn-text-WIFIContent'>复制</text>
  244. </view>
  245. </view>
  246. </view>
  247. </view>
  248. <view className='Guide-Content-box' >
  249. <view className='title-image' style={{ display: guideStyle }} >
  250. <image mode='scaleToFill' className='title-image-cup' src={BlackSpot} />
  251. <text className='title-title-boss' >更多指引</text>
  252. </view>
  253. {(extend || []).map((item, index) => <MoreGuide key={(index)} item={item} />)}
  254. <view className='showMore' style={{ display: newextNum == AllextNum ? 'none' : '' }} onClick={extendMore}>
  255. <view>点击查看更多</view>
  256. <image src={showMore} className='moreTip' />
  257. </view>
  258. </view>
  259. </view>
  260. )
  261. }
  262. <view className='Guide-Content-box'>
  263. <view className='title-image'>
  264. <image mode='scaleToFill' className='title-image-cup' src={Cup} />
  265. <text className='title-title-boss' >老板推荐好吃的</text>
  266. </view>
  267. </view>
  268. <view style={{ marginTop: '10rpx', marginBottom: '60rpx' }}>
  269. {(spackage || []).map((item, index) => <BossCard det={item} st={parseFloat(item.score.toFixed(1))} key={(index)} trackClick={trackClick} taRoomContent={taRoomContent} item={item} />)}
  270. </view>
  271. </view>
  272. </scroll-view>
  273. )
  274. }