Guide.jsx 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. import { useState, useEffect } 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 { Image } from "@tarojs/components";
  7. import GPS from '@/assets/icons/GuideCheck/GPS.png'
  8. import copy_logo from '@/assets/icons/GuideCheck/copy_logo.png'
  9. import Cup from '@/assets/icons/GuideCheck/Cup.png'
  10. import BlackSpot from '@/assets/icons/GuideCheck/BlackSpot.png'
  11. import { getRecommendList, getExtendContent } from '@/services/home'
  12. import sleep from '@/assets/icons/GuideCheck/sleep_logo.png'
  13. import { getTaRoom, goToRoomForm } from '@/services/taRoom​'
  14. import useTrackClick from '@/utils/hooks/useTrackClick'
  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. const goContent = () => {
  31. if (roomOrderId) {
  32. goToRoomForm(roomOrderId).then((res) => {
  33. if (res.status !== 1 && res.personNum > 0) {
  34. Taro.reLaunch({
  35. url: `/pages/RoomOrder/index?roomOrderId=${roomOrderId}&status=${res.status}&roomId=${roomId}`,
  36. })
  37. }
  38. })
  39. }
  40. }
  41. useEffect(() => {
  42. goContent()
  43. }, [roomId, roomOrderId])
  44. useDidShow(() => {
  45. goContent()
  46. })
  47. const getGuidelist = () => {
  48. setLoading(true)
  49. getExtendContent('room', roomId, { pageSize: 500 }).then((res) => {
  50. setExtend(res.records || [])
  51. setIfroomId('reality')
  52. setLoading(false)
  53. })
  54. setLoading(true)
  55. }
  56. useEffect(() => {
  57. if (roomId) {
  58. setLoading(true)
  59. // 点击’去这里‘跳转导航
  60. getTaRoom(roomId).then((res) => {
  61. setTaRoomContent(res || [])
  62. setLoading(false)
  63. })
  64. //更多指引
  65. getGuidelist()
  66. getRecommendList({ location: taRoomContent.location || '' }).then((res) => {
  67. setPackage(res || [])
  68. setLoading(false)
  69. })
  70. } else {
  71. setLoading(true)
  72. getRecommendList({ location: location }).then((res) => {
  73. setPackage(res || [])
  74. setLoading(false)
  75. })
  76. return
  77. }
  78. }, [roomId, taRoomContent?.wifiPassword, taRoomContent?.parkingAddress, location, taRoomContent.location])
  79. const goRoomMap = () => {
  80. if (taRoomContent.location) {
  81. const [longitude, latitude] = taRoomContent.location.split(',').map(x => x - 0)
  82. Taro.openLocation({
  83. longitude,
  84. latitude,
  85. name: taRoomContent.roomName,
  86. address: taRoomContent.address,
  87. scale: 12,
  88. })
  89. }
  90. }
  91. const goParkMap = () => {
  92. if (taRoomContent.parkingLocation) {
  93. const [longitude, latitude] = taRoomContent.parkingLocation.split(',').map(x => x - 0)
  94. Taro.openLocation({
  95. longitude,
  96. latitude,
  97. name: taRoomContent.parkingAddress,
  98. address: taRoomContent.parkingAddress,
  99. scale: 12,
  100. })
  101. }
  102. }
  103. const wifiCopy = () => {
  104. Taro.setClipboardData({
  105. data: taRoomContent?.wifiPassword,
  106. success: e => {
  107. Taro.showToast({
  108. title: '密码已复制',
  109. icon: 'success',
  110. duration: 2000,
  111. })
  112. }
  113. })
  114. }
  115. const goIndex = () => {
  116. Taro.redirectTo({ url: '/pages/index/index' })
  117. }
  118. return (
  119. <scroll-view scrollY style={{ height: '100%' }} >
  120. <view className='Guide-Home-box'>
  121. {
  122. ifroomId === 'havenot' && (
  123. <view className='Guide-image-text-box'>
  124. <image className='Guide-images' src={sleep} />
  125. <view className='Guide-text'>您还没有入住订单哟~</view>
  126. </view>
  127. )
  128. }
  129. {/* 有民宿的情况下 */}
  130. {
  131. ifroomId === 'reality' && (
  132. <SpinBox loading={loading}>
  133. <view className='room-box-info-ROOM'>
  134. <view className='room-bi-name-ROOM' >
  135. <view className='room-bin-title-ROOM'>房屋名称</view>
  136. <view className='room-bint-nameInfo-ROOM'>{taRoomContent?.roomName}
  137. </view>
  138. </view>
  139. </view>
  140. {/* --------房屋位置-------- */}
  141. <view className='room-box-info-HouLocation'>
  142. <view className='room-bi-name-HouLocation' >
  143. <view className='room-bin-title-HouLocation'>房屋位置</view>
  144. <view className='room-bint-nameInfo-HouLocation'>
  145. <view className='room-bint-nameInfo-bool-HouLocation' >{taRoomContent?.address}</view>
  146. <view className='room-bintn-button-HouLocation' onClick={() => { goRoomMap() }}>
  147. <image className='room-bintn-image-HouLocation' src={GPS} />
  148. <text className='room-bintn-text-HouLocation'>去这里</text>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. {/* --------停车场-------- */}
  154. {
  155. !taRoomContent.parkingLocation ? null :
  156. <view className='room-box-info-Parking'>
  157. <view className='room-bi-name-Parking' >
  158. <view className='room-bin-title-Parking'>停车位置</view>
  159. <view className='room-bint-nameInfo-Parking'>
  160. <view className='room-bint-nameInfo-bool-Parking' >{taRoomContent?.parkingAddress}</view>
  161. <view className='room-bintn-button-Parking' onClick={() => { goParkMap() }}>
  162. <image className='room-bintn-image-Parking' src={GPS} />
  163. <text className='room-bintn-text-Parking'>去这里</text>
  164. </view>
  165. </view>
  166. </view>
  167. </view>
  168. }
  169. {/* --------无线网-------- */}
  170. {
  171. !taRoomContent.wifiName && !taRoomContent.wifiPassword ? null :
  172. <view className='room-box-info-WIFIContent'>
  173. <view className='room-bi-name-WIFIContent' >
  174. <view className='room-bin-title-WIFIContent'>WiFi信息</view>
  175. <view className='room-bint-nameInfo-WIFIContent'>
  176. <view className='room-bint-nameInfo-bool-WIFIContent-wifi' >名称:{taRoomContent?.wifiName}</view>
  177. <view className='room-bint-nameInfo-bool-WIFIContent-password' >密码:{taRoomContent?.wifiPassword}</view>
  178. <view className='room-bintn-button-WIFIContent' onClick={() => { wifiCopy() }}>
  179. <image className='room-bintn-image-WIFIContent' src={copy_logo} />
  180. <text className='room-bintn-text-WIFIContent'>复制</text>
  181. </view>
  182. </view>
  183. </view>
  184. </view>
  185. }
  186. {
  187. extend.length === 0 ? null :
  188. <view className='Guide-Content-box' >
  189. <view className='title-image'>
  190. <image mode='scaleToFill' className='title-image-cup' src={BlackSpot} />
  191. <text className='title-title-boss' >更多指引</text>
  192. </view>
  193. <view>
  194. {(extend || []).map((item, index) => <MoreGuide key={(index)} item={item} />)}
  195. </view>
  196. </view>
  197. }
  198. </SpinBox>
  199. )
  200. }
  201. <view className='Guide-Content-box'>
  202. <view className='title-image'>
  203. <image mode='scaleToFill' className='title-image-cup' src={Cup} />
  204. <text className='title-title-boss' >老板推荐好吃的</text>
  205. </view>
  206. </view>
  207. <view style={{ marginTop: '10rpx', paddingBottom: '60rpx' }}>
  208. {(spackage || []).map((item, index) => <BossCard det={item} st={parseFloat(item.score.toFixed(1))} key={(index)} trackClick={trackClick} taRoomContent={taRoomContent} item={item} />)}
  209. </view>
  210. <Image mode='widthFix' style={{ width: '100%' }} src='http://yz-shigongli.oss-cn-shanghai.aliyuncs.com/images/hotel_guide_help.png' onClick={goIndex} />
  211. </view>
  212. </scroll-view>
  213. )
  214. }