Guide.jsx 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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 Taxi from '@/assets/icons/GuideCheck/taxi.png'
  6. import WiFi from '@/assets/icons/GuideCheck/WiFi.png'
  7. import GoHere from '@/assets/icons/GuideCheck/GoHere.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 { roomId: rid } = useModel('hotel')
  24. if (!roomId && rid) {
  25. roomId = rid
  26. }
  27. const trackClick = useTrackClick(router)
  28. // 住宿经纬度
  29. const Roomlog = useRef('')
  30. const Roomlat = useRef('')
  31. // 停车场经纬度
  32. const Parklog = useRef('')
  33. const Parklat = useRef('')
  34. const [taRoomContent, setTaRoomContent] = useState([])
  35. const RoomLocation = taRoomContent?.location
  36. //没有停车 wifi的就不显示按钮
  37. const [wifiButtonStyle, setWifiButtonStyle] = useState('')
  38. const [parkingButtonStyle, setParkingButtonStyle] = useState('')
  39. const [guideStyle, setGuideStyle] = useState('')
  40. //当前指南总数
  41. const [newextNum, setNewextNum] = useState(0)
  42. //全部指南个数
  43. const [AllextNum, setAllextNum] = useState(0)
  44. //指南当前页数
  45. const [epage, setEpage] = useState(2)
  46. const extendMore = () => {
  47. setEpage(epage + 1)
  48. getExtendContent('room', roomId, { pageNum: epage }).then((res) => {
  49. setExtend([...extend, ...res.records])
  50. setNewextNum(newextNum + res.records.length)
  51. })
  52. }
  53. useEffect(() => {
  54. if (roomOrderId) {
  55. goToRoomForm(roomOrderId).then((res) => {
  56. console.log("🚀 ~ file: Guide.jsx ~ line 65 ~ goToRoomForm ~ res", res)
  57. if (res.status !== 1 && res.personNum > 0) {
  58. Taro.navigateTo({
  59. url: `/pages/RoomOrder/index?roomOrderId=${roomOrderId}&status=${res.status}&roomId=${roomId}`,
  60. })
  61. }
  62. })
  63. }
  64. }, [roomId, roomOrderId])
  65. useEffect(() => {
  66. if (roomId) {
  67. console.log('--------------------------');
  68. // 点击’去这里‘跳转导航
  69. getTaRoom(roomId).then((res) => {
  70. Roomlog.current = (res.location).toString().split(',')[0]
  71. Roomlat.current = (res.location).toString().split(',')[1]
  72. Parklog.current = (res.parkingLocation).toString().split(',')[0]
  73. Parklat.current = (res.parkingLocation).toString().split(',')[1]
  74. setTaRoomContent(res || [])
  75. })
  76. //更多指引
  77. getExtendContent('room', roomId).then((res) => {
  78. setExtend(res.records || [])
  79. setIfroomId('reality')
  80. setAllextNum(res.total)
  81. setNewextNum(res.records.length)
  82. })
  83. // getRecommendList({ location: RoomLocation }).then((res) => {
  84. // setPackage(res || [])
  85. // })
  86. getRecommendList({ location: location }).then((res) => {
  87. setPackage(res || [])
  88. })
  89. } else {
  90. getRecommendList({ location: location }).then((res) => {
  91. setPackage(res || [])
  92. })
  93. return
  94. }
  95. // extend?.records === []
  96. if (taRoomContent?.wifiPassword === "") {
  97. setWifiButtonStyle('none')
  98. }
  99. if (taRoomContent?.parkingAddress === "") {
  100. setParkingButtonStyle('none')
  101. }
  102. }, [roomId, RoomLocation, taRoomContent?.wifiPassword, taRoomContent?.parkingAddress, location])
  103. const goRoomMap = () => {
  104. Taro.openLocation({
  105. longitude: Roomlog.current - 0,
  106. latitude: Roomlat.current - 0,
  107. name: taRoomContent.roomName,
  108. address: taRoomContent.address,
  109. scale: 12,
  110. })
  111. }
  112. const goParkMap = () => {
  113. Taro.openLocation({
  114. longitude: Parklog.current - 0,
  115. latitude: Parklat.current - 0,
  116. name: taRoomContent.parkingAddress,
  117. address: taRoomContent.parkingAddress,
  118. scale: 12,
  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. <view>
  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='Guide-Content-box' >
  202. <view className='title-image' style={{ display: guideStyle }} >
  203. <image mode='scaleToFill' className='title-image-cup' src={BlackSpot} />
  204. <text className='title-title-boss' >更多指引</text>
  205. </view>
  206. {(extend || []).map((item, index) => <MoreGuide key={(index)} item={item} />)}
  207. <view className='showMore' style={{ display: newextNum == AllextNum ? 'none' : '' }} onClick={extendMore}>
  208. <view>点击查看更多</view>
  209. <image src={showMore} className='moreTip' />
  210. </view>
  211. </view>
  212. </view>
  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. {(spackage || []).map((item, index) => <BossCard det={item} st={parseFloat(item.score.toFixed(1))} key={(index)} trackClick={trackClick} taRoomContent={taRoomContent} item={item} />)}
  222. </view>
  223. </scroll-view>
  224. )
  225. }