shop_uniapp/pages/local_life/local_life.vue

342 lines
8.0 KiB
Vue

<template>
<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="{ use: false, toTop: {
bottom: '300rpx'
}}">
<view class="index">
<u-sticky offset-top="0" h5-nav-height="0" bg-color="transparent">
<view class="index-bg">
<u-navbar title="本地生活" title-color="#fff" :is-fixed="false" :border-bottom="false"
:background="{ background: 'transparent', }" :is-back="false">
<view class="flex row city">
<router-link class="m-l-16 flex white row-center" to="/bundle_b/pages/city/city">
<text class="m-r-6">{{ cityInfo.name || '选择' }}</text>
<u-icon name="arrow-down" size="24" color="#FFFFFF"></u-icon>
</router-link>
</view>
<view class="flex-1">
<router-link to="/bundle_b/pages/local_search/index">
<u-search wrap-bg-color="transparent" bg-color="#fff" :disabled="true" :height="62">
</u-search>
</router-link>
</view>
</u-navbar>
</view>
</u-sticky>
<view>
<view class="nav bg-white m-t-20" v-if="navList.length">
<swiper :style="'height:' + navSwiperH + 'rpx;'" @change="swiperChange">
<swiper-item v-for="(items, index) in navList" :key="index">
<view class="flex flex-wrap">
<view v-for="(item, index2) in items" :key="index2" class="nav-item m-t-30"
@tap="menuJump(item)">
<view class="flex-col col-center">
<image class="nav-icon m-b-15" :src="item.image"></image>
<view class="name xs">{{item.name}}</view>
</view>
</view>
</view>
</swiper-item>
</swiper>
<view class="dots" v-if="navList.length > 1">
<view v-for="(item, index) in navList" :key="index"
:class="'dot ' + (index == currentSwiper ? 'active' : '')"></view>
</view>
</view>
</view>
<view class="swiper">
<ad-swipers :pid="7" height="260rpx" radius="20rpx"></ad-swipers>
</view>
<view class="filter">
<view :class="active == 1 ? 'active': ''">推荐</view>
<view :class="active == 2 ? 'active': ''">销量</view>
<view :class="'flex ' + (active == 3 ? 'active': '')">
<view class="mr-0">距离</view>
<view class="flex col-center">
<view class="arrow-icon flex-col col-center row-center">
<u-icon name="arrow-up-fill" :color="distanceSort == 'asc' ? colorConfig.primary : colorConfig.normal"></u-icon>
<u-icon name="arrow-down-fill" :color="distanceSort == 'desc' ? colorConfig.primary : colorConfig.normal"></u-icon>
</view>
</view>
</view>
</view>
<view class="list">
<view class="info">
<navigator url="/bundle_b/pages/local_shop/local_shop" hover-class="none">
<view class="flex row-between col-center">
<view>
<u-image width="120rpx" height="120rpx" radius="50"
src="https://dlh.hainings.com/uploads/images/20231130103254fa5431831.jpg"></u-image>
</view>
<view class="shop-info">
<view>商家名称</view>
<view class="address">
<u-icon name="map" color="#9e9e9e" size="28"></u-icon>
浙江省 嘉兴市 秀洲区 新洲国际大酒店
</view>
</view>
</view>
</navigator>
<view>
<scroll-view style="white-space: nowrap;" :scroll-x="true">
<view class="goods-wrap">
<view class="goods-item" v-for="(item, index) in shop" :key="item.index">
<navigator url="/bundle_b/pages/local_shop/local_shop" hover-class="none">
<u-image :src="item.image" width="200rpx" height="200rpx"
border-radius="10rpx"></u-image>
<view class="line-1">{{item.name}}</view>
<view>
<price-format :color="colorConfig.primary" class="m-r-10" :first-size="34"
:second-size="26" :subscript-size="26" :price="item.price"
:weight="500"></price-format>
</view>
</navigator>
</view>
</view>
</scroll-view>
</view>
</view>
</view>
</view>
<tabbar></tabbar>
</mescroll-body>
</template>
<script>
import MescrollCompMixin from "@/components/mescroll-uni/mixins/mescroll-comp";
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins";
import {
mapGetters,
mapActions,
mapMutations
} from 'vuex'
import {
arraySlice,
menuJump
} from '@/utils/tools'
export default {
mixins: [MescrollMixin, MescrollCompMixin],
data() {
return {
enable: true,
navSwiperH: '',
currentSwiper: 0,
active: 1,
distanceSort: 'asc',
navList: [
[{
image: 'https://dlh.hainings.com/uploads/images/202401151539353104e7660.jpeg',
name: '商家入驻',
is_tab: 0,
link: '/bundle_b/pages/local_settled/index',
link_type: 1
}, ]
],
shop: [{
image: 'https://dlh.hainings.com/uploads/images/20230617152038ec2d56794.png',
name: '东龙汇金卡金卡金卡金卡金卡金卡金卡金卡金卡',
price: 1.00,
id: 1
}]
}
},
async onLoad(options) {
if (this.navList[0].length <= 5) {
this.navSwiperH = 200
} else {
this.navSwiperH = 374
}
this.navList = arraySlice(this.navList[0])
try {
if (!options?.refresh) {
this.reLocationFunc();
this.getHome()
}
} catch (e) {}
// 选择城市后是否刷新
if (options?.refresh) await this.getHomeFun()
},
onUnload() {
uni.$off('refreshhome')
},
onShow(options) {
this.getCartNum()
},
onHide() {
// #ifdef H5
this.enable = false
// #endif
},
methods: {
...mapActions(['initLocationFunc', 'getCartNum']),
...mapMutations(['setCityInfo']),
// 位置
async reLocationFunc() {
await this.initLocationFunc();
},
async downCallback() {
this.mescroll.endSuccess(0, false)
},
async getHomeFun() {
console.log('getHome')
console.log(this.cityInfo.id)
},
swiperChange(e) {
this.currentSwiper = e.detail.current
},
menuJump(item) {
menuJump(item)
},
},
computed: {
...mapGetters(['sysInfo', 'cityInfo']),
},
watch: {
cityInfo: {
handler(val) {
this.getHomeFun()
}
},
// navList(val) {
// if (val[0].length <= 5) {
// this.navSwiperH = 200
// } else {
// this.navSwiperH = 374
// }
// this.navList = arraySlice(val)
// },
list(val) {
this.goodsList = val
}
}
}
</script>
<style lang="scss">
page {
padding: 0;
}
.index {
min-height: calc(100vh - var(--window-bottom));
.index-bg {
background-image: url('https://dlh.hainings.com/uploads/images/2024010413223852d897379.jpg');
}
.u-navbar {
::v-deep .u-search {
padding: 0 30rpx;
}
}
.city {
flex: 0 0 auto;
position: relative;
}
.nav {
position: relative;
border-radius: 20rpx;
.nav-item {
width: 20%;
.nav-icon {
width: 82rpx;
height: 82rpx;
}
}
.dots {
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 20rpx;
display: flex;
.dot {
width: 10rpx;
height: 6rpx;
border-radius: 6rpx;
margin-right: 10rpx;
background-color: rgba(255, 44, 60, 0.4);
&.active {
width: 20rpx;
background-color: $-color-primary;
}
}
}
}
.swiper {
margin: 20rpx 0;
}
.filter {
display: flex;
align-items: center;
padding: 30rpx;
.arrow-icon {
transform: scale(0.5);
}
view {
margin-right: 20rpx;
}
.mr-0 {
margin-right: 0;
}
.active {
color: $-color-primary;
}
}
.list {
margin-top: 20rpx;
padding: 0 0 20rpx;
.info {
background-color: #fff;
padding: 0 20rpx;
margin-bottom: 20rpx;
.shop-info {
width: 100%;
overflow: hidden;
.address {
margin-top: 8rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.goods-wrap {
.goods-item {
margin-top: 20rpx;
padding: 0 20rpx 20rpx;
display: inline-block;
width: 240rpx;
}
}
}
}
}
</style>