mshop-view/pages/index/component/shopList.vue

715 lines
20 KiB
Vue

<template>
<view :style="'margin-top:' +mbConfig+'rpx;background:'+bgColor">
<view class="explosion" :style="'margin:0 '+prConfig+'rpx'">
<view class="common-hd" mode="widthFix" v-if="logoUrl">
<image class="title-img" mode="widthFix" :src="logoUrl"></image>
</view>
<view class="mer-box">
<!-- 风格一 -->
<block v-if="tabConfig == 0">
<view class="mer-item" v-for="(item, index) in brandList" :key="index" :style="'border-radius:'+bgStyle+'rpx'">
<view class="mer-hd" @click="goStore(item.mer_id)" :style="'border-radius:'+bgStyle+'rpx '+bgStyle+'rpx 0 0'">
<image :src="item.mer_banner"></image>
<view class="mer-name">
<image :src="item.mer_avatar"></image>
<view class="txt line1">{{ item.mer_name }}</view>
<text v-if="item.type_name" class="store_type" :style="'background:'+themeColor">{{ item.type_name }}</text>
<text v-else-if="item.is_trader" class="store_type" :style="'background:'+themeColor">自营</text>
</view>
</view>
<view class="pro-box">
<navigator
:url="`/pages/goods_details/index?id=${itemn.product_id}`"
hover-class="none"
class="pro-item"
v-for="(itemn, indexn) in item.all_recommend"
:key="indexn"
v-if="item.all_recommend.length <= 3"
>
<view class="picture">
<easy-loadimage mode="widthFix" :image-src="itemn.image"></easy-loadimage>
<view v-if="itemn.border_pic" :style="{ backgroundImage: `url(${itemn.border_pic})` }" class="border-picture"></view>
</view>
<view v-if="titleShow" class="name line1">{{itemn.store_name}}</view>
<view v-if="priceShow" class="price" :style="'color:'+themeColor">
<text>¥</text>
{{ itemn.price }}
</view>
</navigator>
</view>
</view>
</block>
<!-- 风格二 -->
<block v-else-if="tabConfig == 1">
<view class="mer_count">
<view class="item" v-for="(item, index) in brandList" :key="index" @click="goStore(item.mer_id)">
<image :src="item.mer_avatar" mode="widthFix"></image>
</view>
</view>
</block>
<!-- 风格三 -->
<block v-else-if="tabConfig == 2">
<view class="mobile-page-style-3">
<view class="shop-block" v-for="(item, index) in brandList" :key="index" :style="'border-radius:'+bgStyle+'rpx'" @click="goStore(item.mer_id)">
<view class="shop-block-top">
<view class="image">
<image class="store-avatar" :src="item.mer_avatar" mode="widthFix"></image>
<view class="store-type" v-if="item.type_name">{{ item.type_name }}</view>
</view>
<view class="store-desc">
<view class="store-name">
<view class="store-title">{{ item.mer_name }}</view>
<view class="store-name-label" v-if="item.is_best">优选</view>
</view>
<view class="statistics">
<view class="stars">
<text :class="['iconfont', 'icon-shitixing', 'stars-i',{'active-i': (item.service_score >= 1)}]"></text>
<text :class="['iconfont', 'icon-shitixing', 'stars-i',{'active-i': (item.service_score >= 2)}]"></text>
<text :class="['iconfont', 'icon-shitixing', 'stars-i',{'active-i': (item.service_score >= 3)}]"></text>
<text :class="['iconfont', 'icon-shitixing', 'stars-i',{'active-i': (item.service_score >= 4)}]"></text>
<text :class="['iconfont', 'icon-shitixing', 'stars-i',{'active-i': (item.service_score >= 5)}]"></text>
</view>
<view class="per-avg">人均 {{ item.avg_consumption }} 元</view>
<!--<view class="month-sale">月售 {{ item.month_sales }}</view>-->
<view class="month-sale">销量 {{ item.sales }}</view>
</view>
<view class="class-address">
<view class="store-class">{{ item.category_name }}</view>
<view class="store-address">{{ item.mer_address }}</view>
<view class="store-distance">{{ item.distance }}</view>
</view>
<view class="other-label-list" v-if="item.mer_label">
<view class="other-label-item" v-for="label_name in item.mer_label.split(',')">
{{label_name}}
</view>
</view>
</view>
</view>
<view class="goods-list">
<!--仅显示2个商品-->
<view class="goods-block" v-for="(goodsInfo,index) in item.all_recommend" :key="index" v-if="index <= 1">
<view class="left-label">
<view class="left-label-tag" v-if="goodsInfo.brand_name">{{ goodsInfo.brand_name }}</view>
</view>
<div class="right-desc">
<!--<view class="goods-info-left">-->
<text class="iconfont icon-goumaishangpin goods-info-left-icon"></text>
<view class="price">¥{{ goodsInfo.price }}</view>
<view class="line-price">¥{{ goodsInfo.ot_price }}</view>
<!--</view>-->
<!--<view class="goods-info-right">-->
<view class="goods-name">{{ goodsInfo.store_name }}</view>
<text class="iconfont icon-xiangyou goods-info-right-icon"></text>
<!--</view>-->
</div>
</view>
</view>
</view>
</view>
</block>
<!-- 统一底部 -->
<view class="more-shop" @click="moreShop">
<text>更多店铺</text>
<text class="iconfont icon-xiangyou"></text>
</view>
</view>
</view>
</view>
</template>
<script>
import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue';
import { storeList } from '@/api/api.js';
import { mapGetters } from 'vuex';
import { configMap } from '@/utils';
export default {
computed: configMap(['hide_mer_status']),
components: {
easyLoadimage
},
props: {
dataConfig: {
type: Object,
default: () => {}
}
},
data() {
return {
brandList: [],
mbConfig: this.dataConfig.mbConfig.val*2, //页面间距
prConfig: this.dataConfig.prConfig.val*2, //背景间距
logoUrl: this.dataConfig.logoConfig.url,
bgStyle: this.dataConfig.bgStyle.type ? '16' : 0,
bgColor: this.dataConfig.bgColor.color[0].item,
themeColor: this.dataConfig.themeColor.color[0].item,
tabConfig: this.dataConfig.tabConfig.tabVal, //展示样式
numConfig: this.dataConfig.numConfig.val,
titleShow: this.dataConfig.titleShow.val,
priceShow: this.dataConfig.priceShow.val,
diy_id: this.dataConfig.did,
unique: this.dataConfig.timestamp,
latitude: 0,
longitude: 0
}
},
created() {},
mounted() {
this.selfLocation();
},
methods: {
// 进店看看
goStore(id) {
if (this.hide_mer_status != 1) {
uni.navigateTo({
url: `/pages/store/home/index?id=${id}`
});
}
},
// 更多店铺
moreShop() {
uni.navigateTo({
url: `/pages/store/shopStreet/index?cate_id=&type_id=`
});
},
// 品牌好店
storeMerchant() {
storeList({
diy_id: this.diy_id,
unique: this.unique,
page: 1,
limit: this.numConfig ? this.numConfig : 4,
is_best: 1,
latitude: this.latitude || 0,
longitude: this.longitude || 0
}).then(res => {
this.brandList = res.data.list;
});
},
//获取定位
selfLocation() {
let self = this
uni.getLocation({
type: 'gcj02',
success: (res) => {
console.log(res)
let latitude, longitude;
latitude = res.latitude.toString();
longitude = res.longitude.toString();
self.latitude = res.latitude
self.longitude = res.longitude
console.log(res)
self.storeMerchant();
},
complete: function() {
// self.getList();
self.storeMerchant();
}
});
},
}
};
</script>
<style scoped lang="scss">
.explosion {
.common-hd {
display: flex;
align-items: center;
justify-content: center;
.title-img{
width: 242rpx;
margin: 20rpx 0;
}
}
.mer-box {
margin-bottom: 20rpx;
.mer-item {
margin-bottom: 20rpx;
background-color: #fff;
text-align: center;
.mer-hd {
position: relative;
width: 100%;
height: 200rpx;
border-radius: 16rpx 16rpx 0 0;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
.mer-name {
position: absolute;
left: 20rpx;
top: 20rpx;
display: flex;
max-width: 60%;
padding: 8rpx 8rpx 8rpx 4rpx;
border-radius: 26rpx;
background: #fff;
font-weight: bold;
font-size: 12px;
align-items: center;
image {
width: 38rpx;
height: 38rpx;
margin-right: 10rpx;
border-radius: 50%;
}
.txt {
flex: 1;
line-height: 19px;
height: 19px;
}
.store_type {
font-size: 10px;
color: #fff;
background-color: #e93323;
padding: 0 5px;
line-height: 19px;
height: 19px;
margin-left: 20rpx;
border-radius: 30rpx;
}
}
}
/deep/.easy-loadimage,/deep/uni-image,image,/deep/.loadfail-img{
width: 100%;
height: 214rpx;
}
.pro-box {
display: flex;
align-items: center;
padding: 20rpx 20rpx 30rpx;
.pro-item {
width: 31.3%;
margin-right: 3.05%;
.picture,/deep/.easy-loadimage,/deep/uni-image,/deep/image,/deep/.loadfail-img {
width: 100%;
height: 214rpx;
position: relative;
}
.sell_out {
display: flex;
width: 110rpx;
height: 110rpx;
align-items: center;
justify-content: center;
border-radius: 100%;
background: rgba(0,0,0,.6);
color: #fff;
font-size: 24rpx;
position: absolute;
top: 50%;
left: 50%;
margin: -55rpx 0 0 -55rpx;
&::before{
content: "";
display: block;
width: 100rpx;
height: 100rpx;
border-radius: 100%;
border: 1px dashed #fff;
position: absolute;
top: 5rpx;
left: 5rpx;
}
}
.border-picture {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: center/cover no-repeat;
}
.name{
padding: 6rpx 9rpx;
margin-top: 6rpx;
}
.price {
margin-top: 5rpx;
font-size: 28rpx;
color: $theme-color;
font-weight: bold;
text {
font-size: 28rpx;
}
}
&:last-child {
margin-right: 0;
}
.picture {
position: relative;
}
.border-picture {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: center/cover no-repeat;
}
}
}
}
.more-shop {
display: flex;
align-items: center;
justify-content: center;
background-color: #ffffff;
padding: 27rpx 0;
color: #999999;
font-size: 26rpx;
.icon-xiangyou {
font-size: 22rpx;
}
}
}
}
.mer_count{
display: flex;
flex-wrap: wrap;
padding: 20rpx;
align-items: center;
.item{
flex: 4;
height: 140rpx;
margin: 0 2% 30rpx 0;
background: #FEFEFF;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
/deep/uni-image,/deep/image,/deep/.easy-loadimage{
width: 100%!important;
max-height: 140rpx;
}
&:nth-child(4n){
margin-right: 0;
}
}
}
.mobile-page-style-3{
--store-avatar-size-: 200rpx;
.shop-block{
--shop-block-background-: #ffffff;
padding: 20rpx;
background: var(--shop-block-background-);
margin-bottom: 20rpx;
.shop-block-top{
width: 100%;
height: var(--store-avatar-size-);
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
.image{
height: var(--store-avatar-size-);
width: var(--store-avatar-size-);
position: relative;
border-radius: 10rpx;
overflow: hidden;
.store-avatar{
width: 100% !important;
height: 100% !important;
}
.store-type{
position: absolute;
top: 0;
left: 0;
height: 36rpx;
line-height: 36rpx;
padding: 0 10rpx;
font-size: 24rpx;
background: #f5dda9;
color: #000000;
border-radius: 6rpx;
}
}
.store-desc{
padding-left: 20rpx;
width: calc(100% - var(--store-avatar-size-));
height: var(--store-avatar-size-);
display: inline-flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: space-evenly;
align-items: flex-start;
.store-name{
width: 100%;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
height: 50rpx;
line-height: 50rpx;
.store-title{
font-size: 30rpx;
font-weight: bold;
max-width: calc(100% - 80rpx);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.store-name-label{
height: 34rpx;
line-height: 36rpx;
font-size: 24rpx;
background: black;
color: #93674b;
border-radius: 6rpx;
width: 70rpx;
text-align: center;
margin-left: 10rpx;
}
}
.statistics{
--stars-width-: 160rpx;
--month-sale-width-: 130rpx;
--stars-size-: calc((var(--stars-width-) - 10rpx) / 5);
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
width: 100%;
height: 50rpx;
font-size: 24rpx;
.stars{
width: var(--stars-width-);
.stars-i{
height: var(--stars-size-) !important;
line-height: var(--stars-size-) !important;;
width: var(--stars-size-) !important;
background: #cccccc;
color: #FFFFFF;
float: left;
text-align: center;
border-radius: 2rpx;
font-size: 22rpx;
}
.stars-i:not(:last-child){
margin-right: 2rpx;
}
.active-i{
background: #f65906!important;
}
}
.per-avg{
width: calc(100% - (var(--stars-width-) + var(--month-sale-width-)));
padding-left: 10rpx;
height: 30rpx;
line-height: 32rpx;
color: #919191;
}
.month-sale{
text-align: right;
width: var(--month-sale-width-);
height: 30rpx;
line-height: 32rpx;
color: #919191;
}
}
.class-address{
height: 50rpx;
width: 100%;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
color: #7a7a7a;
.store-class{
width: 130rpx;
white-space: nowrap;
overflow: hidden;
margin-right: 10rpx;
}
.store-address{
width: calc(100% - 130rpx - 120rpx);
white-space: nowrap;
overflow: hidden;
}
.store-distance{
color: #3a3a3a;
width: 120rpx;
white-space: nowrap;
overflow: hidden;
text-align: right;
}
}
.other-label-list{
height: 50rpx;
width: 100%;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
white-space: nowrap;
overflow: hidden;
.other-label-item{
height: 36rpx;
line-height: 36rpx;
padding: 0 10rpx;
background: #fcf0e6;
color: #f19d75;
border-radius: 6rpx;
font-size: 24rpx;
}
.other-label-item:not(:last-child){
margin-right: 10rpx;
}
}
}
}
.goods-list{
width: 100%;
display: inline-flex;
flex-direction: column;
flex-wrap: nowrap;
align-items: flex-start;
justify-content: flex-start;
.goods-block{
width: 100%;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
height: 60rpx;
.left-label{
--left-label-tag-border-color-: #f8ddd4;
width: var(--store-avatar-size-);
height: 100%;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-end;
align-items: center;
padding-right: 20rpx;
.left-label-tag{
border: 2rpx solid var(--left-label-tag-border-color-);
padding: 0 10rpx 0 20rpx;
height: 44rpx;
line-height: 44rpx;
font-size: 24rpx;
color: #e75a29;
position: relative;
}
.left-label-tag:after, .left-label-tag:before {
border: solid transparent;
content: ' ';
height: 0;
left: 100%;
position: absolute;
top: -4rpx;
width: 0;
}
.left-label-tag:after {
border-width: 20rpx;
border-left-color: var(--shop-block-background-);
top: 0;
}
.left-label-tag:before {
border-width: 24rpx;
border-left-color: var(--left-label-tag-border-color-);
}
}
.right-desc{
width: calc((100% - var(--store-avatar-size-)));
height: 100%;
padding-left: 20rpx;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
//.goods-info-left{
// width: calc((100% - var(--store-avatar-size-)) * 0.4);
// height: 100%;
// display: inline-flex;
// flex-direction: row;
// flex-wrap: nowrap;
// justify-content: flex-start;
// align-items: center;
.goods-info-left-icon{
height: 36rpx;
width: 36rpx;
background: linear-gradient(180deg, #fd931e, #ec6b00);
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
margin-right: 10rpx;
color: #FFFFFF;
}
.price{
color: #e33a25;
font-size: 24rpx;
margin-right: 10rpx;
}
.line-price{
color: #767676;
font-size: 24rpx;
text-decoration: line-through;
}
//}
//.goods-info-right{
// width: calc((100% - var(--store-avatar-size-)) * 0.6);
// height: 100%;
// display: inline-flex;
// flex-direction: row;
// flex-wrap: nowrap;
// justify-content: flex-start;
// align-items: center;
.goods-name{
width: calc(100% - 30rpx);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding-left: 20rpx;
font-size: 24rpx;
}
.goods-info-right-icon{
height: 60rpx;
line-height: 60rpx;
width: 30rpx;
text-align: center;
font-size: 30rpx;
}
//}
}
}
}
}
}
</style>