477 lines
13 KiB
Vue
477 lines
13 KiB
Vue
<template>
|
|
<view class="health-foods">
|
|
<view
|
|
class="banner-wrap"
|
|
v-if="topImageConfig && topImageConfig.backgroundImage"
|
|
>
|
|
<image
|
|
:src="topImageConfig.backgroundImage"
|
|
class="banner-img"
|
|
mode="widthFix"
|
|
/>
|
|
<view class="banner-tabs v12-justify-center">
|
|
<image
|
|
class="tab-btn v12-mr-3"
|
|
:src="travelButtonSrc"
|
|
mode="widthFix"
|
|
@click="toSanctun"
|
|
/>
|
|
<image
|
|
class="tab-btn"
|
|
:src="wellnessButtonSrc"
|
|
mode="widthFix"
|
|
/>
|
|
</view>
|
|
</view>
|
|
<!-- <view class="v12-justify-center v12-mt-3" v-if="hasRankData">
|
|
<image
|
|
class="title-img"
|
|
:src="webUrl + '/orderIcon/rankTitle.png'"
|
|
mode="widthFix"
|
|
></image>
|
|
</view> -->
|
|
<!-- <vi
|
|
<view
|
|
class="rank-item v12-justify-start v12-align-center v12-mb-4"
|
|
v-for="(item, index) in k.products"
|
|
@click="toGoods(item.productId)"
|
|
:key="index"
|
|
>
|
|
<view
|
|
class="rank-tag"
|
|
:class="{ 'rank2-bg': index === 1, 'rank3-bg': index === 2 }"
|
|
>
|
|
<view
|
|
class="rank-2"
|
|
:class="{
|
|
'rank2-2-bg': index === 1,
|
|
'rank3-3-bg': index === 2,
|
|
}"
|
|
>
|
|
<view
|
|
class="rank-3"
|
|
:class="{
|
|
'rank2-4-bg': index === 1,
|
|
'rank3-4-bg': index === 2,
|
|
}"
|
|
>
|
|
<view
|
|
class="rank-4"
|
|
:class="{
|
|
'rank2-bg': index === 1,
|
|
'rank3-bg': index === 2,
|
|
}"
|
|
>{{ index + 1 }}</view
|
|
>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="rank-img">
|
|
<image
|
|
:src="item.productImage"
|
|
mode="widthFix"
|
|
class="rank-img"
|
|
></image>
|
|
</view>
|
|
<view class="v12-ml-2">
|
|
<view
|
|
class="v12-font-bold v12-font-24 one-t"
|
|
style="width: 160rpx"
|
|
>{{ item.productTitle }}</view
|
|
>
|
|
<view class="v12-font-22 more-t">{{ item.productDesc }}</view>
|
|
</view>
|
|
</view>
|
|
</view> -->
|
|
<view class="v12-justify-between v12-align-center v12-px-3 tabs-wrap">
|
|
<view
|
|
class="tab v12-font-34 v12-dark-text v12-mr-5"
|
|
v-for="(tab, index) in tabs"
|
|
@click="handleTab(index,tab)"
|
|
:class="{'activeTab' : index === actived}"
|
|
:key="index">
|
|
<text>{{ tab.name }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="waterfall-box v12-mt-3 v12-px-2">
|
|
<view class="waterfall-column">
|
|
<view v-for="(item, index) in leftItems" :key="index" class="v12-pa-1" @click="toStore(item)">
|
|
<view class="img">
|
|
<video
|
|
class="img"
|
|
:src="item.cover"
|
|
:play-btn-position="'center'"
|
|
:show-fullscreen-btn="false"
|
|
:show-center-play-btn="false"
|
|
:show-play-btn="false"
|
|
:controls="false"
|
|
:poster="item.cover + '?vframe/jpg/offset/1'"
|
|
v-if="item.coverType === 2">
|
|
</video>
|
|
<image v-else class="img" :src="item.cover" mode="aspectFill"></image>
|
|
<view class="v12-white-text address">
|
|
<image
|
|
class="map-icon v12-mr-1"
|
|
:src="webUrl + '/orderIcon/map_white.png'"
|
|
></image>
|
|
<text class="v12-font-28">{{ item.areaName }}</text>
|
|
</view>
|
|
</view>
|
|
<view v-if="item.intro" class="v12-font-bold v12-font-28 v12-mt-1 more-t desc-txt">{{ item.intro }}</view>
|
|
<view class="v12-justify-start v12-align-center v12-mb-1">
|
|
<view class="atr">
|
|
<image class="atr" :src="item.avatar"></image>
|
|
</view>
|
|
<view class="v12-font-26 v12-ml-2 v12-dark-text one-t">{{ item.name }}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="waterfall-column">
|
|
<view v-for="(item, index) in rightItems" :key="index" class="v12-pa-1" @click="toStore(item)">
|
|
<view class="img">
|
|
<video
|
|
class="img"
|
|
:src="item.cover"
|
|
:play-btn-position="'center'"
|
|
:show-fullscreen-btn="false"
|
|
:show-center-play-btn="false"
|
|
:show-play-btn="false"
|
|
:controls="false"
|
|
:poster="item.cover + '?vframe/jpg/offset/1'"
|
|
v-if="item.coverType === 2">
|
|
</video>
|
|
<image v-else class="img" :src="item.cover" mode="aspectFill"></image>
|
|
<view class="v12-white-text address">
|
|
<image
|
|
class="map-icon v12-mr-1"
|
|
:src="webUrl + '/orderIcon/map_white.png'"
|
|
></image>
|
|
<text class="v12-font-28">{{ item.areaName }}</text>
|
|
</view>
|
|
</view>
|
|
<view v-if="item.intro" class="v12-font-bold v12-font-28 v12-mt-1 more-t desc-txt">{{ item.intro }}</view>
|
|
<view class="v12-justify-start v12-align-center v12-mb-1">
|
|
<view class="atr">
|
|
<image class="atr" :src="item.avatar"></image>
|
|
</view>
|
|
<view class="v12-font-26 v12-ml-2 v12-dark-text one-t">{{ item.name }}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view v-if="items.length === 0" class="v12-justify-center v12-mt-6">
|
|
<view class="no-data-wrap">
|
|
<image :src="webUrl + '/orderIcon/微信图片_20241009220552.png'" mode="widthFix"></image>
|
|
</view>
|
|
</view>
|
|
<view v-if="items.length > 0" class="load-more-status">
|
|
{{ loading ? '加载中...' : (hasMore ? '上拉加载更多' : '没有更多了') }}
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import { getCategory } from '@/api/health'
|
|
import { getJiaLouList } from '@/api/qianxian'
|
|
import { getWellnessTopImage } from '@/api/health'
|
|
export default {
|
|
data() {
|
|
return {
|
|
webUrl: this.$VUE_APP_RESOURCES_URL,
|
|
tabs: [],
|
|
items: [],
|
|
actived: 0,
|
|
cityId: '',
|
|
cityName: '',
|
|
categoryId: null,
|
|
topImageConfig: {},
|
|
page: 1,
|
|
pageSize: 10,
|
|
loading: false,
|
|
hasMore: true
|
|
}
|
|
},
|
|
computed: {
|
|
travelButtonSrc() {
|
|
const config = this.topImageConfig || {}
|
|
return config.travelButtonImage || config.travelButtonImage || ''
|
|
},
|
|
wellnessButtonSrc() {
|
|
const config = this.topImageConfig || {}
|
|
return config.wellnessButtonImageFocus || config.wellnessButtonImage || ''
|
|
},
|
|
leftItems() {
|
|
return this.items.filter((item, index) => index % 2 === 0)
|
|
},
|
|
rightItems() {
|
|
return this.items.filter((item, index) => index % 2 !== 0)
|
|
}
|
|
},
|
|
onLoad(opts) {
|
|
console.log(opts);
|
|
|
|
this.cityId = opts.city
|
|
this.cityName = decodeURIComponent(decodeURIComponent(opts.cityName))
|
|
getCategory().then(res => {
|
|
this.tabs = res.data
|
|
this.categoryId = res.data[0].id
|
|
this.getList(true)
|
|
})
|
|
this.getTopImage()
|
|
},
|
|
onReachBottom() {
|
|
this.getList()
|
|
},
|
|
onUnload() {
|
|
// uni.navigateBack({
|
|
// delta: 0
|
|
// })
|
|
},
|
|
methods: {
|
|
handleTab(index, tab) {
|
|
if (this.actived === index) return
|
|
this.actived = index
|
|
this.categoryId = tab.id
|
|
this.getList(true)
|
|
},
|
|
toSanctun() {
|
|
uni.redirectTo({
|
|
url: '/pkg_product/views/healthSanctum?city=' + this.cityId + '&cityName=' + this.cityName
|
|
})
|
|
},
|
|
toFoods() {
|
|
uni.redirectTo({
|
|
url: '/pkg_product/views/healthFoods?city=' + this.cityId + '&cityName=' + this.cityName
|
|
})
|
|
},
|
|
getPageList(data) {
|
|
if (Array.isArray(data)) {
|
|
return data
|
|
}
|
|
return (data && (data.records || data.list || data.data)) || []
|
|
},
|
|
getHasMore(data, list, page) {
|
|
const pageCount = Number(
|
|
data && (data.pages || data.totalPage || data.last_page || data.pageCount || 0)
|
|
)
|
|
const total = Number(
|
|
data && (data.total || data.totalCount || data.count || 0)
|
|
)
|
|
if (pageCount > 0) {
|
|
return page < pageCount
|
|
}
|
|
if (total > 0) {
|
|
return page * this.pageSize < total
|
|
}
|
|
return list.length >= this.pageSize
|
|
},
|
|
getList(reset = false) {
|
|
if (this.loading) return
|
|
if (!reset && !this.hasMore) return
|
|
const page = reset ? 1 : this.page
|
|
if (reset) {
|
|
this.page = 1
|
|
this.hasMore = true
|
|
this.items = []
|
|
}
|
|
const params = {
|
|
// countyId: this.cityId,
|
|
goodCityId: this.cityId,
|
|
wellnessPlaceCateId : this.categoryId,
|
|
shopType: 'wellnessCate',
|
|
page,
|
|
limit: this.pageSize
|
|
}
|
|
this.loading = true
|
|
getJiaLouList(params).then(res => {
|
|
const list = this.getPageList(res.data)
|
|
this.items = page === 1 ? list : this.items.concat(list)
|
|
this.hasMore = this.getHasMore(res.data, list, page)
|
|
this.page = page + 1
|
|
}).finally(() => {
|
|
this.loading = false
|
|
})
|
|
},
|
|
search() {
|
|
uni.navigateTo({
|
|
url: '/pkg_product/views/healthSearch?city=' + this.cityId + '&cityName=' + this.cityName
|
|
})
|
|
},
|
|
toStore(item) {
|
|
if(item.dataType === 'wellnessPlace'){
|
|
this.$yrouter.push({
|
|
path: '/pagesInn/inn/innHome',
|
|
query: {
|
|
id: item.hotelId
|
|
}
|
|
})
|
|
}else{
|
|
uni.navigateTo({ url: '/pkg_product/views/sojoumStore?id=' + item.id })
|
|
}
|
|
},
|
|
getTopImage() {
|
|
const cached = uni.getStorageSync('wellnessTopImageConfig')
|
|
if (cached) {
|
|
this.topImageConfig = cached
|
|
}
|
|
getWellnessTopImage().then(res => {
|
|
this.topImageConfig = res.data || {}
|
|
uni.setStorageSync('wellnessTopImageConfig', this.topImageConfig)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style lang="less" scoped>
|
|
.health-foods{
|
|
background: #fff;
|
|
overflow-x: hidden;
|
|
}
|
|
.banner-wrap{
|
|
position: relative;
|
|
}
|
|
.banner-img{
|
|
width: 100%;
|
|
height: auto;
|
|
display: block;
|
|
will-change: transform;
|
|
}
|
|
.banner-tabs{
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
top: 40rpx;
|
|
display: flex;
|
|
justify-content: center;
|
|
}
|
|
.tab-btn{
|
|
width: 200rpx;
|
|
will-change: transform;
|
|
display: block;
|
|
height: auto;
|
|
}
|
|
.tabs-wrap{
|
|
white-space: nowrap;
|
|
overflow: scroll;
|
|
.tab:last-child{
|
|
margin-right: 0 !important;
|
|
}
|
|
}
|
|
.map-icon{
|
|
width: 28rpx;
|
|
height: 28rpx;
|
|
}
|
|
.arrow-icon{
|
|
width: 25rpx;
|
|
height: 25rpx;
|
|
}
|
|
.icon{
|
|
width: 30rpx;
|
|
height: 30rpx;
|
|
}
|
|
.flex-1{
|
|
flex: 1;
|
|
}
|
|
.swap{
|
|
overflow: auto;
|
|
}
|
|
.trave-item-wrap{
|
|
position: relative;
|
|
}
|
|
.trave-btn{
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
margin: auto;
|
|
bottom: 30rpx;
|
|
text-align: center;
|
|
width: 212rpx;
|
|
background: rgba(255,255,255,0.7);
|
|
border-radius: 60rpx;
|
|
font-size: 28rpx;
|
|
font-weight: bold;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 10rpx 20rpx;
|
|
}
|
|
.trave-item{
|
|
width: 382rpx;
|
|
height: 272rpx;
|
|
background: rgba(230,178,178,0.39);
|
|
border-radius: 20rpx;
|
|
position: relative;
|
|
}
|
|
.desc-txt {
|
|
line-height: 40rpx;
|
|
max-height: 78rpx;
|
|
}
|
|
.address{
|
|
position: absolute;
|
|
left: 30rpx;
|
|
bottom: 30rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.sanctup-items{
|
|
display: grid;
|
|
grid-template-columns: 50% 50%;
|
|
}
|
|
.waterfall-box {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: flex-start;
|
|
}
|
|
.waterfall-column {
|
|
width: 49.9%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
.img{
|
|
height: 670rpx;
|
|
}
|
|
}
|
|
.atr{
|
|
width: 52rpx;
|
|
height: 52rpx;
|
|
border-radius: 50%;
|
|
}
|
|
.img{
|
|
width: 100%;
|
|
border-radius: 16rpx;
|
|
position: relative;
|
|
overflow: hidden;
|
|
max-height: 460rpx;
|
|
display: block;
|
|
min-height: 200rpx;
|
|
}
|
|
.sanctum-wrap{
|
|
min-height: 100vh;
|
|
background-color: #fff;
|
|
padding: 20rpx ;
|
|
}
|
|
.tab{
|
|
position: relative;
|
|
}
|
|
.slider{
|
|
position: absolute;
|
|
width: 100%;
|
|
height: 6rpx;
|
|
background: linear-gradient(to right, #C52733 0%, rgba(255,255,255,0) 100%);
|
|
border-radius: 6rpx;
|
|
bottom: 5rpx;
|
|
}
|
|
.activeTab{
|
|
font-size: 34rpx;
|
|
background: #C52733;
|
|
color: #fff !important;
|
|
border-radius: 100rpx;
|
|
padding: 4rpx 20rpx;
|
|
}
|
|
.load-more-status{
|
|
padding: 24rpx 0 40rpx;
|
|
text-align: center;
|
|
font-size: 24rpx;
|
|
color: #999;
|
|
}
|
|
</style>
|