392 lines
8.6 KiB
Vue
392 lines
8.6 KiB
Vue
<template>
|
|
<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
|
|
<view class="index">
|
|
<u-sticky offset-top="0" h5-nav-height="0" bg-color="transparent">
|
|
<view class="index-bg">
|
|
<view class="flex row city m-b-20">
|
|
<u-icon name="map" size="28" color="#FFFFFF" style="margin-top: 6rpx;"></u-icon>
|
|
<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>
|
|
<u-navbar title-color="#fff" :is-fixed="false" :border-bottom="false"
|
|
:background="{ background: 'transparent', }" :is-back="false">
|
|
<view class="flex-1 m-t-20 flex">
|
|
<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 class="swiper">
|
|
<ad-swipers :pid="7" height="312rpx" radius="20rpx"></ad-swipers>
|
|
</view>
|
|
|
|
<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="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="list-block m-t-20" v-for="(item, index) in list" :key="index" style="width: 346rpx;height: 100%;">
|
|
<router-link :to="{path: '/bundle_b/pages/local_shop/local_shop_detail', query: {id: item.lstore_id}}">
|
|
<view class="goods-image">
|
|
<u-image :width="width" :height="width" :border-radius="10" :src="item.shopLogo"></u-image>
|
|
<view class="goods-distance">
|
|
{{item.distance}}
|
|
</view>
|
|
</view>
|
|
<view class="shop-name line-2">
|
|
{{item.shopName}}
|
|
</view>
|
|
</router-link>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<tabbar></tabbar>
|
|
</mescroll-body>
|
|
</template>
|
|
|
|
<script>
|
|
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins";
|
|
import {
|
|
mapGetters,
|
|
mapActions,
|
|
mapMutations
|
|
} from 'vuex'
|
|
import {
|
|
arraySlice,
|
|
menuJump
|
|
} from '@/utils/tools'
|
|
import {
|
|
getLocalHome,
|
|
getLocalList
|
|
} from '@/api/store.js'
|
|
|
|
export default {
|
|
mixins: [MescrollMixin],
|
|
data() {
|
|
return {
|
|
loadStatus: 'loadmore',
|
|
enable: true,
|
|
navSwiperH: '',
|
|
currentSwiper: 0,
|
|
active: 1,
|
|
distanceSort: 'asc',
|
|
navList: [],
|
|
downOption: {
|
|
auto: false,
|
|
},
|
|
upOption: {
|
|
auto: false,
|
|
empty: {
|
|
icon: 'https://zjeloong.oss-cn-hangzhou.aliyuncs.com/uniapp/order_null.png',
|
|
tip: '暂无记录', // 提示
|
|
}
|
|
},
|
|
list: [],
|
|
width: '346rpx'
|
|
}
|
|
},
|
|
async onLoad(options) {
|
|
try {
|
|
if (!options?.refresh) {
|
|
this.reLocationFunc()
|
|
this.mescroll.resetUpScroll()
|
|
}
|
|
} catch (e) {}
|
|
// 选择城市后是否刷新
|
|
if (options?.refresh) await this.getHomeFun()
|
|
|
|
this.getLocal()
|
|
},
|
|
onUnload() {
|
|
uni.$off('refreshhome')
|
|
},
|
|
onShow(options) {
|
|
this.getCartNum()
|
|
},
|
|
onHide() {
|
|
// #ifdef H5
|
|
this.enable = false
|
|
// #endif
|
|
},
|
|
methods: {
|
|
...mapActions(['initLocationFunc', 'getCartNum']),
|
|
...mapMutations(['setCityInfo']),
|
|
|
|
async getLocal() {
|
|
const {data} = await getLocalHome()
|
|
this.navList = [data]
|
|
|
|
if (this.navList[0].length == 0) {
|
|
this.navSwiperH = 0
|
|
return
|
|
}
|
|
|
|
if (this.navList[0].length <= 5) {
|
|
this.navSwiperH = 200
|
|
} else {
|
|
this.navSwiperH = 374
|
|
}
|
|
},
|
|
|
|
// 位置
|
|
async reLocationFunc() {
|
|
await this.initLocationFunc();
|
|
},
|
|
|
|
async getHomeFun() {
|
|
console.log('getHome')
|
|
console.log(this.cityInfo.id)
|
|
},
|
|
|
|
swiperChange(e) {
|
|
this.currentSwiper = e.detail.current
|
|
},
|
|
|
|
menuJump(item) {
|
|
menuJump(item)
|
|
},
|
|
|
|
upCallback(page) {
|
|
this.getLocal()
|
|
|
|
const pageNum = page.num;
|
|
const pageSize = page.size;
|
|
if (this.cityInfo && this.cityInfo.gcj02_lng) {
|
|
getLocalList({
|
|
page_size: pageSize,
|
|
page_no: pageNum,
|
|
type: 'all',
|
|
c_name: this.cityInfo.name,
|
|
longitude: this.cityInfo.gcj02_lng ?? 0,
|
|
latitude: this.cityInfo.gcj02_lat ?? 0
|
|
}).then(({
|
|
data
|
|
}) => {
|
|
if (page.num == 1) this.list = [];
|
|
const curPageData = data.list;
|
|
const curPageLen = curPageData.length;
|
|
const hasNext = !!data.more;
|
|
this.list = this.list.concat(curPageData);
|
|
this.mescroll.endSuccess(curPageLen, hasNext);
|
|
}).catch(() => {
|
|
this.mescroll.endErr()
|
|
})
|
|
}
|
|
}
|
|
},
|
|
computed: {
|
|
...mapGetters(['sysInfo', 'cityInfo', 'userInfo']),
|
|
},
|
|
watch: {
|
|
cityInfo: {
|
|
handler(val) {
|
|
this.getHomeFun()
|
|
this.mescroll.resetUpScroll()
|
|
}
|
|
},
|
|
// 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 {
|
|
position: relative;
|
|
background-image: url('https://dlh.hainings.com/uploads/images/2024010413223852d897379.jpg');
|
|
padding-top: 40rpx;
|
|
padding-bottom: 14rpx;
|
|
}
|
|
|
|
.u-navbar {
|
|
::v-deep .u-search {
|
|
padding: 0 30rpx;
|
|
}
|
|
}
|
|
|
|
.city {
|
|
flex: 0 0 auto;
|
|
position: absolute;
|
|
top: 0;
|
|
bottom: 20rpx;
|
|
left: 40rpx;
|
|
}
|
|
|
|
.nav {
|
|
position: relative;
|
|
border-radius: 20rpx;
|
|
|
|
.nav-item {
|
|
width: 20%;
|
|
|
|
.nav-icon {
|
|
width: 60rpx;
|
|
height: 60rpx;
|
|
}
|
|
}
|
|
|
|
.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 {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
justify-content: space-between;
|
|
flex-direction: row;
|
|
align-items: stretch;
|
|
margin-top: 20rpx;
|
|
padding: 0 20rpx 20rpx 20rpx;
|
|
|
|
.list-block {
|
|
background-color: #fff;
|
|
|
|
.goods-image {
|
|
position: relative;
|
|
|
|
.goods-distance {
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 0;
|
|
background-color: rgba(0, 0, 0, 0.8);
|
|
color: #fff;
|
|
font-size: 24rpx;
|
|
padding: 6rpx;
|
|
border-radius: 6rpx;
|
|
}
|
|
}
|
|
.shop-name {
|
|
padding: 20rpx 0 2rpx 10rpx;
|
|
}
|
|
}
|
|
|
|
.info {
|
|
background-color: #fff;
|
|
padding: 0 20rpx;
|
|
margin-bottom: 20rpx;
|
|
|
|
.info-header {
|
|
padding: 20rpx 0;
|
|
}
|
|
|
|
.shop-info {
|
|
width: 100%;
|
|
overflow: hidden;
|
|
margin-left: 16rpx;
|
|
|
|
.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> |