Authored by 李靖

开发完成

... ... @@ -175,7 +175,8 @@ exports.resourcesGoodsList = (req, res, next) => {
};
plusstarModel.getProductBatch(param, {
isApp: isApp
isApp: isApp,
showSimilar: true
}).then(result => {
res.render('plusstar/resources-goodsList', {
layout: false,
... ...
... ... @@ -207,6 +207,10 @@ const getNewProduct = (brandId, gender, url, isApp) => {
});
}
obj = _.assign(obj, {
similar: true
});
newArrival.naList.push(obj);
}
... ...
... ... @@ -34,6 +34,12 @@
{{# is_solded}}
<p class="out-tag">已售罄</p>
{{/ is_solded}}
{{#if similar}}
<div class="similar-c">
<div class="bg"></div>
<a href="//m.yohobuy.com/product/similar?skn={{id}}">找相似</a>
</div>
{{/if}}
</div>
<div class="good-detail-text">
<div class="name">
... ... @@ -53,6 +59,9 @@
{{/price}}
{{/if}}
</div>
{{#if similar}}
<a class="similar-btn iconfont">&#xe606;</a>
{{/if}}
</div>
</div>
{{/if}}
... ...
'use strict';
const headerModel = require('../../../doraemon/models/header'); // 头部model
const similarModel = require('../models/similar');
exports.index = (req, res, next) => {
let responseData = {
pageHeader: headerModel.setNav({
navTitle: '找相似',
}),
module: 'product',
page: 'similar',
title: '找相似',
width750: true,
pageFooter: true,
localCss: true
};
req.ctx(similarModel).list({skn: req.query.skn}).then(result => {
res.render('similar/index', Object.assign(responseData, result));
}).catch(next);
};
\ No newline at end of file
... ...
... ... @@ -75,7 +75,10 @@ const getSearchData = (params) => {
if (result && result.code === 200) {
let newList = {};
newList.list = productProcess.processProductList(result.data.product_list || [], {showTags: true});
newList.list = productProcess.processProductList(result.data.product_list || [], {
showTags: true,
showSimilar: true
});
if (parseInt(params.page, 10) === 1) {
newList.total = result.data.total;
... ...
... ... @@ -23,7 +23,9 @@ const mayLike = (uid, page, limit, gender, udid, recPos, channel, clientId) => {
if (result.data.page_total && page <= result.data.page_total) {
if (result.data.product_list) {
return productProcess.processProductList(result.data.product_list);
return productProcess.processProductList(result.data.product_list, {
showSimilar: true
});
} else {
return false;
... ... @@ -51,7 +53,9 @@ const mayLikeKids = (page, limit, channel) => {
if (result.data.product_list) {
return productProcess.processProductList(result.data.product_list);
return productProcess.processProductList(result.data.product_list, {
showSimilar: true
});
}
} else {
... ... @@ -77,7 +81,10 @@ const mayLikelife = (page, limit) => {
build.show = true;
build.goods = productProcess.processProductList(result.data.product_list.top, {showTags: false});
build.goods = productProcess.processProductList(result.data.product_list.top, {
showTags: false,
showSimilar: true
});
formData.goodsContainer.push(build);
}
... ... @@ -87,7 +94,10 @@ const mayLikelife = (page, limit) => {
build.show = true;
build.goods = productProcess.processProductList(result.data.product_list.new, {showTags: false});
build.goods = productProcess.processProductList(result.data.product_list.new, {
showTags: false,
showSimilar: true
});
formData.goodsContainer.push(build);
}
... ...
... ... @@ -63,6 +63,7 @@ const getPreferenceData = (data) => {
// tags.is_solded = true;
goods.tags = tags;
goods.similar = true;
if (tags.is_solded === true) {
goods.is_solded = true;
... ...
... ... @@ -247,7 +247,8 @@ const getSearchData = (params) => {
newList.list = productProcess.processProductList(result.data.product_list || [], {
isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'),
gender: _coverChannel[params.coverChannel]
gender: _coverChannel[params.coverChannel],
showSimilar: params.shop_id ? false : true
});
if (result.data.rec_shop_list && result.data.rec_shop_list.length > 0 &&
... ... @@ -278,7 +279,8 @@ const getSearchData = (params) => {
termsSuggestion: productProcess.termsSuggestion(
result.data.suggestion && result.data.suggestion.terms_suggestion || [], params
),
isMaybeLike: result.data.total < 20 // 搜索过来的 小于 20条 猜你喜欢显示不显示判断
isMaybeLike: result.data.total < 20, // 搜索过来的 小于 20条 猜你喜欢显示不显示判断
showSimilar: true
};
suggestion.isNeedSuggestionOne = suggestion.termsSuggestion.length > 1;// 如果只有一个<或者试试不显示>
}
... ... @@ -300,7 +302,9 @@ const getSearchData = (params) => {
const getFilterData = (params) => {
return _searchGoods(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processFilter(result.data.filter || []);
return productProcess.processFilter(result.data.filter || [], {
showSimilar: true
});
} else {
logger.error('get filter data api return code is not 200');
return [];
... ...
'use strict';
const utils = '../../../utils';
const _ = require('lodash');
const productProcess = require(`${utils}/product-process`);
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
list(params) {
let options = {
data: {
method: 'app.search.findLike',
product_skn: params.skn
},
param: {
code: 200
}
};
return this.get(options).then(result => {
let resu = {
goodInfo: [],
list: []
};
if (_.get(result, 'data', false)) {
resu.goodInfo = productProcess.processProductList(result.data);
}
if (_.get(result, 'data.product_list', false)) {
resu.list = productProcess.processProductList(result.data.product_list);
}
return resu;
});
}
};
... ...
... ... @@ -56,6 +56,9 @@ const bundle = require(`${cRoot}/bundle`);
// 全球购
const globalPro = require(`${cRoot}/global`);
// 找相似
const similar = require(`${cRoot}/similar`);
// routers
// /pro_136349_455445/HEARTSOFARMianMaShuJiaoXiuXianKuPS1684.html
... ... @@ -209,4 +212,6 @@ router.get('/global/search', globalPro.search); // 全球购列表页搜索数
router.get(/^\/global\/(\d+)\.html/, globalPro.detail); // 全球购店铺详情页
router.get('/global/gethtml', globalPro.gethtml); // 全球购商品信息
router.get('/similar', similar.index); // 找相似
module.exports = router;
... ...
<div class="similar-c">
<div class="good-c">
{{# goodInfo}}
<div class="good-item clearfix" href="#">
<div class="pic">
<a href="{{url}}">
<img src="{{image2 default_images w=152 h=203 q=60}}"/>
</a>
</div>
<div class="info">
<a href="{{url}}">
<p class="name">{{product_name}}</p>
</a>
<div class="price">
{{#if @root.saleViplogin}}
<span class="now">¥
{{#if @root.vipPrice1}}{{round vip1_price}}{{/if}}
{{#if @root.vipPrice2}}{{round vip2_price}}{{/if}}
{{#if @root.vipPrice3}}{{round vip3_price}}{{/if}}
</span>
{{else}}
<span class="now">¥{{round sales_price}}</span>
{{/if}}
{{#market_price}}
<span class="old">¥{{round .}}</span>
{{/market_price}}
</div>
</div>
</div>
{{/goodInfo}}
</div>
{{#if list}}
<p class="big-title">相似商品</p>
{{/if}}
<div class="good-c">
{{#list}}
<div class="good-item clearfix" href="#">
<div class="pic">
<a href="{{url}}">
<img class="lazy" data-original="{{image2 default_images w=152 h=203 q=60}}"/>
</a>
</div>
<div class="info">
<a href="{{url}}">
<p class="name">{{product_name}}</p>
</a>
<div class="price">
{{#if @root.saleViplogin}}
<span class="now">¥
{{#if @root.vipPrice1}}{{round vip1_price}}{{/if}}
{{#if @root.vipPrice2}}{{round vip2_price}}{{/if}}
{{#if @root.vipPrice3}}{{round vip3_price}}{{/if}}
</span>
{{else}}
<span class="now">¥{{round sales_price}}</span>
{{/if}}
{{#market_price}}
<span class="old">¥{{round .}}</span>
{{/market_price}}
</div>
<a class="btn" href="//m.yohobuy.com/product/similar?skn={{product_skn}}">找相似</a>
</div>
</div>
{{/list}}
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -52,6 +52,12 @@
<div class="no-storage-img"></div>
</div>
{{/ noStorage}} --}}
{{#if similar}}
<div class="similar-c">
<div class="bg"></div>
<a href="//m.yohobuy.com/product/similar?skn={{product_skn}}">找相似</a>
</div>
{{/if}}
</div>
<div class="good-detail-text">
<div class="name">
... ... @@ -77,6 +83,9 @@
<i class="vip-icon"></i>更优惠
</div>
{{/if}}
{{#if similar}}
<a class="similar-btn iconfont">&#xe606;</a>
{{/if}}
</div>
</div>
{{/if}}
... ...
... ... @@ -71,6 +71,12 @@
<div class="no-storage-img"></div>
</div>
{{/ noStorage}} --}}
{{#if similar}}
<div class="similar-c">
<div class="bg"></div>
<a href="//m.yohobuy.com/product/similar?skn={{product_skn}}">找相似</a>
</div>
{{/if}}
</div>
<div class="good-detail-text">
<div class="name">
... ... @@ -96,6 +102,9 @@
<i class="vip-icon"></i>更优惠
</div>
{{/if}}
{{#if similar}}
<a class="similar-btn iconfont">&#xe606;</a>
{{/if}}
</div>
</div>
{{/if}}
... ...
... ... @@ -302,6 +302,15 @@ $('.nav-home').on('touchstart', function() {
$('.homebuttom').toggleClass('hide');
});
// 商品列表找相似按钮
$('*').on('touchstart', '.similar-btn', function() {
let $thisP = $(this).parents('.good-info');
$thisP.find('.similar-c').toggle();
$thisP.siblings('.good-info').find('.similar-c').hide();
return false;
});
(function() {
let lastTime = 0,
prefixes = 'webkit moz ms o'.split(' '),
... ...
'use strict';
import {
Controller
} from 'yoho-mvc';
require('yoho-jquery');
const lazyLoad = require('yoho-jquery-lazyload');
class SimilarController extends Controller {
constructor() {
super();
lazyLoad($('img.lazy'));
}
}
module.exports = SimilarController;
... ...
require('product/similar/similar.page.css');
const SimilarController = require('./controller');
new SimilarController();
... ...
... ... @@ -156,9 +156,46 @@
background-size: contain;
}
}
.similar-c {
display: none;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
.bg {
width: 100%;
height: 100%;
background-color: #000;
opacity: 0.6;
}
a {
display: block;
width: 120px;
height: 120px;
position: absolute;
top: 50%;
left: 50%;
margin-left: -60px;
margin-top: -60px;
color: #fff;
background-color: #d0021b;
font-size: 28px;
line-height: 120px;
text-align: center;
border-radius: 50%;
}
}
}
.good-detail-text {
position: relative;
.name a {
transform: scale(0.9);
margin: 15px 0 10px;
... ... @@ -235,6 +272,18 @@
vertical-align: bottom;
}
}
.similar-btn {
color: #b0b0b0;
width: 40px;
height: 40px;
line-height: 40px;
text-align: center;
position: absolute;
bottom: -10px;
right: 0;
font-weight: bold;
}
}
.width750 {
... ...
.similar-c {
background-color: #f0f0f0;
padding-bottom: 30px;
.good-c {
border-top: solid 1px #e0e0e0;
.good-item {
display: block;
padding: 20px 30px;
border-bottom: solid 1px #e0e0e0;
position: relative;
background-color: #fff;
.pic {
width: 152px;
height: 203px;
float: left;
}
img {
width: 100%;
height: 100%;
}
.info {
width: 508px;
float: left;
margin-left: 30px;
}
.name {
padding: 5px 0;
font-size: 28px;
color: #444;
line-height: 40px;
height: 170px;
overflow: hidden;
}
.price {
line-height: 33px;
}
.now {
font-size: 34px;
color: #d0021b;
margin-right: 10px;
}
.old {
font-size: 20px;
color: #444;
text-decoration: line-through;
}
.btn {
width: 86px;
height: 36px;
line-height: 36px;
color: #d0021b;
font-size: 20px;
border: solid 2px #d0021b;
border-radius: 3px;
position: absolute;
bottom: 20px;
right: 30px;
text-align: center;
}
}
}
.big-title {
font-size: 28px;
color: #b0b0b0;
line-height: 88px;
text-align: center;
}
}
... ...
... ... @@ -199,6 +199,11 @@ exports.processProductList = (list, options) => {
}
// 显示相似商品按钮
if (options.showSimilar) {
product.similar = true;
}
pruductList.push(product);
});
... ...