123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- import { useState, useEffect, useRef } from "react";
- import Taro, { useDidShow } from '@tarojs/taro'
- import MoreGuide from "@/components/MoreGuide";
- import BossCard from '@/components/BossCard'
- import Taxi from '@/assets/icons/GuideCheck/taxi.png'
- import WiFi from '@/assets/icons/GuideCheck/WiFi.png'
- import GoHere from '@/assets/icons/GuideCheck/GoHere.png'
- import Cup from '@/assets/icons/GuideCheck/Cup.png'
- import BlackSpot from '@/assets/icons/GuideCheck/BlackSpot.png'
- import { getRecommendList, getExtendContent } from '@/services/home'
- import sleep from '@/assets/icons/GuideCheck/sleep_logo.png'
- import { getTaRoom, goToRoomForm } from '@/services/taRoom'
- import useTrackClick from '@/utils/hooks/useTrackClick'
- import showMore from '@/assets/icons/housemantj/setMore.png'
- import { useModel } from "@/store";
- import './GuideCss/style.less'
-
-
- export default (props) => {
- const { router, person, location, } = props
- let { roomId, roomOrderId } = router.params
- const [extend, setExtend] = useState([])
- const [ifroomId, setIfroomId] = useState('havenot')
- const [spackage, setPackage] = useState([])
-
- const { roomId: rid } = useModel('hotel')
-
- if (!roomId && rid) {
- roomId = rid
- }
-
- const trackClick = useTrackClick(router)
-
- // 住宿经纬度
- const Roomlog = useRef('')
- const Roomlat = useRef('')
- // 停车场经纬度
- const Parklog = useRef('')
- const Parklat = useRef('')
- const [taRoomContent, setTaRoomContent] = useState([])
- const RoomLocation = taRoomContent?.location
- //没有停车 wifi的就不显示按钮
- const [wifiButtonStyle, setWifiButtonStyle] = useState('')
- const [parkingButtonStyle, setParkingButtonStyle] = useState('')
- const [guideStyle, setGuideStyle] = useState('')
-
- //当前指南总数
- const [newextNum, setNewextNum] = useState(0)
- //全部指南个数
- const [AllextNum, setAllextNum] = useState(0)
- //指南当前页数
- const [epage, setEpage] = useState(2)
- const extendMore = () => {
- setEpage(epage + 1)
- getExtendContent('room', roomId, { pageNum: epage }).then((res) => {
- setExtend([...extend, ...res.records])
- setNewextNum(newextNum + res.records.length)
- })
- }
-
-
- useEffect(() => {
- if (roomOrderId) {
- goToRoomForm(roomOrderId).then((res) => {
- console.log("🚀 ~ file: Guide.jsx ~ line 65 ~ goToRoomForm ~ res", res)
-
- if (res.status !== 1 && res.personNum > 0) {
- Taro.navigateTo({
- url: `/pages/RoomOrder/index?roomOrderId=${roomOrderId}&status=${res.status}&roomId=${roomId}`,
- })
- }
- })
- }
- }, [roomId, roomOrderId])
-
-
- useEffect(() => {
-
- if (roomId) {
- console.log('--------------------------');
- // 点击’去这里‘跳转导航
- getTaRoom(roomId).then((res) => {
- Roomlog.current = (res.location).toString().split(',')[0]
- Roomlat.current = (res.location).toString().split(',')[1]
- Parklog.current = (res.parkingLocation).toString().split(',')[0]
- Parklat.current = (res.parkingLocation).toString().split(',')[1]
- setTaRoomContent(res || [])
- })
- //更多指引
- getExtendContent('room', roomId).then((res) => {
- setExtend(res.records || [])
- setIfroomId('reality')
- setAllextNum(res.total)
- setNewextNum(res.records.length)
- })
- // getRecommendList({ location: RoomLocation }).then((res) => {
- // setPackage(res || [])
- // })
- getRecommendList({ location: location }).then((res) => {
- setPackage(res || [])
- })
-
- } else {
- getRecommendList({ location: location }).then((res) => {
- setPackage(res || [])
- })
-
- return
- }
- // extend?.records === []
-
-
- if (taRoomContent?.wifiPassword === "") {
- setWifiButtonStyle('none')
- }
- if (taRoomContent?.parkingAddress === "") {
- setParkingButtonStyle('none')
- }
-
-
- }, [roomId, RoomLocation, taRoomContent?.wifiPassword, taRoomContent?.parkingAddress, location])
-
-
- const goRoomMap = () => {
- Taro.openLocation({
- longitude: Roomlog.current - 0,
- latitude: Roomlat.current - 0,
- name: taRoomContent.roomName,
- address: taRoomContent.address,
- scale: 12,
- })
- }
-
- const goParkMap = () => {
- Taro.openLocation({
- longitude: Parklog.current - 0,
- latitude: Parklat.current - 0,
- name: taRoomContent.parkingAddress,
- address: taRoomContent.parkingAddress,
- scale: 12,
- })
- }
-
-
-
-
- const wifiCopy = () => {
- Taro.setClipboardData({
- data: taRoomContent?.wifiPassword,
- success: e => {
- Taro.showToast({
- title: '密码已复制',
- icon: 'success',
- duration: 2000,
- })
- }
- })
- }
-
-
-
-
- return (
- <scroll-view scrollY style='height:100%;' >
-
- <view className='Guide-Home-box'>
-
-
- {
- ifroomId === 'havenot' && (
- <view className='Guide-image-text-box'>
- <image className='Guide-images' src={sleep} />
- <view className='Guide-text'>休息一下,休息一下~</view>
- </view>
- )
- }
- {/* 有民宿的情况下 */}
- {
- ifroomId === 'reality' && (
- <view>
-
- <view className='MessageCard'>
- <view className='MessageCard-title1'>
- <text className='MessageCard-left'>----------</text>
- 名称
- <text className='MessageCard-right'>----------</text>
- </view>
- <view className='MessageCard-content'>
- <view className='MessageCard-name' >{taRoomContent?.roomName}</view>
- </view>
- </view>
- <view className='MessageCard-hotle'>
- <view className='MessageCard-title1-hotle'>
- <text className='MessageCard-left-hotle'>----------</text>
- 民宿位置
- <text className='MessageCard-right-hotle'>----------</text>
- </view>
- <view className='MessageCard-content-hotle'>
- <view className='MessageCard-name-hotle' >{taRoomContent?.address}</view>
- </view>
- <view className='MessageCard-button-RoomName-hotle' onClick={() => { goRoomMap() }}>
- <image className='MessageCard-image-hotle' src={GoHere} />
- <text className='MessageCard-text-hotle' >去这里</text>
- </view>
- </view>
- <view className='MessageCard-parkView'>
- <view className='MessageCard-title1-parkView'>
- <text className='MessageCard-left-parkView'>----------</text>
- 停车位置
- <text className='MessageCard-right-parkView'>----------</text>
- </view>
- <view className='MessageCard-content-parkView'>
- <view className='MessageCard-name-parkView' >{taRoomContent?.parkingAddress}</view>
- </view>
- <view className='MessageCard-button-Park-parkView' onClick={() => { goParkMap() }} style={{ display: parkingButtonStyle }} >
- <image className='MessageCard-image-parkView' src={Taxi} />
- <text className='MessageCard-text-parkView' >去这里</text>
- </view>
- </view>
- <view className='MessageCard'>
- <view className='MessageCard-title1'>
- <text className='MessageCard-left'>----------</text>
- WiFi信息
- <text className='MessageCard-right'>----------</text>
- </view>
- <view className='MessageCard-content' style={{ display: wifiButtonStyle }} >
- <view className='MessageCard-name' >名称:{taRoomContent?.wifiName}</view>
- <view className='MessageCard-info' ><text className='MessageCard-name'>密码:</text>{taRoomContent?.wifiPassword}</view>
- </view>
-
- <view className='MessageCard-button' onClick={() => { wifiCopy() }} style={{ display: wifiButtonStyle }}>
- <image className='MessageCard-image' src={WiFi} />
- <text className='MessageCard-text'>复制</text>
- </view>
- </view>
-
- <view className='Guide-Content-box' >
- <view className='title-image' style={{ display: guideStyle }} >
- <image mode='scaleToFill' className='title-image-cup' src={BlackSpot} />
- <text className='title-title-boss' >更多指引</text>
- </view>
- {(extend || []).map((item, index) => <MoreGuide key={(index)} item={item} />)}
-
- <view className='showMore' style={{ display: newextNum == AllextNum ? 'none' : '' }} onClick={extendMore}>
- <view>点击查看更多</view>
- <image src={showMore} className='moreTip' />
- </view>
- </view>
- </view>
- )
- }
- <view className='Guide-Content-box'>
- <view className='title-image'>
- <image mode='scaleToFill' className='title-image-cup' src={Cup} />
- <text className='title-title-boss' >老板推荐好吃的</text>
- </view>
- </view>
- {(spackage || []).map((item, index) => <BossCard det={item} st={parseFloat(item.score.toFixed(1))} key={(index)} trackClick={trackClick} taRoomContent={taRoomContent} item={item} />)}
- </view>
- </scroll-view>
- )
- }
|