roamfuding-xcx/page_fenbao/remenxq.vue

502 lines
12 KiB
Vue
Raw Normal View History

2025-11-08 11:21:57 +08:00
<template>
<view class="page">
<u-navbar title="景区详情" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#262B37'
title-size='36' height='40' id="navbar">
</u-navbar>
<!-- 轮播图 -->
<view class="wrap">
<u-swiper :height="462" bg-color="#fff" :list="list"></u-swiper>
</view>
<view class="boxxx">
<view class="titlt">
<view class="">
{{xqobj.name == null ? '--' : xqobj.name}}
</view>
<view class="">
<image src="https://api.ccttiot.com/smartmeter/img/static/uIG8mJqVBzND0R3SPfSB" mode=""></image>
<image src="https://api.ccttiot.com/smartmeter/img/static/uSNNMPwNIgARSp6N5hM7" mode=""></image>
<image @click="btntel" src="https://api.ccttiot.com/smartmeter/img/static/uK3UOSMjP61UJbZCeTVd" mode=""></image>
<image @click="btndh" src="https://api.ccttiot.com/smartmeter/img/static/uIYgKFjLZQGnlf07TPhH" mode=""></image>
</view>
</view>
<view class="kftime">
开放时间每日{{xqobj.startTime == null ? '--' : xqobj.startTime}}-{{xqobj.endTime == null ? '--' : xqobj.endTime}}
</view>
<view class="dizhi">
{{xqobj.address == null ? '--' : xqobj.address}} <image src="https://api.ccttiot.com/smartmeter/img/static/u4wkK5Qag3jpDNatLVQi" mode=""></image>
</view>
<view class="liyou">
<view class="tit">
推荐理由
</view>
<view class="">
{{xqobj.reason == null ? '--' : xqobj.reason}}
</view>
</view>
<view class="titname" v-if="mplist.length > 0">
门票推荐
</view>
<view class="menpiao" v-if="mplist.length > 0">
<view class="piao" v-for="(item,index) in mplist" :key="index">
<view class="jd">
<image src="https://api.ccttiot.com/smartmeter/img/static/ukVW3RAuL6lVONjQ1kB5" mode=""></image> 景点门票
</view>
<view class="dz">
<view class="qian">
{{item.name}}
</view>
<view class="hou">
<text>{{item.price}}</text>
</view>
</view>
</view>
</view>
<view class="titname" v-if="hxjdlist.length > 0">
核心景点
</view>
<view class="jdlist" v-if="hxjdlist.length > 0">
<view class="jditem" v-for="(item,index) in hxjdlist" :key="index">
<image :src="item.picture" mode="aspectFill"></image>
<view class="name">
{{item.name}}
</view>
</view>
</view>
<view class="titname" @click="btnjqjs">
景区简介 <view class="">更多介绍 <image src="https://api.ccttiot.com/smartmeter/img/static/u4wkK5Qag3jpDNatLVQi" mode=""></image> </view>
</view>
<view class="jieshao">
{{ xqobj.description ? (xqobj.description.length > 40 ? xqobj.description.slice(0, 40) + '...' : xqobj.description) : '' }}
</view>
<view class="titname">
玩法攻略
</view>
<view class="anniu">
<view :class="tabindex == 0 ? 'active' : ''" @click="btnqh(0)">
玩法攻略
</view>
<!-- <view :class="tabindex == 1 ? 'active' : ''" @click="btnqh(1)">
住宿
</view> -->
</view>
<view class="listimg">
<view class="" v-for="(item,index) in gllist" :key="index" @click="btngl(item)">
<image :src="item.photo" mode="aspectFill"></image>
</view>
</view>
<view class="titname" v-if="xqobj.nearbyAreas.length > 0">
周边推荐
</view>
<view class="listimg">
<view class="" v-for="(item,index) in xqobj.nearbyAreas" :key="index" @click="btntj(item)">
<image :src="getFirstImage(item.picture)" mode="aspectFill"></image>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
bgc: {
backgroundColor: "#fff",
},
tabindex:0,
list: [],
id:'',
xqobj:{},
hxjdlist:[],
mplist:{},
gllist:[]
}
},
onLoad(option) {
this.id = option.id
this.getxq()
this.getjd()
this.getmp()
this.getgl()
},
methods: {
// 点击景区更多介绍
btnjqjs(){
uni.navigateTo({
url:'/page_fenbao/jqjieshao?id=' + this.id
})
},
// 点击拨打电话
btntel(){
uni.makePhoneCall({
phoneNumber: this.xqobj.phone,
success: function(res) {
console.log('拨打电话成功', res)
},
fail: function(err) {
console.error('拨打电话失败', err)
}
})
},
// 点击进行导航
btndh(){
if (!this.xqobj.latitude || !this.xqobj.longitude) {
uni.showToast({
title: '坐标数据不完整',
icon: 'none',
duration:3000
})
return
}
uni.getSetting({
success: (res) => {
if (res.authSetting['scope.userLocation'] === false) {
uni.showModal({
title: '位置权限',
content: '需要获取您的位置信息才能进行导航,请在设置中开启位置权限',
confirmText: '去设置',
success: (modalRes) => {
if (modalRes.confirm) {
uni.openSetting()
}
}
})
return
}
this.openMap()
}
})
},
// 打开地图
openMap() {
uni.openLocation({
latitude: parseFloat(this.xqobj.latitude), // 确保是数字类型
longitude: parseFloat(this.xqobj.longitude), // 确保是数字类型
name: this.xqobj.name || '目的地', // 地点名称
success: function(res) {
console.log('打开地图成功', res)
},
fail: function(err) {
console.error('打开地图失败', err)
uni.showToast({
title: '打开地图失败: ' + (err.errMsg || '未知错误'),
icon: 'none',
duration: 3000
})
}
})
},
// 点击查询其他周边景点
btntj(item){
this.id = item.id
this.getxq()
this.getjd()
this.getmp()
this.getgl()
},
// 点击跳转到攻略
btngl(item){
uni.navigateTo({
url:'/page_fenbao/gonglue/gongluexq?id=' + item.id
})
},
// 请求景区详情
getxq(){
this.$u.get(`/app/scenicArea/detail/${this.id}`).then(res =>{
if(res.code == 200){
this.xqobj = res.data
let imgArray = this.getAllImages(this.xqobj.picture)
imgArray.forEach(item =>{
this.list.push({
image: item
})
})
}
})
},
// 获取所有图片数组
getAllImages(pictureString) {
// 默认图片
const defaultImage = '/static/image/a1.png';
if (!pictureString || pictureString.trim() === '') {
return [defaultImage]
}
let imageArray = []
// 如果包含逗号,分割成数组
if (pictureString.includes(',')) {
imageArray = pictureString.split(',').map(url => url.trim()).filter(url => url && url.length > 0); // 过滤空字符串
} else {
// 单张图片
const trimmedUrl = pictureString.trim()
if (trimmedUrl && trimmedUrl.length > 0) {
imageArray = [trimmedUrl]
}
}
// 如果处理后没有有效图片,返回默认图片
if (imageArray.length === 0) {
return [defaultImage]
}
return imageArray
},
// 查询核心景点
getjd(){
this.$u.get(`/app/scenicSpot/list?pageNum=1&pageSize=99&id=${this.id}`).then(res =>{
if(res.code == 200){
this.hxjdlist = res.rows
}
})
},
// 查询门票
getmp(){
this.$u.get(`/app/ticket/list?pageNum=1&pageSize=99&areaId=${this.id}`).then(res =>{
if(res.code == 200){
this.mplist = res.rows
}
})
},
// 查询攻略
getgl(){
this.$u.get(`/app/strategy/list?pageNum=1&pageSize=99&areaId=${this.id}`).then(res =>{
if(res.code == 200){
this.gllist = res.rows
}
})
},
// 点击切换选项
btnqh(num){
this.tabindex = num
},
// 获取第一张图片
getFirstImage(pictureString) {
// 默认图片
const defaultImage = '/static/image/a1.png';
if (!pictureString || pictureString.trim() === '') {
return defaultImage;
}
// 将字符串转换为数组并取第一个
if (pictureString.includes(',')) {
const imageArray = pictureString.split(',').map(url => url.trim()).filter(url => url && url.length > 0);
return imageArray.length > 0 ? imageArray[0] : defaultImage;
} else {
// 单张图片
return pictureString.trim() || defaultImage;
}
}
}
}
</script>
<style lang="scss">
page {
background: #fff;
}
.active{
background-color: #3D3D3D !important;
color: #fff !important;
}
.listimg{
display: flex;
gap: 20rpx;
margin-top: 30rpx;
overflow: scroll;
view{
image{
width: 204rpx;
height: 204rpx;
border-radius: 10rpx;
}
}
}
.anniu{
display: flex;
margin-top: 18rpx;
view{
padding: 10rpx 26rpx;
box-sizing: border-box;
background-color: #EBEBEB;
font-weight: 600;
font-size: 28rpx;
color: #3D3D3D;
margin-right: 16rpx;
border-radius: 10rpx;
}
}
.jieshao{
margin-top: 26rpx;
font-size: 30rpx;
color: #3D3D3D;
text-indent: 2em;
}
.jdlist{
display: flex;
gap: 20rpx;
overflow: scroll;
margin-top: 32rpx;
padding-bottom: 30rpx;
.jditem{
text-align: center;
image{
width: 204rpx;
height: 204rpx;
border-radius: 10rpx;
}
view{
font-weight: 600;
font-size: 32rpx;
color: #3D3D3D;
}
}
}
.menpiao{
width: 650rpx;
max-height: 80vh;
background: #F6F6F6;
border-radius: 14rpx 14rpx 14rpx 14rpx;
margin-top: 32rpx;
padding: 34rpx 40rpx;
.piao{
.dz{
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 28rpx;
border-bottom: 1px solid #D8D8D8;
padding-bottom: 24rpx;
.qian{
font-size: 32rpx;
}
.hou{
font-size: 24rpx;
color: #3D3D3D;
text{
font-size: 24rpx;
color: #1EC28B;
font-weight: 600;
}
}
}
.jd{
display: flex;
align-items: center;
font-weight: 600;
font-size: 28rpx;
color: #3D3D3D;
image{
width: 32rpx;
height: 32rpx;
margin-right: 20rpx;
}
}
}
}
.titname{
font-weight: 600;
font-size: 36rpx;
color: #3D3D3D;
margin-top: 20rpx;
display: flex;
justify-content: space-between;
width: 100%;
align-items: center;
view{
font-size: 24rpx;
color: #3D3D3D;
display: flex;
align-items: center;
font-weight: 400;
image{
width: 32rpx;
height: 32rpx;
}
}
}
.boxxx{
width: 750rpx;
max-height: 999vh;
background: #FFFFFF;
padding: 44rpx 24rpx;
box-sizing: border-box;
border-radius: 30rpx 30rpx 0 0 !important;
position: relative;
top: -50rpx;
.liyou{
width: 100%;
max-height: 1142rpx;
background: #E7F9F4;
border-radius: 4rpx;
padding: 24rpx 40rpx;
box-sizing: border-box;
margin-top: 22rpx;
.tit{
font-weight: 600;
font-size: 32rpx;
color: #3D3D3D;
margin-top: 0;
}
view{
font-size: 24rpx;
color: #3D3D3D;
margin-top: 12rpx;
}
}
.dizhi{
font-size: 28rpx;
color: #3D3D3D;
display: flex;
align-items: center;
margin-top: 20rpx;
image{
width: 38rpx;
height: 38rpx;
}
}
.kftime{
font-size: 28rpx;
color: #3D3D3D;
margin-top: 18rpx;
}
.titlt{
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
view{
font-weight: 600;
font-size: 52rpx;
color: #3D3D3D;
display: flex;
gap: 50rpx;
image{
width: 40rpx;
height: 40rpx;
}
}
}
}
::v-deep .u-swiper-image{
width: 750rpx !important;
height: 462rpx !important;
}
::v-deep .u-swiper-indicator{
bottom: 70rpx !important;
}
::v-deep .u-list-image-wrap{
border-radius: 0 !important;
}
::v-deep .u-swiper-wrap{
border-radius: 0 !important;
}
::v-deep .u-indicator-item-round{
width: 6rpx !important;
height: 6rpx !important;
background: #606060;
border-radius: 50%;
opacity: 0.5;
}
::v-deep .u-indicator-item-round-active{
width: 46rpx !important;
height: 6rpx;
background: #fff !important;
border-radius: 9rpx 9rpx 9rpx 9rpx;
}
</style>