Authored by 陈峰

Merge branch 'master' of http://git.yoho.cn/fe/yoho-community-web

import ProductGroup from './product-group';
import ProductList from './product-list';
import ProductItem from './product-item';
export default [
ProductGroup,
ProductList,
ProductItem
ProductList
];
... ...
<template>
<div
class="product-item"
:class="{single}">
:class="{single}"
@click="onClick"
>
<div class="product-content">
<ImageFormat :lazy="lazy" class="product-image" :src="product.productImage" :width="136" :height="180"></ImageFormat>
<div class="product-info">
... ... @@ -72,6 +74,9 @@ export default {
time: 1000
}).show();
}
},
onClick() {
console.log('click');
}
}
};
... ...
<template>
<div class="product-item">
<div class="product-content">
<ImageFormat class="product-image" :src="src" width="136" height="180"></ImageFormat>
<div class="product-info">
<p class="product-name">{{name}}</p>
<p class="price">¥{{price}}</p>
</div>
</div>
<div class="btn-fav hover-opacity" v-if="!isFav">收藏</div>
<div class="btn-fav btn-is-fav hover-opacity" v-else>已收藏</div>
</div>
</template>
<script>
import {Button} from 'cube-ui';
export default {
name: 'ProductItem',
props: ['name', 'src', 'price', 'isFav'],
components: {Button}
};
</script>
<style lang="scss" scoped>
.product-item {
position: relative;
margin-top: 20px;
padding: 10px 20px;
height: 180px;
width: 670px;
background-color: #fff;
box-shadow: 0 5px 10px 0 rgba(107, 95, 95, 0.2);
display: inline-block;
white-space: initial;
}
.product-content {
display: flex;
width: 100%;
height: 100%;
}
.product-image {
width: 136px;
height: 180px;
margin-top: -30px;
}
.product-info {
padding-left: 20px;
flex: 1;
.product-name {
font-size: 24px;
color: #9b9b9b;
letter-spacing: -0.25PX;
height: 104px;
}
.price {
font-size: 32px;
color: #d0021b;
letter-spacing: -0.34PX;
}
}
.btn-fav {
position: absolute;
bottom: 20px;
right: -20px;
width: 120px;
height: 50px;
padding: 0;
font-size: 24px;
background-color: #444;
background-size: contain;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
&.btn-is-fav {
background-color: #b0b0b0;
}
& /deep/ .iconfont {
margin: 0;
}
}
</style>
... ... @@ -9,7 +9,7 @@ const {mapActions} = createNamespacedHelpers('user');
export default {
name: 'WidgetFollow',
props: {
authorUid: Number,
authorUid: [Number, String],
follow: Boolean
},
data() {
... ...
... ... @@ -16,7 +16,7 @@
<template v-if="item.smallImage">
<div class="small-img-block clearfix">
<ImageFormat :lazy="false" :src="i.src" width="315" height="420" v-for="i in item.smallImage" ></ImageFormat>
<ImageFormat :lazy="false" :src="i.src" width="315" height="420" v-for="(i,index) in item.smallImage" :key="index"></ImageFormat>
</div>
</template>
... ... @@ -28,9 +28,7 @@
<template v-if="item.relatedReco">
<div class="products">
<ProductItem class="product-item" v-for="p in item.relatedReco.goods" :src="p.default_images" :price="p.sales_price" :name="p.product_name"></ProductItem>
<!--<ProductGroup v-for="p in item.relatedReco.goods" :data="[p]"></ProductGroup>-->
<ProductGroup v-for="(p,index) in item.relatedReco.goods" :data="[p]" :key="index"></ProductGroup>
</div>
</template>
</template>
... ... @@ -141,12 +139,20 @@ export default {
}
.products {
margin-top: 40px;
margin-bottom: 40px;
}
/deep/ .product-group {
height: 220px;
padding-top: 0;
padding-bottom: 0;
margin: 40px 0;
}
.product-item + .product-item {
margin-top: 64px;
/deep/ .product-item {
margin-left: 0;
}
/deep/ .single {
width: 670px;
}
}
.big-img-block {
... ...
... ... @@ -5,8 +5,7 @@
<span class="name">{{data.name}}</span>
</div>
<div class="opts">
<button class="btn-follow hover-opacity" v-if="true">关注</button>
<button class="btn-follow followed hover-opacity" v-else>已关注</button>
<WidgetFollow v-bind="data"></WidgetFollow>
</div>
</div>
</template>
... ... @@ -60,24 +59,5 @@ export default {
display: flex;
align-items: center;
justify-content: flex-end;
.btn-follow {
width: 120px;
height: 50px;
padding: 0;
font-size: 26px;
border-radius: 3PX;
background-color: #222;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
&.followed {
border: solid 1px #4a4a4a;
background-color: #fff;
color: #000;
}
}
}
</style>
... ...
... ... @@ -33,7 +33,7 @@ export default {
};
</script>
<style>
<style lang="scss" scoped>
.content {
width: 100%;
height: 100vh;
... ...
<template>
<div class="product-list">
<RecommendProductItem class="item" v-for="i in list" v-bind="i"></RecommendProductItem>
<RecommendProductItem class="item" v-for="(i, index) in list" v-bind="i" :key="index"></RecommendProductItem>
</div>
</template>
... ...
<template>
<div>
<WidgetTopic v-for="i in list" :topic="i.name"></WidgetTopic>
<WidgetTopic v-for="(i, index) in list" :topic="i.name" :key="index"></WidgetTopic>
</div>
</template>
... ...
... ... @@ -7,12 +7,24 @@
</template>
<script>
import dayjs from 'dayjs';
export default {
name: 'ZanBar',
props: ['praiseHeadIco', 'praiseCount', 'publish_time'],
filters: {
formatTime(str) {
return '1天前';
const now = dayjs();
const pubTime = dayjs(str * 1000);
if (now.year() === pubTime.year() && now.month() === pubTime.month() && now.day() === pubTime.day()) {
return pubTime.format('HH:mm');
} else if (now.year() === pubTime.year()) {
return pubTime.format('MM-DD');
} else {
return pubTime.format('YYYY-MM-DD');
}
}
}
};
... ...
... ... @@ -114,6 +114,8 @@ export default {
if (author && author.code === 200 && author.data) {
result.getAuthor = author.data;
result.getAuthor.authorUid = result.getAuthor.author_id;
result.getAuthor.fellow = get(zan, 'data.hasAttention', false);
}
if (content && content.code === 200 && content.data) {
... ... @@ -127,15 +129,18 @@ export default {
const processContents = guangProcess.processArticleDetail(content.data);
// 插入商品
const goodsList = await this.$api.get('/api/guang/article/queryGoods', {
const [goodsList, favsList] = await Promise.all([this.$api.get('/api/guang/article/queryGoods', {
query: processContents.allgoods.join(','),
order: 's_t_desc',
limit: processContents.allgoods.length || 1
}).then(res => {
return get(res, 'data.product_list', []);
}), this.$api.get('/api/favorite/batchCheckIsFavorite', {
favIds: processContents.allgoods.join(','),
type: 'product'
})]).then(([res1, res2]) => {
return [get(res1, 'data.product_list', []), get(res2, 'data', [])];
});
result.getArticleContent = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList);
result.getArticleContent = guangProcess.pushGoodsInfo(processContents.finalDetail, goodsList, favsList);
}
if (zan && zan.code === 200 && zan.data) {
... ...
... ... @@ -198,7 +198,7 @@ export function processArticleDetail(articleContent) {
/**
* 商品搜索商品数据处理
*/
function processProductList(list) {
function processProductList(list, favsList) {
const pruductList = [];
forEach(list, (product) => {
... ... @@ -243,12 +243,24 @@ function processProductList(list) {
product.default_images = getSourceUrl(product.default_images, 'goodsimg');
product.productImage = product.default_images;
product.salesPrice = product.sales_price;
product.productName = product.product_name;
product.is_soon_sold_out = product.is_soon_sold_out === 'Y';
if (product.cn_alphabet) {
product.cn_alphabet = productNameProcess(product.cn_alphabet);
}
// fav
const fav = favsList.find(i => i.id === product.product_id);
product.productId = product.product_id;
product.productType = 1;
product.favorite = fav || false;
product.url = product.is_global === 'Y' ? `/product/global/${product.product_skn}.html` :
`/product/${product.product_skn}.html`; // 商品url改版 // eslint-disable-line
... ... @@ -289,8 +301,8 @@ const _goodsArrayToObj = (goodsArray) => {
/**
* 重新获取商品数据
*/
export function pushGoodsInfo(finalDetail, goodsList) {
let goodsObj = _goodsArrayToObj(processProductList(goodsList));
export function pushGoodsInfo(finalDetail, goodsList, favsList) {
let goodsObj = _goodsArrayToObj(processProductList(goodsList, favsList));
forEach(finalDetail, (value, key) => {
if (value.relatedReco) {
... ...
... ... @@ -14,6 +14,7 @@ export default {
productId
};
}
const result = await this.$api.get(postUrl, params);
return result;
... ...
... ... @@ -103,7 +103,7 @@ module.exports = {
enable_offline_queue: false,
retry_strategy(options) {
if (options.error && options.error.code === 'ECONNREFUSED') {
console.log('connect redis server fail');
// console.log('connect redis server fail');
}
if (options.attempt < 10) {
... ... @@ -152,7 +152,7 @@ if (isProduction) {
enable_offline_queue: false,
retry_strategy(options) {
if (options.error && options.error.code === 'ECONNREFUSED') {
console.log('connect redis server fail');
// console.log('connect redis server fail');
}
if (options.attempt < 10) {
... ...