258 lines
6.1 KiB
Vue
258 lines
6.1 KiB
Vue
<template>
|
|
<view class="pkg-product-list">
|
|
<view class="search-box flex jc-between ai-center">
|
|
<input type="text" v-model="keyword" placeholder="搜索商品" placeholder-style="color:#949494" @confirm="search">
|
|
<image class="icon" :src="webUrl+'/20220903142935869059.png'" mode="scaleToFill" @click="search"></image>
|
|
</view>
|
|
|
|
<swiper class="swiper-box" indicator-dots indicator-color="rgba(255,255,255,.3)" indicator-active-color="#fff"
|
|
autoplay circular v-if="bannerList.length>0">
|
|
<swiper-item v-for="(item,index) in bannerList" :key="index">
|
|
<image :src="item.pic" mode="scaleToFill" @click="$global.commonJump(item.uniappUrl)"/>
|
|
</swiper-item>
|
|
</swiper>
|
|
|
|
<image class="banner" :src="webUrl+'/20230220024816081525.png'" mode="scaleToFill" @click="goStory"/>
|
|
|
|
<view class="nav-box flex">
|
|
<view class="item" :class="{'active':index===navIndex}" v-for="(item,index) in navList" :key="index"
|
|
@click="navTap(index)">{{ item.value }}
|
|
</view>
|
|
</view>
|
|
|
|
<view class="section-title bold">千县名品榜单</view>
|
|
|
|
<view class="list flex flex-wrap">
|
|
<view class="item" v-for="(item,index) in dataList" :key="index" @click="goGoods(item.id)">
|
|
<image class="label" :src="webUrl+'/20230222133041781911.png'"/>
|
|
<image class="cover" :src="item.image" mode="scaleToFill"/>
|
|
<view class="name bold one-t">{{ item.storeName }}</view>
|
|
<view class="price">¥
|
|
<text class="bold">{{ item.price }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<image class="img-nodata" :src="webUrl+'/20231023131208675588.png'" mode="scaleToFill"
|
|
v-if="dataList.length===0"/>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {countyFamous} from "@/api/product";
|
|
import {getProducts} from "@/api/store";
|
|
import {famousShareImage} from "@/api/share";
|
|
import {mapGetters} from "vuex";
|
|
import cookie from "@/utils/store/cookie";
|
|
import {userBindParent} from "@/api/user";
|
|
import {getUrlParam} from "@/utils/common.js";
|
|
|
|
export default {
|
|
name: "famousList",
|
|
data() {
|
|
return {
|
|
webUrl: this.$VUE_APP_RESOURCES_URL,
|
|
keyword: "",
|
|
page: 1,
|
|
bannerList: [],
|
|
dataList: [],
|
|
navList: [],
|
|
navIndex: 0,
|
|
partnerId: null
|
|
}
|
|
},
|
|
computed: mapGetters(["userInfo", "isLogin"]),
|
|
onShareAppMessage() {
|
|
return new Promise(async (resolve, reject) => {
|
|
const {status, data} = await famousShareImage();
|
|
if (status === 200) {
|
|
resolve({
|
|
title: '探寻有趣有味的生活方式',
|
|
path: '/pkg_product/views/famousList?partnerId=' + this.userInfo.uid,
|
|
imageUrl: data
|
|
})
|
|
}
|
|
})
|
|
},
|
|
onLoad(options) {
|
|
if (options.partnerId) {
|
|
this.partnerId = options.partnerId || null;
|
|
} else {
|
|
let obj = uni.getEnterOptionsSync();
|
|
if (options.scene != null || obj.query.scene != null) {
|
|
let query = options ? decodeURIComponent(options.scene) : decodeURIComponent(obj.query.scene);
|
|
this.partnerId = getUrlParam(query, "partnerId") || null;
|
|
}
|
|
}
|
|
if (this.partnerId) {
|
|
cookie.set("spread", this.partnerId);
|
|
userBindParent({spread: parseInt(this.partnerId)});
|
|
}
|
|
|
|
countyFamous().then(({data}) => {
|
|
this.bannerList = data.banner;
|
|
this.navList = data.countyFamousAreaList;
|
|
this.search();
|
|
})
|
|
},
|
|
onReachBottom() {
|
|
this.page++;
|
|
this.fetchList();
|
|
},
|
|
methods: {
|
|
search() {
|
|
this.page = 1;
|
|
this.dataList = [];
|
|
this.fetchList();
|
|
},
|
|
navTap(index) {
|
|
if (index === this.navIndex) return;
|
|
this.navIndex = index;
|
|
this.search();
|
|
},
|
|
fetchList() {
|
|
let param = {
|
|
isCountyFamous: 1,
|
|
page: this.page,
|
|
limit: 10,
|
|
keyword: this.keyword,
|
|
countyFamousArea: this.navList.length > 0 ? this.navList[this.navIndex].key : ""
|
|
}
|
|
|
|
getProducts(param).then(({data}) => {
|
|
for (let i = 0; i < data.length; i++) {
|
|
this.dataList.push(data[i]);
|
|
}
|
|
})
|
|
},
|
|
goGoods(id) {
|
|
uni.navigateTo({
|
|
url: `/pages/shop/GoodsCon/index?id=${id}&from=famous`
|
|
})
|
|
},
|
|
goStory() {
|
|
uni.navigateTo({
|
|
url: "/pkg_product/views/famousStory"
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
@import "@/assets/css/product.less";
|
|
|
|
.pkg-product-list {
|
|
min-height: 100vh;
|
|
box-sizing: border-box;
|
|
padding-top: 16rpx;
|
|
background: #fff;
|
|
color: #333;
|
|
|
|
.swiper-box {
|
|
margin: 18rpx 32rpx 0;
|
|
}
|
|
|
|
.banner {
|
|
width: 686rpx;
|
|
height: 160rpx;
|
|
margin: 20rpx 32rpx 0;
|
|
}
|
|
|
|
.section-title {
|
|
margin: 0 32rpx 20rpx;
|
|
font-size: 32rpx;
|
|
line-height: 42rpx;
|
|
}
|
|
|
|
.nav-box {
|
|
width: 718rpx;
|
|
box-sizing: border-box;
|
|
margin: 26rpx 32rpx;
|
|
overflow-x: auto;
|
|
|
|
.item {
|
|
margin-right: 50rpx;
|
|
color: #7D7D7D;
|
|
font-size: 26rpx;
|
|
line-height: 38rpx;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.active {
|
|
position: relative;
|
|
color: #333;
|
|
font-size: 28rpx;
|
|
line-height: 40rpx;
|
|
}
|
|
|
|
.active:after {
|
|
content: "";
|
|
display: block;
|
|
width: 100%;
|
|
height: 6rpx;
|
|
border-radius: 30px;
|
|
background: #FF564A;
|
|
}
|
|
}
|
|
|
|
.nav-box::-webkit-scrollbar {
|
|
width: 0 !important
|
|
}
|
|
|
|
.list {
|
|
padding: 0 32rpx 32rpx;
|
|
|
|
.item {
|
|
position: relative;
|
|
width: 332rpx;
|
|
margin: 0 22rpx 24rpx 0;
|
|
|
|
.label {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 72rpx;
|
|
height: 60rpx;
|
|
}
|
|
|
|
.cover {
|
|
width: 332rpx;
|
|
height: 332rpx;
|
|
border-radius: 8rpx;
|
|
}
|
|
|
|
.name {
|
|
height: 64rpx;
|
|
margin: 4rpx 0;
|
|
font-size: 34rpx;
|
|
line-height: 48rpx;
|
|
}
|
|
|
|
.price {
|
|
color: #DA0000;
|
|
font-size: 28rpx;
|
|
line-height: 36rpx;
|
|
|
|
.bold {
|
|
font-size: 34rpx;
|
|
}
|
|
}
|
|
}
|
|
|
|
.item:nth-child(2n) {
|
|
margin-right: 0;
|
|
}
|
|
|
|
.img-nodata {
|
|
position: relative;
|
|
top: 40rpx;
|
|
left: 50%;
|
|
transform: translate(-50%, 0);
|
|
width: 352rpx;
|
|
height: 338rpx;
|
|
}
|
|
}
|
|
}
|
|
</style>
|