roamfuding-xcx/page_user/meishi/meishixq.vue

343 lines
8.2 KiB
Vue

<template>
<view class="page">
<u-navbar title="福鼎肉片" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#262B37'
title-size='36' height='46' id="navbar">
</u-navbar>
<!-- 头部大图 -->
<view class="hero-image">
<image :src="xqobj.imageUrl" mode="aspectFill" class="hero-img"></image>
</view>
<!-- 切换标签 -->
<view class="tab-container">
<view class="tab-item" :class="{ active: activeTab === 'intro' }" @click="switchTab('intro')">
<text class="tab-text">简介</text>
<view class="tab-line" v-if="activeTab === 'intro'"></view>
</view>
<view class="tab-item" :class="{ active: activeTab === 'merchants' }" @click="switchTab('merchants')">
<text class="tab-text">推荐商家</text>
<view class="tab-line" v-if="activeTab === 'merchants'"></view>
</view>
</view>
<!-- 内容区域 -->
<view class="content-container">
<!-- 简介内容 -->
<view class="intro-content" v-if="activeTab === 'intro'">
<view class="intro-text">
<text class="paragraph">{{xqobj.description}}</text>
</view>
</view>
<!-- 推荐商家内容 -->
<view class="merchants-content" v-if="activeTab === 'merchants'">
<view class="merchant-list">
<view class="merchant-item" v-for="(merchant, index) in merchantList" :key="index">
<view class="" style="display: flex;align-items: center;justify-content: space-between;">
<view class="merchant-left">
<image :src="merchant.picture" mode="aspectFill" class="merchant-image"></image>
</view>
<view class="merchant-right">
<view class="merchant-title">{{ merchant.name }}</view>
<view class="merchant-rating">
<text class="rating-score">{{ merchant.rating.toFixed(1) }}</text>
<text class="rating-count">{{ merchant.commentCount }}条</text>
<text class="price">¥{{ merchant. capita }}/人</text>
</view>
<view class="merchant-tags">
<text class="tag" v-for="(val,index) in merchant.types" :key="index">{{ val.name }}</text>
</view>
<view class="" style="color: #999;" v-if="merchant.startTime && merchant.endTime">
营业时间:{{merchant.startTime}} - {{merchant.endTime}}
</view>
</view>
</view>
<view class="merchant-location">
<image src="https://api.ccttiot.com/smartmeter/img/static/uqj2ln1YzY0Foise7dx1" mode=""></image>
<text class="location-text">{{ merchant.address }}</text>
<view class="go-button" @click="goToMerchant(merchant)">
<text class="go-text">立即前往</text>
</view>
</view>
</view>
<view class="" style="width: 100%;text-align: center;color: #ccc;margin-top: 30rpx;">
暂无更多推荐...
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
bgc: {
backgroundColor: "#fff",
},
activeTab: 'intro', // 当前激活的标签
merchantList: [],
id:'',
xqobj:{},
pageNum:1,
total:0
}
},
onLoad(option) {
this.id = option.id
this.getxq()
},
methods: {
// 请求美食详情
getxq(){
this.$u.get(`/app/dish/${this.id}`).then((res) => {
if(res.code == 200){
this.xqobj = res.data
}
})
},
// 请求推荐商家列表
getlist(){
this.$u.get(`/app/store/list/?dishIds=${this.id}`).then((res) => {
if(res.code == 200){
this.total = res.total
if(this.pageNum == 1){
this.pageNum++
this.merchantList = res.rows
}else{
this.pageNum++
this.merchantList = this.merchantList.concat(res.rows)
}
}
})
},
// 切换标签
switchTab(tab) {
this.activeTab = tab;
if(tab == 'intro'){
this.getxq()
}else{
this.pageNum = 1
this.getlist()
}
},
// 前往商家
goToMerchant(merchant) {
uni.openLocation({
latitude: parseFloat(merchant.areaLat), // 确保是数字类型
longitude: parseFloat(merchant.areaLon), // 确保是数字类型
name: merchant.address || '目的地', // 地点名称
success: function(res) {
console.log('打开地图成功', res);
},
fail: function(err) {
console.error('打开地图失败', err);
uni.showToast({
title: '打开地图失败: ' + (err.errMsg || '未知错误'),
icon: 'none',
duration: 3000
});
}
})
}
}
}
</script>
<style lang="scss">
::v-deep .u-title{
padding-bottom: 22rpx;
}
::v-deep .u-iconfont{
padding-bottom: 22rpx;
}
page {
background: #fff;
}
.page {
background: #fff;
min-height: 100vh;
}
// 头部大图
.hero-image {
width: 100%;
height: 400rpx;
position: relative;
.hero-img {
width: 100%;
height: 100%;
}
}
// 切换标签容器
.tab-container {
display: flex;
background: #fff;
padding: 0 60rpx;
border-bottom: 1rpx solid #f5f5f5;
.tab-item {
flex: 1;
text-align: center;
padding: 30rpx 0;
position: relative;
.tab-text {
font-size: 32rpx;
color: #666;
font-weight: 400;
}
&.active {
.tab-text {
color: #000;
font-weight: 500;
}
.tab-line {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 60rpx;
height: 4rpx;
background: #F15A24;
border-radius: 2rpx;
}
}
}
}
// 内容容器
.content-container {
padding: 40rpx 30rpx;
}
// 简介内容
.intro-content {
.intro-text {
.paragraph {
display: block;
font-size: 28rpx;
line-height: 1.8;
color: #333;
margin-bottom: 30rpx;
text-align: justify;
}
}
}
// 推荐商家内容
.merchants-content {
.merchant-list {
.merchant-item {
background: #fff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
.merchant-location {
display: flex;
align-items: center;
justify-content: space-between;
image{
width: 32rpx;
height: 32rpx;
}
.location-icon {
font-size: 24rpx;
margin-right: 8rpx;
}
.location-text {
flex: 1;
font-size: 32rpx;
color: #999;
}
.go-button {
background: #F15A24;
padding: 12rpx 24rpx;
border-radius: 20rpx;
.go-text {
font-size: 24rpx;
color: #fff;
}
}
}
.merchant-left {
margin-right: 24rpx;
.merchant-image {
width: 222rpx;
height: 222rpx;
border-radius: 12rpx;
}
}
.merchant-right {
flex: 1;
.merchant-title {
font-size: 36rpx;
font-weight: 600;
color: #000;
margin-bottom: 12rpx;
}
.merchant-rating {
display: flex;
align-items: center;
margin-bottom: 12rpx;
.rating-score {
font-size: 36rpx;
font-weight: 600;
color: #F15A24;
margin-right: 12rpx;
}
.rating-count {
font-size: 32rpx;
color: #999;
margin-right: 20rpx;
}
.price {
font-size: 32rpx;
color: #999;
}
}
.merchant-tags {
display: flex;
margin-bottom: 12rpx;
.tag {
font-size: 32rpx;
color: #999;
margin-right: 16rpx;
}
}
.merchant-highlight {
font-size: 32rpx;
color: #666;
margin-bottom: 16rpx;
line-height: 1.4;
}
}
}
}
}
</style>