Authored by 沈志敏

Merge branch 'master' of git.yoho.cn:fe/yohobuywap-node into release/couponcenter

... ... @@ -19,7 +19,7 @@ router.get('/girls', channel.switchChannel, channel.girls);
router.get('/kids', channel.switchChannel, channel.kids);
router.get('/lifestyle', channel.switchChannel, channel.lifestyle);
router.get('/channel/bottomBanner', channel.bottomBanner);
router.get('/(:channel)/bottomBanner', channel.bottomBanner);
router.get('/cate', cate.index);
... ...
... ... @@ -192,7 +192,7 @@ const brand = (req, res, next) => {
return;
}
listModel.getBrandLogoByDomain(domain).then((result) => {
listModel.getBrandLogoByDomain(domain).then(result => {
brandLogo = result;
title = brandLogo.name;
... ... @@ -209,20 +209,20 @@ const brand = (req, res, next) => {
if (brandLogo.type === '2' && brandLogo.shopId) {
_shop(req, res, brandLogo.shopId);
} else { // 获取品牌店铺信息
listModel.getBrandShops(brandId).then((brandShop) => {
listModel.getBrandShops(brandId).then(brandShop => {
if (brandId === 0) {
params.query = domain;
}
// 从搜索页过来的,显示搜索框, 和进入品牌引导信息 或者品牌关联多店铺
if (req.query.from === 'search' || brandShop.length > 0) {
params = {
brandWay: brandShop ? brandShop : brandLogo,
params = _.assign({
brandWay: _.isEmpty(brandShop) ? brandLogo : brandShop,
search: {
default: req.query.query,
url: helpers.urlFormat('', null, 'search')
}
};
}, params);
} else if (brandId !== 0) { // 品牌一览过来的展示品牌介绍和LOGO
return Promise.all([listModel.getBrandIntro(brandId, uid), listModel.getBrandBanner(brandId)]).then((resData) => { //eslint-disable-line
title = resData[0].title;
... ... @@ -281,7 +281,7 @@ const shopIntro = (req, res, next) => {
let params = {};
if (shopId) {
listModel.getShopIntro(shopId).then((result) => {
listModel.getShopIntro(shopId).then(result => {
if (appVersion) {
params = {
title: '店铺简介'
... ... @@ -294,7 +294,10 @@ const shopIntro = (req, res, next) => {
};
}
res.render('shop/intro', _.assign(params, result));
res.render('shop/intro', _.assign(params, result, {
module: 'product',
page: 'intro'
}));
}).catch(next);
} else {
res.redirect('/?go=1');
... ... @@ -431,8 +434,6 @@ module.exports = {
brand,
favoriteBrand,
shopIntro,
// pagecache新增
brandFav,
shopAppCookie,
shopFav,
... ...
... ... @@ -25,21 +25,34 @@ const list = (req, res, next) => {
let isQuerySecondClass = false; // 标识用户搜的是不是二级品类
let domain = null;
if (params.query) {
let activity = _.get(searchModel.searchKeyActivity(params.query), 'data.urlobj.appUrl', '');
if (activity) {
res.redirect(activity);
}
}
if (params.shop_id) {
params.shopId = params.shop_id;
}
/* 判断是不是品牌, 是品牌跳到品牌列表页(显示搜索框),判断是不是品类, 是品类加导航标题(不显示搜索框) */
Promise.all([searchModel.getAllBrandNames(), searchModel.getClassNames()]).then((result) => {
Promise.all([
searchModel.getAllBrandNames(),
searchModel.getClassNames()
]).then(result => {
if (query) {
_.forEach(result[0], function(obj) {
query = query.toLowerCase();
_.forEach(result[0], obj => {
if (query === obj.brandDomain && /^[a-z0-9]+$/i.test(obj.brandName)) { // 精确查品牌域名
domain = query;
return false;
}
if (query === obj.brandName || query.toUpperCase() === obj.brandName || query.toLowerCase() === obj.brandName && /^[a-z0-9]+$/i.test(obj.brandName)) { // 精确查品牌名称
domain = obj.brandName;
if (query === obj.brandName || query === obj.brandName || query === obj.brandName && /^[a-z0-9]+$/i.test(obj.brandName)) { // 精确查品牌名称
domain = obj.brandDomain;
return false;
}
... ... @@ -158,13 +171,6 @@ const search = (req, res, next) => {
let params = Object.assign({}, req.query);
if (params.query) {
let activity = _.get(searchModel.searchKeyActivity(params.query), 'data.urlobj.appUrl', '');
if (activity) {
res.redirect(activity);
}
}
searchModel.getSearchData(params).then((result) => {
res.render('search/page', {
layout: false,
... ...
... ... @@ -90,7 +90,7 @@ const _procShowStatus = (data, showStatus, isBeginSale) => {
break;
case 4: // 开售后,立即购买(用户已领取限购码)
data.gotCode = true;
data.cartInfo.canBuyLimit = true;
data.cartInfo.canNotBuy = true;
break;
case 5: // 开售前,限购码已被抢光(用户未领取限购码)
data.codeEmpty = true;
... ...
... ... @@ -7,7 +7,6 @@
const utils = '../../../utils';
const logger = global.yoho.logger;
const crypto = global.yoho.crypto;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
const helpers = global.yoho.helpers;
const api = global.yoho.API;
... ... @@ -27,16 +26,13 @@ const yhChannel = {
/* 多品牌店铺列表数据信息处理*/
const _processBrandShops = (list) => {
const formatDat = [];
let formatDat = [];
list = list || [];
list = camelCase(list);
_.forEach(list, (item) => {
if (item.shopId) {
_.forEach(list, item => {
if (item.shop_id) {
formatDat.push({
url: helpers.urlFormat('/product/index/brand/', {
shop_id: item.brandId
shop_id: item.shop_id
}),
thumb: helpers.image(item.brandIco, 75, 40),
name: item.brandName
... ... @@ -98,11 +94,7 @@ const _getShopDecorator = (shopId) => {
cache: true,
code: 200
}).then((result) => {
if (result.data) {
return camelCase(result.data);
} else {
return '';
}
return result.data;
});
};
... ... @@ -118,11 +110,7 @@ const _getShopInfo = (shopId, uid) => {
shop_id: shopId,
uid: uid || 0
}, {code: 200}).then((result) => {
if (result.data) {
return camelCase(result.data);
} else {
return {};
}
return result.data;
});
};
... ... @@ -139,11 +127,7 @@ const _getShopCategory = (shopId, channel, gender) => {
gender: gender || '1,3',
shop_id: shopId
}, {code: 200}).then(result => {
if (result && result.code === 200) {
return camelCase(result.data);
} else {
return {};
}
return result.data;
});
};
... ... @@ -212,11 +196,8 @@ const getShopBrands = (shopId) => {
method: 'app.shops.getShopsBrands',
shop_id: shopId
}, {code: 200}).then((result) => {
if (result && result.code === 200) {
result = camelCase(result.data);
return result[0].brandId;
} else {
return {};
if (result[0]) {
return result[0].brand_id;
}
});
};
... ... @@ -256,10 +237,10 @@ const _formShopData = (data, shopId, isApp) => {
if (data.decorator) {
_.forEach(data.decorator.list, floor => {
let resData = JSON.parse(floor.resourceData);
let resData = JSON.parse(floor.resource_data);
if (floor.resourceName) {
floor[_.camelCase(floor.resourceName)] = true;
if (floor.resource_name) {
floor[_.camelCase(floor.resource_name)] = true;
}
// 店铺banner
... ... @@ -382,10 +363,11 @@ const _formShopData = (data, shopId, isApp) => {
};
formatData = _.assign({
shopIntro: data.shopInfo.shopIntro,
logoImg: data.shopInfo.shopLogo,
storeName: (data.shopInfo.isShowShopName === 'Y') ? data.shopInfo.shopName : '',
collect: data.shopInfo.isFavorite === 'Y',
shopIntro: _.get(data, 'shopInfo.shop_intro', ''),
logoImg: _.get(data, 'shopInfo.shop_logo', ''),
storeName: (_.get(data, 'shopInfo.is_show_shop_name', '') === 'Y') ?
_.get(data, 'shopInfo.shop_name', '') : '',
collect: _.get(data, 'shopInfo.is_favorite', '') === 'Y',
url: helpers.urlFormat('', {
shop_id: shopId
}, 'search'), // 搜索链接
... ... @@ -434,14 +416,14 @@ const _formShopData = (data, shopId, isApp) => {
shop_id: shopId
});
} else {
_.forEach(data.shopCategory, (item) => {
_.forEach(data.shopCategory, item => {
shopCategory.list.push({
url: helpers.urlFormat('', {
shop_id: shopId,
sort: item.relationParameter.sort
sort: item.relation_parameter.sort
}, 'search'),
categoryId: item.categoryId,
name: item.categoryName
categoryId: item.category_id,
name: item.category_name
});
});
}
... ... @@ -477,8 +459,8 @@ const getBaseShopData = (params, shopInfo) => {
if (result[0] && _.has(result[0], 'list')) {
_.forEach(result[0].list, item => {
if (item.resourceName === 'shopTopBanner_base') {
let banner = JSON.parse(item.resourceData);
if (item.resource_name === 'shopTopBanner_base') {
let banner = JSON.parse(item.resource_data);
finalResult = _.assign(finalResult, {
baseShopHome: {
... ... @@ -515,13 +497,10 @@ const getShopData = (req, shopId, uid, isApp) => {
let shopData = {};
let channel = req.yoho.channel;
/* 变量污染临时处理 */
// shopId = shopId.replace(/\//, '');
return _getShopInfo(shopId, uid).then(shopInfoResult => {
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
if (shopInfoResult.shopTemplateType && parseInt(shopInfoResult.shopTemplateType, 10) === 1) {
if (shopInfoResult.shop_template_type && parseInt(shopInfoResult.shop_template_type, 10) === 1) {
return {
goBrand: shopInfoResult
};
... ... @@ -556,7 +535,8 @@ const getShopData = (req, shopId, uid, isApp) => {
let shopCoupons = result[2] || [];
// 店铺分类
return _getShopCategory(shopId, channel).then((shopCategory) => {
return _getShopCategory(shopId, channel).then(shopCategory => {
shopData = _.assign({
shopCategory: shopCategory
}, shopData);
... ... @@ -597,31 +577,27 @@ const getShopFav = (req, shopId, uid) => {
* @return array banner数据
*/
const getBrandIntro = (brandId, uid) => {
let param = {};
param = {
uid: uid,
let param = {
uid: uid
};
return api.get('', _.assign({
method: 'app.brand.getBrandIntro',
brand_id: brandId
}, param), {
code: 200,
cache: true
}).then((result) => {
if (result && result.code === 200) {
let list = camelCase(result.data) || {};
}).then(result => {
let list = result.data;
return {
id: list.brandId,
intro: list.brandIntro,
collected: (list.isFavorite && list.isFavorite === 'Y') ? true : false,
title: list.brandName ? list.brandName : ''
id: list.brand_id,
intro: list.brand_intro,
collected: list.is_favorite && list.is_favorite === 'Y',
title: list.brand_name ? list.brand_name : ''
};
} else {
logger.error('get brand introduction api return code is not 200');
return {};
}
});
};
... ... @@ -660,27 +636,23 @@ const getBrandLogoByDomain = (domain) => {
method: 'web.brand.byDomain',
domain: domain
}, {
code: 200,
cache: true
}).then((result) => {
if (result && result.code === 200) {
}).then(result => {
if (result.data) {
let formatData = camelCase(result.data);
let formatData = result.data;
return {
id: formatData.id,
url: helpers.urlFormat('', null, formatData.brandDomain),
thumb: helpers.image(formatData.brandIco, 75, 40),
name: formatData.brandName,
shopId: formatData.shopId ? formatData.shopId : 0, // 店铺id
url: helpers.urlFormat('', null, formatData.brand_domain),
thumb: helpers.image(formatData.brand_ico, 75, 40),
name: formatData.brand_name,
shopId: formatData.shop_id ? formatData.shop_id : 0, // 店铺id
type: formatData.type ? formatData.type : 0
};
} else {
return false;
}
} else {
logger.error('get brand logo by domain api return code is not 200');
return {};
}
});
};
... ... @@ -694,13 +666,13 @@ const getBrandShops = (brandId) => {
method: 'app.shop.queryShopsByBrandId',
brand_id: brandId
}, {
code: 200,
cache: true
}).then((result) => {
if (result && result.code === 200) {
}).then(result => {
if (_.isArray(result.data)) {
return _processBrandShops(result.data);
} else {
logger.error('get shop list by brandId api return code is not 200');
return {};
return [];
}
});
};
... ... @@ -748,13 +720,8 @@ const getShopIntro = (shopId) => {
return api.get('', {
method: 'app.shops.getIntro',
shop_id: shopId
}).then((result) => {
if (result && result.code === 200) {
return camelCase(result.data);
} else {
logger.error('get shop intro api return code is not 200');
return {};
}
}, {code: 200, cache: true}).then(result => {
return result.data;
});
};
... ... @@ -779,7 +746,7 @@ const getShopCategory = (params) => {
_.forEach(value.sub, (subValue, subKey) => {
value.sub[subKey].url = helpers.urlFormat('/product/search/list', {
shop_id: params.shopId,
sort: _.get(value, 'relationParameter.sort', ''),
sort: _.get(value, 'relation_parameter.sort', ''),
title: subValue.categoryName,
query: subValue.categoryName
});
... ...
... ... @@ -26,8 +26,8 @@ const _processBrandNames = (list) => {
_.forEach(list, (item) => {
_.forEach(item, (obj) => {
formatData.push({
brandDomain: obj.brandDomain,
brandName: obj.brandName
brandDomain: obj.brandDomain.toLowerCase(),
brandName: obj.brandName.toLowerCase()
});
});
});
... ...
... ... @@ -179,8 +179,8 @@
<a href="javascript:;" class="sold-out limit">即将发售</a>
{{/if}}
{{#if canBuyLimit}}
<a href="javascript:;" id="addtoCart" class="addto-cart">立即购买</a>
{{#if canNotBuy}}
<a href="javascript:;" class="addto-cart can-not-buy">立即购买</a>
{{/if}}
{{#if noLimitCode}}
... ...
<div class="shop-introduce-page">
<a class="banner">
<img src="{{image shopLogo 640 480}}">
<img src="{{image shop_logo 640 480}}">
</a>
<div class="descripition">
{{shopIntro}}
{{shop_intro}}
</div>
<p class="sign-icon">
... ...
... ... @@ -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',
... ...
... ... @@ -125,15 +125,16 @@ module.exports = function(specificGender) {
page: page + 1
},
success: function(data) {
// console.log(data)
var PRDID = [];
if (data === ' ') {
console.log(data);
if (data === ' ' || data === '') {
searching = false;
loading.hideLoadingMask();
// 有货币页面不加载底部
if (gender && !specificGender) {
gender = gender.substr(0, 3);
if (gender === '1,3') {
url = '/boys/bottomBanner';
} else {
... ...
/**
* Created by yoho on 2016/10/9.
*/
require('../common');
... ...
/*
* @Description: dialog
*/
var $ = require('yoho-jquery'),
Handlebars = require('yoho-handlebars'),
Hammer = require('yoho-hammer');
var $dialogWrapper,
dialogTpl,
dialogTemplate;
function getInstance() {
if (dialogTpl === undefined) {
dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
'<div class="dialog-box">' +
'{{# hasHeader}}' +
'{{/ hasHeader}}' +
'<div class="dialog-content">{{dialogText}}</div>' +
'{{# hasFooter}}' +
'<div class="dialog-footer">' +
'{{# leftBtnText}}' +
'<span class="dialog-left-btn tap-hightlight">{{.}}</span>' +
'{{/ leftBtnText}}' +
'{{# rightBtnText}}' +
'<span class="dialog-right-btn tap-hightlight">{{.}}</span>' +
'{{/ rightBtnText}}' +
'</div>' +
'{{/ hasFooter}}' +
'</div>' +
'</div>';
dialogTemplate = Handlebars.compile(dialogTpl);
}
return dialogTemplate;
}
// fullWithBtn是供详情页获取限购码使用的特殊参数
exports.showDialog = function(data, callback, callbackForLeft, fullWithBtn) {
var dialogStr = dialogTemplate(data),
$dialogBox,
defaultHideDuraton,
dialogWrapperHammer;
dialogTemplate = getInstance();
$('.dialog-wrapper').remove();
$('body').append($(dialogStr));
$dialogBox = $('.dialog-box');
$dialogWrapper = $('.dialog-wrapper');
dialogWrapperHammer = new Hammer(document.getElementById('dialog-wrapper'));
// 显示
if (data.fast) {
$dialogWrapper.css({
display: 'block'
});
} else {
$dialogWrapper.fadeIn();
}
if (fullWithBtn) {
$('.dialog-wrapper .dialog-footer > span').css('width', '100%');
$('.dialog-wrapper .dialog-content').css({
'padding-left': '1.85rem',
'padding-right': '1.85rem'
});
$dialogWrapper.css('z-index', '10');
}
$dialogBox.css({
top: '50%',
marginTop: -($dialogBox.height() / 2)
});
// 隐藏
if (data.autoHide) {
defaultHideDuraton = 1000;
if (data.autoHide > 1) {
defaultHideDuraton = data.autoHide;
}
setTimeout(function() {
$dialogWrapper.fadeOut();
}, defaultHideDuraton);
}
// 禁止在dialog上可以上下滚动
$dialogWrapper.on('touchmove', function() {
return false;
});
dialogWrapperHammer.on('tap', function(event) {
if ($(event.target).hasClass('dialog-left-btn')) {
if (typeof callbackForLeft === 'function') {
callbackForLeft();
}
$dialogWrapper.fadeOut();
} else if ($(event.target).hasClass('dialog-right-btn')) {
callback();
}
// 防止出现点透问题
event.preventDefault();
event.srcEvent.stopPropagation();
});
};
exports.hideDialog = function() {
$('.dialog-wrapper').remove();
};
... ... @@ -8,7 +8,7 @@ var $ = require('yoho-jquery'),
security = require('../../plugin/security'),
tip = require('../../plugin/tip'),
Hammer = require('yoho-hammer'),
dialog = require('../search/dialog');
dialog = require('../../plugin/dialog');
var $input = $('#search-input input');
... ...
... ... @@ -89,7 +89,7 @@ ellipsis.init();
tip.show('网络断开连接了~');
}
});
} else {
} else if ($('.shopId').val().length > 0){
$.ajax({
url: '/product/index/baseShopFav',
data: {
... ...
... ... @@ -768,6 +768,10 @@ $basicBtnC: #eb0313;
line-height: 80px;
}
.can-not-buy {
background-color: #ccc;
}
.sold-out {
background-color: #ccc;
}
... ...