|
|
|
<template>
|
|
|
|
<div class="home-pick flex flex-between">
|
|
|
|
<!-- 甄选推荐 -->
|
|
|
|
<div v-if="showRecommend" class="home-pick-recommend">
|
|
|
|
<div
|
|
|
|
@click="onJumpGoodsList('recommend')"
|
|
|
|
class="home-pick--label flex flex-middle"
|
|
|
|
>
|
|
|
|
<strong>甄选推荐</strong>
|
|
|
|
<img src="~/assets/img/common/icon-jump.png" />
|
|
|
|
</div>
|
|
|
|
<div class="home-pick-recommend__products flex flex-middle flex-between">
|
|
|
|
<!-- 左侧商品一 -->
|
|
|
|
<div
|
|
|
|
@click="onJumpGoodsDetal(recommendGoodsOne.id)"
|
|
|
|
class="pick-recommend-products__left"
|
|
|
|
>
|
|
|
|
<strong class="home-pick-recommend--title">{{
|
|
|
|
recommendGoodsOne.title
|
|
|
|
}}</strong>
|
|
|
|
<p class="home-pick-recommend--subtitle">
|
|
|
|
{{ recommendGoodsOne.subtitle }}
|
|
|
|
</p>
|
|
|
|
<!-- 商品标签 -->
|
|
|
|
<div
|
|
|
|
v-for="item in recommendGoodsOne.labelList"
|
|
|
|
:key="item.code"
|
|
|
|
class="home-pick-recommend--tag-wrap flex"
|
|
|
|
>
|
|
|
|
<div :class="`tag-wrap__item tag-wrap__item--${item.code}`">
|
|
|
|
{{ item.text }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<strong class="home-pick--price__18">{{
|
|
|
|
recommendGoodsOne.startingPrice
|
|
|
|
}}</strong>
|
|
|
|
<div class="recommend-products-left__cover">
|
|
|
|
<img :src="recommendGoodsOne.recommendPicture" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- 右侧商品 -->
|
|
|
|
<div
|
|
|
|
class="pick-recommend-products__right flex flex-column flex-between"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-for="(item, index) in recommendArray"
|
|
|
|
:key="index"
|
|
|
|
@click="onJumpGoodsDetal(item.id)"
|
|
|
|
class="recommend-products-right__item"
|
|
|
|
>
|
|
|
|
<strong class="home-pick-recommend--title">{{ item.title }}</strong>
|
|
|
|
<p class="home-pick-recommend--subtitle">
|
|
|
|
{{ recommendGoodsOne.subtitle }}
|
|
|
|
</p>
|
|
|
|
<!-- 商品标签 -->
|
|
|
|
<div
|
|
|
|
v-for="itemLabel in recommendGoodsOne.labelList"
|
|
|
|
:key="itemLabel.code"
|
|
|
|
class="home-pick-recommend--tag-wrap flex"
|
|
|
|
>
|
|
|
|
<div :class="`tag-wrap__item tag-wrap__item--${itemLabel.code}`">
|
|
|
|
{{ itemLabel.text }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<strong class="home-pick--price__18">{{
|
|
|
|
item.startingPrice
|
|
|
|
}}</strong>
|
|
|
|
<div class="recommend-products-right__cover flex-1">
|
|
|
|
<img :src="item.recommendPicture" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- 新品上架 -->
|
|
|
|
<div v-if="showNew" class="home-pick-new">
|
|
|
|
<div
|
|
|
|
@click="onJumpGoodsList('new')"
|
|
|
|
class="home-pick--label flex flex-middle"
|
|
|
|
>
|
|
|
|
<strong>新品上架</strong>
|
|
|
|
<img src="~/assets/img/common/icon-jump.png" />
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
@click="onJumpGoodsDetal(newGoodsOne.id)"
|
|
|
|
class="home-pick-new__products flex"
|
|
|
|
>
|
|
|
|
<!-- 左侧商品 -->
|
|
|
|
<div class="pick-new-products__left">
|
|
|
|
<img
|
|
|
|
:src="newGoodsOne.mainPicture"
|
|
|
|
class="new-products-left__cover"
|
|
|
|
/>
|
|
|
|
<div class="new-products-left__wrap">
|
|
|
|
<p>{{ newGoodsOne.name }}</p>
|
|
|
|
<strong class="home-pick--price__16">{{
|
|
|
|
newGoodsOne.startingPrice
|
|
|
|
}}</strong>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="pick-new-products__right flex flex-wrap flex-between">
|
|
|
|
<div
|
|
|
|
v-for="(item, index) in newArray"
|
|
|
|
:key="index"
|
|
|
|
@click="onJumpGoodsDetal(item.id)"
|
|
|
|
class="new-products-right__wrap flex flex-middle"
|
|
|
|
>
|
|
|
|
<div class="products-right-wrap__cover">
|
|
|
|
<img :src="item.mainPicture" />
|
|
|
|
</div>
|
|
|
|
<div class="products-right-wrap__info">
|
|
|
|
<p>{{ item.name }}</p>
|
|
|
|
<strong class="home-pick--price__14">{{
|
|
|
|
item.startingPrice
|
|
|
|
}}</strong>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
const RECOMMEND_MIN_COUNT = 3; // 甄选推荐商品数
|
|
|
|
const NEW_MIN_COUNT = 5; // 新品上架商品数
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "HomePick",
|
|
|
|
props: {
|
|
|
|
recommendData: {
|
|
|
|
type: Array,
|
|
|
|
default: () => [],
|
|
|
|
},
|
|
|
|
newData: {
|
|
|
|
type: Array,
|
|
|
|
default: () => [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
recommendGoodsOne: null,
|
|
|
|
recommendArray: [],
|
|
|
|
showRecommend: false,
|
|
|
|
newGoodsOne: null,
|
|
|
|
newArray: [],
|
|
|
|
showNew: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
recommendData: {
|
|
|
|
immediate: true,
|
|
|
|
deep: true,
|
|
|
|
handler(val) {
|
|
|
|
if (val && val.length >= RECOMMEND_MIN_COUNT) {
|
|
|
|
this.showRecommend = true;
|
|
|
|
const [one, two, three] = val;
|
|
|
|
this.recommendGoodsOne = one;
|
|
|
|
this.recommendArray = [two, three];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
newData: {
|
|
|
|
immediate: true,
|
|
|
|
deep: true,
|
|
|
|
handler(val) {
|
|
|
|
if (val && val.length >= NEW_MIN_COUNT) {
|
|
|
|
this.showNew = true;
|
|
|
|
this.newGoodsOne = val[0];
|
|
|
|
this.newArray = val.slice(1, NEW_MIN_COUNT);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onJumpGoodsDetal(id) {
|
|
|
|
this.$router.push(`/goods/detail/${id}`);
|
|
|
|
},
|
|
|
|
onJumpGoodsList(type) {
|
|
|
|
this.$router.push(`/goods/list?id=${type}`);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.home-pick {
|
|
|
|
color: #333333;
|
|
|
|
margin-top: 30px;
|
|
|
|
&--label {
|
|
|
|
font-size: 24px;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
width: 150px;
|
|
|
|
cursor: pointer;
|
|
|
|
img {
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
margin-left: 10px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&--price {
|
|
|
|
&__18 {
|
|
|
|
font-size: 18px;
|
|
|
|
color: #ff512b;
|
|
|
|
&::before {
|
|
|
|
content: "¥";
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&__16 {
|
|
|
|
font-size: 16px;
|
|
|
|
color: #ff512b;
|
|
|
|
&::before {
|
|
|
|
content: "¥";
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&__14 {
|
|
|
|
font-size: 14px;
|
|
|
|
color: #ff512b;
|
|
|
|
&::before {
|
|
|
|
content: "¥";
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.home-pick-recommend {
|
|
|
|
width: 590px;
|
|
|
|
height: 340px;
|
|
|
|
padding: 16px 20px;
|
|
|
|
background: #ffffff;
|
|
|
|
border-radius: 2px;
|
|
|
|
&--tag-wrap {
|
|
|
|
margin-bottom: 16px;
|
|
|
|
.tag-wrap__item {
|
|
|
|
width: 40px;
|
|
|
|
height: 20px;
|
|
|
|
font-size: 12px;
|
|
|
|
line-height: 20px;
|
|
|
|
text-align: center;
|
|
|
|
margin-right: 4px;
|
|
|
|
&:last-child {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
&--second_kill {
|
|
|
|
color: #3083ff;
|
|
|
|
background: #3083ff;
|
|
|
|
}
|
|
|
|
&--recommended {
|
|
|
|
color: #ff875b;
|
|
|
|
background: #ff875b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&--title {
|
|
|
|
display: block;
|
|
|
|
font-size: 18px;
|
|
|
|
margin-bottom: 8px;
|
|
|
|
@include ellipsis;
|
|
|
|
}
|
|
|
|
&--subtitle {
|
|
|
|
font-size: 12px;
|
|
|
|
color: #999999;
|
|
|
|
margin-bottom: 8px;
|
|
|
|
}
|
|
|
|
&__products {
|
|
|
|
height: 264px;
|
|
|
|
cursor: pointer;
|
|
|
|
.pick-recommend-products__left {
|
|
|
|
position: relative;
|
|
|
|
width: 264px;
|
|
|
|
height: 100%;
|
|
|
|
background: #f8f8f9;
|
|
|
|
padding: 12px 0 0 20px;
|
|
|
|
.recommend-products-left__cover {
|
|
|
|
position: absolute;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
width: 158px;
|
|
|
|
height: 158px;
|
|
|
|
img {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.pick-recommend-products__right {
|
|
|
|
width: 266px;
|
|
|
|
height: 100%;
|
|
|
|
.recommend-products-right__item {
|
|
|
|
width: 100%;
|
|
|
|
height: 122px;
|
|
|
|
position: relative;
|
|
|
|
background: #f8f7f8;
|
|
|
|
padding: 14px 0 14px 20px;
|
|
|
|
}
|
|
|
|
.recommend-products-right__cover {
|
|
|
|
position: absolute;
|
|
|
|
right: 0;
|
|
|
|
top: 50%;
|
|
|
|
transform: translate(0, -50%);
|
|
|
|
width: 110px;
|
|
|
|
height: 110px;
|
|
|
|
img {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.home-pick-new {
|
|
|
|
width: 590px;
|
|
|
|
height: 340px;
|
|
|
|
padding: 14px 20px 16px 20px;
|
|
|
|
background: #ffffff;
|
|
|
|
&__products {
|
|
|
|
cursor: pointer;
|
|
|
|
.pick-new-products__left {
|
|
|
|
width: 170px;
|
|
|
|
height: 264px;
|
|
|
|
background: #f8f8f9;
|
|
|
|
margin-right: 20px;
|
|
|
|
.new-products-left__cover {
|
|
|
|
width: 170px;
|
|
|
|
height: 170px;
|
|
|
|
}
|
|
|
|
.new-products-left__wrap {
|
|
|
|
padding: 10px 0;
|
|
|
|
text-align: center;
|
|
|
|
font-size: 14px;
|
|
|
|
p {
|
|
|
|
width: 140px;
|
|
|
|
margin: 0 auto 12px auto;
|
|
|
|
@include ellipsis;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.pick-new-products__right {
|
|
|
|
.new-products-right__wrap {
|
|
|
|
width: 170px;
|
|
|
|
height: 100px;
|
|
|
|
background: #ffffff;
|
|
|
|
padding: 16px 8px 16px 0;
|
|
|
|
&:nth-child(-n + 2) {
|
|
|
|
margin-bottom: 40px;
|
|
|
|
}
|
|
|
|
.products-right-wrap__cover {
|
|
|
|
width: 68px;
|
|
|
|
height: 68px;
|
|
|
|
margin-right: 16px;
|
|
|
|
img {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.products-right-wrap__info {
|
|
|
|
font-size: 14px;
|
|
|
|
p {
|
|
|
|
width: 78px;
|
|
|
|
margin-bottom: 8px;
|
|
|
|
@include ellipses(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|