sceneryDetails.jsx 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import CustomNav from '@/components/CustomNav'
  2. import ax from '@/assets/icons/housemantj/onlove.png'
  3. import dw from '@/assets/icons/housemantj/loc-o.png'
  4. import titlejd from '@/assets/icons/housemantj/goodTourist.png'
  5. import titlems from '@/assets/icons/housemantj/goodFood.png'
  6. import { compressImage } from '@/utils'
  7. import share from '@/assets/icons/housemantj/touristShare.png'
  8. import good from '@/assets/icons/housemantj/touristGood.png'
  9. import baozan from '@/assets/icons/housemantj/bgood.png'
  10. import weibaozan from '@/assets/icons/housemantj/unLike.png'
  11. import zhuandao from "@/assets/icons/housemantj/backTop.png";
  12. import withLayout from '@/layouts'
  13. import SpinBox from "@/components/Spin/SpinBox";
  14. import TabIcon from '@/components/HorTabbar/TabIcon'
  15. import { useState, useEffect } from 'react'
  16. import { getTouristDetail, getExtendContent, getRecommendList } from '@/services/home'
  17. import { Swiper, SwiperItem, Button, View } from '@tarojs/components';
  18. import useSave from "@/utils/hooks/useSave"
  19. import useLike from "@/utils/hooks/useLike"
  20. import Cards from '@/components/foodCards/foodCards.jsx'
  21. import Taro, { useShareAppMessage } from '@tarojs/taro'
  22. import Extend from '../components/Extend/extend'
  23. import logo from "../foodDetails/laba.png";
  24. import './sceneryDetails.less'
  25. export default withLayout((props) => {
  26. const { router, person, location } = props
  27. const { id } = props.router.params
  28. const [detail, setDetail] = useState({})
  29. const [isSaved, toggleSave] = useSave(detail.isSaved, 'tourist', id)
  30. const [isLike, toggleLike] = useLike(detail.isLike, 'tourist', id)
  31. const [loading, setLoading] = useState(false)
  32. //banner图集数组
  33. const [imglist, setimglist] = useState([])
  34. const [index, setIndex] = useState(0)
  35. const handchange = (e) => {
  36. setIndex(e.detail.current)
  37. }
  38. //本店指南
  39. const [extend, setExtend] = useState([])
  40. // 推荐套餐列表
  41. const [recommend, setRecommend] = useState([])
  42. const openMap = () => {
  43. const [lng, lat] = detail.locaton.split(',')
  44. Taro.openLocation({
  45. longitude: lng - 0,
  46. latitude: lat - 0,
  47. name: detail.touristName,
  48. address: detail.address,
  49. scale: 12,
  50. })
  51. }
  52. //引导显隐
  53. const [guidance, setGuidance] = useState('shareOff')
  54. useEffect(() => {
  55. if (router.params.enterType === "share") {
  56. setGuidance('shareOn')
  57. }
  58. }, [router.params.enterType])
  59. useEffect(() => {
  60. if (id) {
  61. setLoading(true)
  62. getTouristDetail(id, { location }).then((res) => {
  63. setDetail(res)
  64. setimglist(res.imageList || [])
  65. getRecommendList({ location: res.locaton }).then((res2) => {
  66. setRecommend(res2 || [])
  67. })
  68. })
  69. getExtendContent('tourist', id, { pageSize: 500 }).then((res) => {
  70. setExtend(res.records || [])
  71. setLoading(false)
  72. })
  73. } else {
  74. getRecommendList({ location }).then((res2) => {
  75. setRecommend(res2 || [])
  76. setLoading(false)
  77. }).catch(e => {
  78. setLoading(false)
  79. })
  80. }
  81. }, [id, location])
  82. // 分享
  83. useShareAppMessage(() => {
  84. return {
  85. title: detail.touristName,
  86. path: `/pages/details/mjDetails/sceneryDetails?id=${id}&enterType=share`,
  87. imageUrl: detail.poster,
  88. }
  89. })
  90. return (
  91. <view className='page-index'>
  92. {
  93. guidance === 'shareOn' ? <view className='index-navbar'>
  94. <add-tipsFood logo={logo} custom duration={-1} />
  95. <CustomNav title='十公里' noback />
  96. </view> :
  97. <view className='index-navbar'>
  98. <CustomNav title='十公里' />
  99. </view>
  100. }
  101. <SpinBox loading={loading} style={{ overflow: 'hidden', padding: '0 30rpx', height: '100%', background: '#F8F8F8' }}>
  102. <scroll-view scrollY style={{ height: '100%' }}>
  103. <view className='storeDetails'>
  104. <View className='huadong'>
  105. <Swiper
  106. className='swiper'
  107. circular
  108. onChange={handchange}
  109. >
  110. {
  111. imglist.map((item) => (
  112. <SwiperItem>
  113. <image src={compressImage(item.url)} mode='aspectFit' className='storeImage' />
  114. </SwiperItem>
  115. ))}
  116. </Swiper>
  117. <view className='tpPage'>
  118. <text>
  119. {index + 1}/{imglist.length}
  120. </text>
  121. </view>
  122. </View>
  123. <view className='storeJs'>
  124. <view className='introduce'>
  125. <text className='storeName'>{detail.touristName}</text>
  126. </view>
  127. <view className='bz'>
  128. <image src={baozan} style={{ width: '15px', height: '15px', marginRight: '10px', marginBottom: '-2px' }} />
  129. <text className='bzRight'>爆赞{detail.likeNum}</text>
  130. </view>
  131. <view className='wz'>{detail.address}</view>
  132. <view className='dpPosition' onClick={openMap}>
  133. <image src={dw} className='dwTip' />
  134. <view className='distance'>{(detail.distance / 1000).toFixed(2)}公里<image src={zhuandao} className="zhuandao" /></view>
  135. </view>
  136. </view>
  137. </view>
  138. <view className='jdjs'>
  139. <view>{detail.description}</view>
  140. <view className='line'></view>
  141. <view className='sc' onClick={toggleSave}>
  142. <image className='scTip' src={isSaved > 0 ? ax : good} /><text>{isSaved > 0 ? '已收藏' : '加入收藏'}</text>
  143. </view>
  144. </view>
  145. <view style={{ position: 'relative', display: extend == '' ? 'none' : '' }}>
  146. <view className='title'>
  147. <image src={titlejd} />景点介绍
  148. </view>
  149. {(extend || []).map((item) => <Extend item={item} />)}
  150. </view>
  151. <view style={{ position: 'relative', marginTop: '6em', display: recommend == '' ? 'none' : '' }}>
  152. <view className='title'>
  153. <image src={titlems} />老板推荐好吃的
  154. </view>
  155. {(recommend || []).map((item) => <Cards item={item} det={item} st={parseFloat(item.score.toFixed(1))} />)}
  156. </view>
  157. <view className='botton'>这是我的底线</view>
  158. </scroll-view>
  159. </SpinBox>
  160. <view className='index-tabber weui-tabbar' style={{ background: '#fff' }}>
  161. <view className='weui-tabbar__item'>
  162. <Button openType='share' className='purebtn'><TabIcon icon={share} text='分享' /></Button>
  163. </view>
  164. <view className='weui-tabbar__item' onClick={toggleLike}>
  165. <TabIcon icon={isLike > 0 ? baozan : weibaozan} text={isLike > 0 ? "已爆赞" : "爆赞"} />
  166. </view>
  167. <view className='weui-tabbar__item' onClick={toggleSave}>
  168. <TabIcon icon={isSaved > 0 ? ax : good} text={isSaved > 0 ? "已收藏" : "加入收藏"} />
  169. </view>
  170. </view>
  171. </view>
  172. )
  173. })