Authored by zhangxiaoru

merge

... ... @@ -29,6 +29,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
return new Promise((resolve) => {
let joinContentFunc = (i, len) => {
if (i < len) {
let build = {};
let art = articleContent[i];
... ... @@ -72,32 +73,35 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
// 通过SKN获取商品信息
productDetailModel.productInfoBySkns(skns).then((product) => {
if (product.data && product.data.product_list) {
let d = [];
if (product && product.data) {
if (product.data.product_list) {
let d = [];
for (let o = 0; o < product.data.product_list.length; o++) {
let goods = product.data.product_list[o];
for (let o = 0; o < product.data.product_list.length; o++) {
let goods = product.data.product_list[o];
// 最多显示4个
if (o > 3) {
break;
// 最多显示4个
if (o > 3) {
break;
}
d.push(guangProcess.formatProduct(goods, false, true, true, 235, 314, isApp, true, gender));
}
d.push(guangProcess.formatProduct(goods, false, true, true, 235, 314, isApp, true, gender));
d.forEach(p => {
if (arr[p.id]) {
p.thumb = helpers.image(arr[p.id], 235, 314);
reco.push(p);
}
});
}
d.forEach(p => {
if (arr[p.id]) {
p.thumb = helpers.image(arr[p.id], 235, 314);
reco.push(p);
}
});
}
// 多个商品
if (product.data.product_list.length > 1) {
build.relatedReco = reco;
} else if (product.data.product_list.length === 1) { // 单个商品
build.relatedReco = reco[0];
// 多个商品
if (product.data.product_list.length && (product.data.product_list.length > 1)) {
build.relatedReco = reco;
} else if (product.data.product_list.length === 1) { // 单个商品
build.relatedReco = reco[0];
}
}
contents.push(build);
joinContentFunc(++i, len);
});
... ... @@ -120,7 +124,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
// 通过SKN获取商品信息
productDetailModel.productInfoBySkns(skns).then((product) => {
if (product.data.product_list) {
if (product && product.data && product.data.product_list) {
let g = [];
product.data.product_list.forEach(_ => {
... ... @@ -157,6 +161,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
resolve(contents);
}
};
joinContentFunc(0, articleContent.length);
});
};
... ... @@ -167,6 +172,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
*/
const _relatedBrand = (getBrand) => {
let relatedBrand = getBrand;
relatedBrand.forEach(brand => {
brand.thumb = brand.thumb.replace('http://', '//');
});
... ... @@ -180,6 +186,7 @@ const _relatedBrand = (getBrand) => {
*/
const _relatedTag = (tags, isApp) => {
let relatedTag = [];
tags.forEach(value => {
if (!isApp) {
value.url = helpers.urlFormat('/tags/index', {
... ... @@ -198,6 +205,7 @@ const _relatedTag = (tags, isApp) => {
*/
const _relatedInfo = (getOtherArticle, isApp) => {
let relatedInfo = [];
getOtherArticle.forEach(value => {
if (!isApp) {
value.url = helpers.urlFormat('/info/index', {
... ... @@ -217,6 +225,7 @@ const _relatedInfo = (getOtherArticle, isApp) => {
*/
const _shareInfo = (id, getArticle) => {
let shareInfo = {};
shareInfo.shareLink = helpers.urlFormat('/info/index', {
id: id
}, 'guang');
... ... @@ -234,7 +243,7 @@ const _shareInfo = (id, getArticle) => {
* [逛资讯详情页]
*/
const index = (req, res, next) => {
let id = req.query.id,
let id = req.query.id || req.params.id,
gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1,
isApp = req.query.app_version || req.query.appVersion || false, // 标识是不是APP访问的
parameter = {},
... ... @@ -314,6 +323,7 @@ const index = (req, res, next) => {
// 分享参数
if (detail.getArticle.cover_image) {
let shareInfo = _shareInfo(id, detail.getArticle);
Object.assign(guang, shareInfo);
data.title = detail.getArticle.article_title + ' | Yoho!Buy有货 | 潮流购物逛不停';
data.title_more = true;
... ... @@ -388,6 +398,7 @@ const mini = (req, res, next) => {
// 分享参数
if (detail.getArticle.cover_image) {
let shareInfo = _shareInfo(id, detail.getArticle);
Object.assign(guang, shareInfo);
}
... ... @@ -443,9 +454,11 @@ const foryoho = (req, res, next) => {
let relatedRecoIndex = data.content.findIndex((cont) => {
return typeof cont.relatedReco !== 'undefined';
});
let collocationIndex = data.content.findIndex((cont) => {
return typeof cont.collocation !== 'undefined';
});
if (relatedRecoIndex > 0) {
data.goods = data.content[relatedRecoIndex].relatedReco;
data.content.splice(relatedRecoIndex, 1);
... ...
... ... @@ -43,6 +43,7 @@ router.post('/opt/praiseArticle', opt.praiseArticle); // 资讯文章点赞 (H5
router.post('/opt/favoriteBrand', opt.favoriteBrand); // 品牌收藏
router.get('/info/index', info.index); // 逛详情页
router.get('/:id.html', info.index); // 逛详情页(兼容 PC 跳转过来的链接)
router.get('/info/mini', info.mini); // 逛mini内容页
router.get('/info/foryoho', info.foryoho); // 逛foryoho内容页
... ...
... ... @@ -308,12 +308,20 @@ const postAccount = (req, res) => {
};
const startingService = (req, res) => {
const banks = ['农业银行', '中国银行', '工商银行', '建设银行', '光大银行', '兴业银行', '邮储银行', '民生银行', '中信银行', '广发银行'];
if (new Date() >= new Date('2016-10-18 00:00:00')) {
// 2016年10月12日至17日 平安银行业务暂停(平安银行期间不支持服务)
banks.push('平安银行');
}
res.render('installment/starting-service', {
module: 'home',
page: 'installment.starting-service',
title: '开通有货分期',
navTitle: '开通有货分期',
navBtn: false
navBtn: false,
banks: banks.join('、')
});
};
... ...
... ... @@ -78,9 +78,7 @@
<div class="notice-area">
<div class="notice-cont">
<h2>支持银行</h2>
<p>农业银行、中国银行、工商银行、建设银行、</p>
<p>光大银行、兴业银行、邮储银行、民生银行、</p>
<p>平安银行、中信银行、广发银行</p>
<p>{{banks}}</p>
</div>
<div class="think-ok">我知道了</div>
</div>
... ...
... ... @@ -63,8 +63,14 @@ const _baseShop = (req, res, shopInfo, shopId) => {
* 基础模板收藏
*/
const baseShopFav = (req, res) => {
let allowOrigin = _.get(req, 'headers.origin', null) ?
req.headers.origin : req.protocol + '://' + req.headers.host;
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
let isApp = req.query.app_version || req.query.appVersion || false;
let uid = isApp ? req.query.uid : req.user.uid;
let uid = req.user.uid || req.query.uid || req.cookies.appUid || _getUidFromUserAgent(req);
let shopId = req.query.shopId;
listModel.getShopData(req, shopId, uid, isApp).then(result => {
... ... @@ -116,7 +122,7 @@ const _shop = (req, res, shopId) => {
} else {
listModel.searchProductBySkn(result.hotListproductSkn).then(hotList => {
result = _.assign(result, pageHeader, {
hotList: productProcess.processProductList(hotList)
hotList: productProcess.processProductList(hotList, {isApp: isApp})
});
_.forEach(result.hotList, (value, key) => {
... ... @@ -148,6 +154,12 @@ const _shop = (req, res, shopId) => {
* app设置cookie
*/
const shopAppCookie = (req, res) => {
let allowOrigin = _.get(req, 'headers.origin', null) ?
req.headers.origin : req.protocol + '://' + req.headers.host;
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
let uid = req.query.uid;
req.session.appUid = uid;
... ... @@ -165,8 +177,14 @@ const shopAppCookie = (req, res) => {
* 前端请求判断shop是否收藏
*/
const shopFav = (req, res) => {
let allowOrigin = _.get(req, 'headers.origin', null) ?
req.headers.origin : req.protocol + '://' + req.headers.host;
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
let isApp = req.query.app_version || req.query.appVersion || false;
let uid = isApp ? req.query.uid : req.user.uid;
let uid = req.user.uid || req.query.uid || req.cookies.appUid || _getUidFromUserAgent(req);
let shopId = req.query.shopId;
listModel.getShopFav(req, shopId, uid, isApp).then(result => {
... ... @@ -347,25 +365,7 @@ const favoriteBrand = (req, res, next) => {
let opt = req.query.opt || 'ok';
let type = req.query.type || 'product';
let appVersion = req.query.appVersion || false;
let refer = req.headers.origin;
if (req.headers.referer) {
let refererSplit = _.split(req.headers.referer, '?');
let shopIdSplit = _.split(refererSplit[1], '&');
let shopId = '';
_.forEach(shopIdSplit, value => {
if (_.startsWith(value, 'shop_id')) {
shopId = value;
return;
}
});
if (shopId) {
refer = refererSplit[0] + '?' + shopId;
}
}
let refer = req.get('referer');
let url = helpers.urlFormat('/signin.html') + '?refer=' + refer;
... ... @@ -376,7 +376,8 @@ const favoriteBrand = (req, res, next) => {
uid = _getUidFromUserAgent(req);
}
url = `${refer}&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"${refer}","param":{}},"requesturl":{"param":{},"url":""},"priority":"Y"}}`; // eslint-disable-line
url = `${refer}&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"${refer}","param":{}},"requesturl":{"param":{"method":"app.favorite.add","id":"${id}","fav_id":"${id}","type":"shop"},"url":"${_.get(global, 'yoho.API.ApiUrl', '')}"},"priority":"Y"}}`; // eslint-disable-line
}
if (!id) {
... ... @@ -468,23 +469,7 @@ const userCoupon = (req, res, next) => {
return;
}).catch(next);
} else {
let refer = req.headers.origin;
if (req.headers.referer) {
let refererSplit = _.split(req.headers.referer, '?');
let shopIdSplit = _.split(refererSplit[1], '&');
let shopId = '';
_.forEach(shopIdSplit, value => {
if (_.startsWith(value, 'shop_id')) {
shopId = value;
return;
}
});
refer = refererSplit[0] + '?' + shopId;
}
let refer = req.get('referer');
if (req.yoho.isApp !== 'false') {
let toUrl = refer + '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' +
... ...
... ... @@ -105,6 +105,9 @@ const _getShopDecorator = (shopId) => {
* @return array
*/
const _getShopInfo = (shopId, uid) => {
if (uid === 'undefined') {
uid = 0;
}
return api.get('', {
method: 'app.shops.getIntro',
shop_id: shopId,
... ... @@ -332,9 +335,10 @@ const _formShopData = (data, shopId, isApp) => {
}
};
_.forEach(resData, (cate) => {
_.forEach(resData, cate => {
hotCategory.data.list.push({
url: cate.url,
url: isApp ? _modifyAppUrl(cate, shopId) :
_modifyWapUrl(cate, shopId),
src: helpers.image(cate.src),
name: cate.name
});
... ... @@ -362,6 +366,16 @@ const _formShopData = (data, shopId, isApp) => {
title: '全部商品'
};
let moreUrl = helpers.urlFormat('', {
shop_id: shopId,
order: 's_n_d',
title: '人气单品'
}, 'search'); // 人气单品的链接
if (isApp) {
moreUrl = 'openby:yohobuy={"action":"go.list","params":{"shop_id":"' + shopId + '","title":"人气单品"}}';
}
formatData = _.assign({
shopIntro: _.get(data, 'shopInfo.shop_intro', ''),
logoImg: _.get(data, 'shopInfo.shop_logo', ''),
... ... @@ -372,11 +386,7 @@ const _formShopData = (data, shopId, isApp) => {
url: helpers.urlFormat('', {
shop_id: shopId
}, 'search'), // 搜索链接
more_url: helpers.urlFormat('', {
shop_id: shopId,
order: 's_n_d',
title: '人气单品'
}, 'search') // 人气单品的链接
more_url: moreUrl
}, formatData);
if (single) { // 单品点
... ... @@ -528,7 +538,7 @@ const getShopData = (req, shopId, uid, isApp) => {
if (result[1]) {
shopFilterSearchData.filter = productProcess.processFilter(result[1].filter || []);
shopFilterSearchData.goods = productProcess.processProductList(result[1].product_list || []);
shopFilterSearchData.goods = productProcess.processProductList(result[1].product_list || [], {isApp: isApp});
}
/* 店鋪優惠券 */
... ...
... ... @@ -13,6 +13,15 @@ const api = global.yoho.API;
const camelCase = global.yoho.camelCase;
/**
* 封面图
* @type {{boys: string, gilrs: string}}
*/
const _coverChannel = {
boys: '1,3',
gilrs: '2,3'
};
/**
* 品牌名称处理
* @param {[object]} list
* @return {[object]}
... ... @@ -104,6 +113,8 @@ const _searchGoods = (params) => {
if (params.order) {
params.order = searchProcess.getTypeCont(params.type || '', params.order);
} else {
params.order = 's_t_asc';
}
return api.get('', _.assign({
... ... @@ -119,7 +130,10 @@ const _searchGoods = (params) => {
const getSearchData = (params) => {
return _searchGoods(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || []);
return productProcess.processProductList(result.data.product_list || [], {
isApp: params.appVersion,
gender: _coverChannel[params.coverChannel]
});
} else {
logger.error('get product search api return code is not 200');
return [];
... ...
... ... @@ -16,15 +16,15 @@ module.exports = {
siteUrl: '//m.yohobuy.com',
assetUrl: '//localhost:5001',
domains: {
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://api.live.yoho.cn/',
singleApi: 'http://single.yoho.cn/',
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/',
// api: 'http://api-test1.yohops.com:9999/',
// service: 'http://service-test1.yohops.com:9999/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test1.yohops.com:9999/',
api: 'http://api-test1.yohops.com:9999/',
service: 'http://service-test1.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test1.yohops.com:9999/',
},
subDomains: {
host: '.m.yohobuy.com',
... ...
{
"name": "m-yohobuy-node",
"version": "5.0.4",
"version": "5.0.5",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -31,6 +31,8 @@ var historyval = writeSearch.getHistoryval();
var chHammer, cHammer;
require('../../common');
chHammer = new Hammer($clearHistory[0]);
chHammer.on('tap', function() {
... ... @@ -50,7 +52,7 @@ chHammer.on('tap', function() {
$historySearch.hide();
$clearHistory.hide();
// window.rePosFooter();
window.rePosFooter();
dialog.showDialog({
dialogText: '删除成功',
... ... @@ -187,12 +189,16 @@ $search.on('touchend', function() {
}
$history.html(html);
if (html !== '') {
$clearHistory.removeClass('hide');
$historySearch.removeClass('hide');
}
// window.rePosFooter();
window.rePosFooter();
} else {
$historySearch.hide();
$clearHistory.hide();
}
}
}());
... ...
... ... @@ -52,6 +52,9 @@ require('../../common');
$.ajax({
type: 'GET',
url: '/product/index/shopAppCookie',
xhrFields: {
withCredentials: true
},
error: function() {
tip.show('网络断开连接了~');
}
... ... @@ -61,6 +64,9 @@ require('../../common');
$.ajax({
type: 'GET',
url: '/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: $('.shopid').val(),
},
... ... @@ -222,7 +228,7 @@ function newData(callback) {
req.url = location.protocol + '//m.yohobuy.com/product/search/search';
req.data = {
type: 'new',
order: '1',
order: '0',
page: navInfo.new.page,
tagNew: '1'
};
... ... @@ -637,7 +643,8 @@ function search(opt) {
$.extend(setting, defaultOpt, {
type: navType,
order: nav.order,
page: page
page: page,
appVersion: appVersion
});
if (brand) {
... ... @@ -851,6 +858,7 @@ $subNav.on('touchend touchcancel', function(e) {
type: 'shop_id',
id: shopId,
brand: brand,
appVersion: appVersion,
url: location.protocol + '//m.yohobuy.com/product/search/search',
nextPage: false
});
... ...
... ... @@ -36,7 +36,7 @@
.search {
position: absolute;
top: 18px;
top: 14px;
right: 40px;
border: none;
background: transparent;
... ...
... ... @@ -55,6 +55,10 @@ const getTypeCont = (type, order) => {
return order === '0' ? 'd_s_desc' : 'd_s_asc';
case 'category':
return order === '0' ? 's_t_desc' : 's_t_asc';
case 'new':
return order === '0' ? 's_t_desc' : 's_t_asc';
case 'hot':
return order === '0' ? 's_n_desc' : 's_n_asc';
default:
return order === '0' ? 's_t_desc' : 's_t_asc';
}
... ...