Authored by yyq

Merge branch 'release/5.5' of git.yoho.cn:fe/yohobuy-node into release/5.5

/**
* Controller
* @author: gxh<xuhui.ge@yoho.cn>
* @date: 2017/02/28
*/
'use strict';
const mRoot = '../models';
const search = require(`${mRoot}/search`);
const _ = require('lodash');
/**
* search 搜索历史提示
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
const suggestHistory = (req, res, next) => {
search.getSuggest(req.query).then(result => {
let dest = {
code: 200,
message: 'suggest',
data: result || ''
};
res.type('text/javascript');
res.send(req.query.callback + '(' + JSON.stringify(dest) + ')');
}).catch(next);
};
exports.suggest4Old = (req, res, next) => {
search.getSuggest(Object.assign({}, req.query, { keyword: req.query.query })).then(result => {
let dest = {
code: 200,
message: 'suggest'
};
let data = [];
if (result) {
for (let it of result) {
let item = '<li>' +
`<a style="display: block;" href="${it.href}" class="clearfix clear search-item" title="${it.keyword}" act="${it.href}">` + // eslint-disable-line
`<span class="searchvalue" >${it.keyword}</span><span class="valuenum">约${it.count}个商品</span>` + // eslint-disable-line
'</a>' +
'</li>';
data.push(item);
}
}
dest.data = data;
res.send(req.query.callback + '(' + JSON.stringify(dest) + ')');
}).catch(next);
};
module.exports = {
suggestHistory
};
/**
* Models-api
* @author: gxh<xuhui.ge@yoho.cn>
* @date: 2017/02/28
*/
'use strict';
const _ = require('lodash');
const md5 = require('md5');
const api = global.yoho.API;
const config = global.yoho.config;
const getSuggest = (params) => {
let finalParams = {
method: 'app.search.fuzzy',
keyword: params.keyword || ''
};
return api.get('', finalParams, config.apiCache);
};
module.exports = {
getSuggest
};
/**
* Models-service
* @author: gxh<xuhui.ge@yoho.cn>
* @date: 2017/02/28
*/
'use strict';
const utils = '../../../utils';
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const searchApi = require('./search-api');
const headerModel = require('../../../doraemon/models/header');
// const searchHandler = require('./search-handler');
const _ = require('lodash');
const needParams = ['query', 'msort', 'misort'];
/**
* 获取搜索数据
* @param {[type]} origin [description]
* @return {[type]} [description]
*/
// exports.getSearchData = (params, channel) => {
// let searchParams = searchHandler.getSearchParams(params);
//
// switch (channel) {
// case 'boys':
// searchParams.physical_channel = 1;
// break;
// case 'girls':
// searchParams.physical_channel = 2;
// break;
// case 'kids':
// searchParams.physical_channel = 3;
// break;
// case 'lifestyle':
// searchParams.physical_channel = 4;
// break;
// default:
// break;
// }
//
// // 调用接口
// let apiMethod = [
// headerModel.requestHeaderData(channel),
// searchApi.getSortList(Object.assign({}, searchParams, {msort: '', misort: '', sort: ''})),
// searchApi.getProductList(searchParams),
// searchApi.getShopList(params)
// ];
//
// return api.all(apiMethod).then(result => {
// let finalResult = {
// headerData: Object.assign(result[0].headerData, {
// header: true
// }),
// search: {}
// };
//
// // 获取左侧类目数据
// if (result[1].code === 200) {
// let dps = {};
//
// _.forEach(needParams, (value) => {
// if (params[value]) {
// dps[value] = params[value];
// }
// });
//
// finalResult.search = {
// leftContent: searchHandler.handleSortData(result[1].data.sort, dps, params)
// };
// }
//
// // 获取商品数据和顶部筛选条件
// if (result[2].code === 200) {
//
// let filters = Object.assign(searchHandler.handleFilterDataAll(result[2].data, params),
// finalResult.search.leftContent.sort);
//
// filters.checkedConditions.conditions = _.concat(filters.checkedConditions.conditions,
// finalResult.search.leftContent.checked);
//
// Object.assign(finalResult.search,
// searchHandler.handlePathNavData({total: result[2].data.total }, params, 'search', channel),
// {
// filters: filters,
// opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
// totalCount: result[2].data.total,
// footPager: searchHandler.handlePagerData(result[2].data.total, params),
// goods: productProcess.processProductList(result[2].data.product_list,
// Object.assign({showDiscount: false, from: {type: 'search', params: params}}, params)),
// latestWalk: 6,
// hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
// shopEntry: result[3]
// });
//
// finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
// }
// return finalResult;
// });
// };
/**
* 处理搜索提示
* @type {[type]}
*/
const handleSuggest = (data) => {
let suggest = [];
_.forEach(data, function(value) {
suggest.push({
href: helpers.urlFormat('', {query: value.keyword}, 'search'),
keyword: value.keyword,
count: value.count
});
});
return suggest;
};
/**
* 搜索提示
*/
const getSuggest = (params) => {
return searchApi.getSuggest(params).then(result => {
let dest = [];
if (result.code === 200) {
dest = handleSuggest(result.data);
}
return dest;
});
};
module.exports = {
handleSuggest,
getSuggest
};
'use strict';
const headerModel = require('../../../doraemon/models/header');
const msgModel = require('../models/message');
const helpers = global.yoho.helpers;
const _ = require('lodash');
const homeNav = (req) => {
return [
{
title: '交易管理',
subNav: [
{name: '我的订单', href: '/home/orders', catchs: ['/home/orders', '/home/index', '/home/orders/detail']},
{name: '我的收藏', href: '/home/favorite', catchs: ['/home/favorite/reduction']},
{name: '我的有货币', href: '/home/currency'},
{name: '我的红包', href: '/home/redenvelopes'},
{name: '我的优惠券', href: '/home/coupons'},
{name: '我的VIP', href: '/home/vip'}
]
},
{
title: '服务中心',
subNav: [
{name: '我的退/换货', href: '/home/returns'},
{name: '我的咨询', href: '/home/consult'},
{name: '我的评论', href: '/home/comment'},
// {name: '我的投诉', href: '/home/complaints'},
{name: '我的信息', href: '/home/message', count: 0},
{
name: '在线客服',
href: _.get(req.app.locals.pc, 'clientService.new', false) ?
'/service/client' : 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&amp;configID=149091&amp;jid=8732423409',
isBlank: true
}
]
},
{
title: '个人信息管理',
subNav: [
{name: '编辑个人资料', href: '/home/user'},
{name: '账号安全', href: '/home/account', catchs: [
'/home/account/userpwd',
'/home/account/email',
'/home/account/mobile',
'/home/account/checkverifycode',
'/home/account/checkpassword',
'/home/account/verifypassword',
'/home/account/modifypwd',
'/home/account/sendemail',
'/home/account/checkemail',
'/home/account/modifyemail',
'/home/account/sendemailsuccess',
'/home/account/mailresult',
'/home/account/checkmobile',
'/home/account/checkmobilemsg',
'/home/account/sendmobilemsg',
'/home/account/modifymobile'
]},
{name: '地址管理', href: '/home/address'},
{name: '兑换礼品卡', href: '/home/gift'}
]
}
];
};
const getActiveNav = (req, count)=>{
let mHomeNav = _.cloneDeep(homeNav(req));
let activeNav = null;
mHomeNav = mHomeNav.map((item) => {
item.subNav = item.subNav.map((nav) => {
let curMatchPath = req.originalUrl;
if (!nav.matchQuery && curMatchPath.indexOf('?') >= 0) { // 严格的路径匹配,包含后面的参数
curMatchPath = curMatchPath.substr(0, curMatchPath.indexOf('?'));
}
if (curMatchPath === nav.href) {
nav.active = true;
}
if (nav.name === '我的信息') {
nav.count = +count;
}
if (nav.catchs) {
let index = nav.catchs.indexOf(curMatchPath);
if (index > -1) {
nav.active = true;
nav.curHref = nav.catchs[index];
}
}
if (nav.active) {
activeNav = nav;
}
nav.href = nav.href.indexOf('http://') > -1 ? nav.href : helpers.urlFormat(nav.href);
return nav;
});
return item;
});
return {
homeNav: mHomeNav,
activeNav: activeNav
};
};
const getHomeNav = (req, res, next) => {
msgModel.unreadTotal(req.user.uid).then(result => {
let navs = getActiveNav(req, _.get(result, 'data.total', 0));
let activeNav = navs.activeNav;
let bread = [{href: helpers.urlFormat('/'), name: 'YOHO!BUY 有货首页'}];
if (activeNav) {
bread.push({
name: '个人中心',
href: helpers.urlFormat('/home')
});
bread.push({
name: activeNav.name
});
// 订单详情
if (activeNav.curHref === '/home/orders/detail') {
Object.assign(_.last(bread), {
href: helpers.urlFormat('/home/orders')
});
bread.push({
name: '订单详情'
});
}
} else {
bread.push({
name: '个人中心'
});
}
res.locals.path = bread; // [{href: helpers.urlFormat('/'), name: 'YOHO!BUY 有货首页'}, {name: '个人中心'}];
res.locals.homeNav = navs.homeNav;
res.locals.userThumb = '//img10.static.yhbimg.com/headimg/' +
'2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100';
next();
});
};
const headerService = require('../models/general-tabs-service');
const getCommonHeader = (req, res, next) => {
let channel = req.query.channel ? req.query.channel : 'boys';
let channel = req.query.channel;
let uid = req.user.uid;
let clientService = _.get(req.app.locals.pc, 'clientService.new', false);
headerModel.requestHeaderData(channel).then((result)=>{
headerService.getHomeNav(uid, channel, req.originalUrl, clientService).then((result)=>{
_.merge(res.locals, result);
next();
});
};
module.exports = {
homeNav,
getActiveNav,
getHomeNav,
getCommonHeader
};
... ...
... ... @@ -65,9 +65,11 @@ const getCouponsList = (uid, type, page, limit)=>{
if (limits.indexOf('2') >= 0) {
extra.push('限量');
}
delete item.isNoLimit;
result[i].extraPro = extra.join('、');
result[i].isNoLimit = item.isNoLimit;
result[i].isNoLimit = item.isNoLimit === 'true' ? true : false;
result[i].explains = _.isEmpty(item.explains) ? false : item.explains;
result[i].proListUrl = helpers.urlFormat('', {cpc_id: item.couponId,
phrase: encodeURIComponent('以下商品可使用 【' + item.couponDetailInfomation + '】优惠券')}, 'list');
result[i].rule = item.rule4ShortName || '';
... ...
'use strict';
const _ = require('lodash');
const userApi = require('./user-api');
const headerModel = require('../../../doraemon/models/header');
const msgModel = require('./message');
const helpers = global.yoho.helpers;
const defaultAvatar = '//img10.static.yhbimg.com/headimg/' +
'2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100';
const _homeNav = (switcher) => {
return [
{
title: '交易管理',
subNav: [
{name: '我的订单', href: '/home/orders', catchs: ['/home/orders', '/home/index', '/home/orders/detail']},
{name: '我的收藏', href: '/home/favorite', catchs: ['/home/favorite/reduction']},
{name: '我的有货币', href: '/home/currency'},
{name: '我的红包', href: '/home/redenvelopes'},
{name: '我的优惠券', href: '/home/coupons'},
{name: '我的VIP', href: '/home/vip'}
]
},
{
title: '服务中心',
subNav: [
{name: '我的退/换货', href: '/home/returns'},
{name: '我的咨询', href: '/home/consult'},
{name: '我的评论', href: '/home/comment'},
// {name: '我的投诉', href: '/home/complaints'},
{name: '我的信息', href: '/home/message', count: 0},
{
name: '在线客服',
href: switcher ?
'/service/client' : 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&amp;configID=149091&amp;jid=8732423409',
isBlank: true
}
]
},
{
title: '个人信息管理',
subNav: [
{name: '编辑个人资料', href: '/home/user'},
{name: '账号安全', href: '/home/account', catchs: [
'/home/account/userpwd',
'/home/account/email',
'/home/account/mobile',
'/home/account/checkverifycode',
'/home/account/checkpassword',
'/home/account/verifypassword',
'/home/account/modifypwd',
'/home/account/sendemail',
'/home/account/checkemail',
'/home/account/modifyemail',
'/home/account/sendemailsuccess',
'/home/account/mailresult',
'/home/account/checkmobile',
'/home/account/checkmobilemsg',
'/home/account/sendmobilemsg',
'/home/account/modifymobile'
]},
{name: '地址管理', href: '/home/address'},
{name: '兑换礼品卡', href: '/home/gift'}
]
}
];
};
const _getActiveNav = (url, switcher, count) =>{
let mHomeNav = _.cloneDeep(_homeNav(switcher));
let activeNav = null;
mHomeNav = mHomeNav.map((item) => {
item.subNav = item.subNav.map((nav) => {
let curMatchPath = url;
if (!nav.matchQuery && curMatchPath.indexOf('?') >= 0) { // 严格的路径匹配,包含后面的参数
curMatchPath = curMatchPath.substr(0, curMatchPath.indexOf('?'));
}
if (curMatchPath === nav.href) {
nav.active = true;
}
if (nav.name === '我的信息') {
nav.count = +count;
}
if (nav.catchs) {
let index = nav.catchs.indexOf(curMatchPath);
if (index > -1) {
nav.active = true;
nav.curHref = nav.catchs[index];
}
}
if (nav.active) {
activeNav = nav;
}
nav.href = nav.href.indexOf('http://') > -1 ? nav.href : helpers.urlFormat(nav.href);
return nav;
});
return item;
});
return {
homeNav: mHomeNav,
activeNav: activeNav
};
};
const _getAvatar = (uid) => {
return userApi.getUserInfo(uid).then((result) => {
return _.get(result, 'data.head_ico', '') || defaultAvatar;
});
};
const _msgCount = (uid) => {
return msgModel.unreadTotal(uid).then(result => _.get(result, 'data.total', 0));
};
const _getTabsData = (uid, channel) => {
return Promise.props({
msg: _msgCount(uid),
header: headerModel.requestHeaderData(channel),
avatar: _getAvatar(uid)
});
};
const getHomeNav = (uid, channel, url, clientSwitcher) => {
return _getTabsData(uid, channel).then((result) => {
let navs = _getActiveNav(url, clientSwitcher, result.msg);
let activeNav = navs.activeNav;
let bread = [{href: helpers.urlFormat('/'), name: 'YOHO!BUY 有货首页'}];
if (activeNav) {
bread.push({
name: '个人中心',
href: helpers.urlFormat('/home')
});
bread.push({
name: activeNav.name
});
// 订单详情
if (activeNav.curHref === '/home/orders/detail') {
Object.assign(_.last(bread), {
href: helpers.urlFormat('/home/orders')
});
bread.push({
name: '订单详情'
});
}
} else {
bread.push({
name: '个人中心'
});
}
return Object.assign({
path: bread,
homeNav: navs.homeNav,
userThumb: result.avatar
}, result.header);
});
};
module.exports = {
getHomeNav
};
... ...
... ... @@ -764,7 +764,7 @@ const _getOrderDetail = co(function * (uid, orderId) {
}
// 判断是否可以修改省份
if (orderDetail.is_support_change_province === 'Y') {
if (orderDetail.is_support_change_province === 'N') {
detail.changeProvince = true;
}
... ...
... ... @@ -43,24 +43,20 @@ const giftController = require(`${cRoot}/gift`);
// 首页
router.get(['/index', '/'],
[tabsMiddleware.getHomeNav, tabsMiddleware.getCommonHeader], indexController.index);
router.get(['/index', '/'], tabsMiddleware.getCommonHeader, indexController.index);
// 查看二维码
router.get('/QRcode', [tabsMiddleware.getHomeNav, tabsMiddleware.getCommonHeader], personalController.QRcode);
router.get('/QRcode', tabsMiddleware.getCommonHeader, personalController.QRcode);
// 我的评论
router.get('/comment',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], commentController.index);
router.get('/comment', tabsMiddleware.getCommonHeader, commentController.index);
router.post('/comment/saveComment', commentController.saveComment);
router.get('/comment/order',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], commentController.commentList4Order);
router.get('/comment/order', tabsMiddleware.getCommonHeader, commentController.commentList4Order);
// 我的咨询
router.get('/consult',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], consultController.index);
router.get('/consult', tabsMiddleware.getCommonHeader, consultController.index);
// 我的投诉
// router.get('/complaints', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], complaintsController.index);
... ... @@ -68,11 +64,9 @@ router.get('/consult',
// router.post('/complaints/cancel', complaintsController.cancel);
// 我的消息
router.get('/message',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], messageController.index);
router.get('/message', tabsMiddleware.getCommonHeader, messageController.index);
router.get('/message/detail',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], messageController.detail);
router.get('/message/detail', tabsMiddleware.getCommonHeader, messageController.detail);
router.get('/message/del', messageController.delMsg);
router.get('/message/read', messageController.readMsg);
... ... @@ -89,30 +83,26 @@ router.get('/message/pickCoupon', messageController.pickCoupon);
// router.get('/index', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], IndexController.index);
/* 我的YOHO币 */
router.get('/currency',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], currencyController.index);
router.get('/currency', tabsMiddleware.getCommonHeader, currencyController.index);
/* 我的红包 */
router.get('/redenvelopes',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], redenvelopesController.index);
router.get('/redenvelopes', tabsMiddleware.getCommonHeader, redenvelopesController.index);
/* 我的VIP */
router.get('/vip',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], vipController.index);
router.get('/vip', tabsMiddleware.getCommonHeader, vipController.index);
/* 我的优惠卷 */
router.get('/coupons', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], couponsController.index);
router.get('/coupons', tabsMiddleware.getCommonHeader, couponsController.index);
/** ******************************* 我的收藏开始 *****************************************/
// 我的收藏
router.get('/favorite', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], favoriteController.index);
router.get('/favorite', tabsMiddleware.getCommonHeader, favoriteController.index);
// 品牌页新品到着
router.get('/favorite/newproduct', favoriteController.newProduct);
// 降价提醒
router.get('/favorite/reduction',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], favoriteController.reduction);
router.get('/favorite/reduction', tabsMiddleware.getCommonHeader, favoriteController.reduction);
// 设置降价提醒
router.get('/favorite/notice', favoriteController.notice);
... ... @@ -126,7 +116,7 @@ router.get('/favorite/cancel', favoriteController.cancel);
/** ******************************* 我的收藏结束 *****************************************/
/** ******************************* 我的订单开始 *****************************************/
router.get('/orders', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], ordersController.index);
router.get('/orders', tabsMiddleware.getCommonHeader, ordersController.index);
// 重新加入购物车
router.post('/orders/readd', ordersController.reBuy);
... ... @@ -144,8 +134,7 @@ router.post('/orders/confirmOrder', ordersController.confirm);
router.post('/orders/cancelOrder', ordersController.cancel);
// 订单详情
router.get('/orders/detail',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], ordersController.detail);
router.get('/orders/detail',tabsMiddleware.getCommonHeader, ordersController.detail);
// 物流信息
router.get('/orders/express', ordersController.express);
... ... @@ -160,8 +149,7 @@ router.get('/orders/refundreason', ordersController.refundReason);
// router.get('/coupons', CouponsController.index);
router.get('/user', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], UserController.index);
router.get('/user', tabsMiddleware.getCommonHeader, UserController.index);
router.post('/user/edituserinfo', UserController.editUserInfo);
... ... @@ -205,42 +193,31 @@ router.get('/bind/renren/callback', bindController.renren.callback);
router.post('/cancelbind/:type', bindController.cancelBind);
// 账号安全
router.get('/account',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.index);
router.get('/account', tabsMiddleware.getCommonHeader, AccountController.index);
router.get('/account/userpwd',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.userPwd);
router.get('/account/userpwd', tabsMiddleware.getCommonHeader, AccountController.userPwd);
router.get('/account/email', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.userEmail);
router.get('/account/email', tabsMiddleware.getCommonHeader, AccountController.userEmail);
router.get('/account/mobile',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.userMobile);
router.get('/account/mobile', tabsMiddleware.getCommonHeader, AccountController.userMobile);
router.post('/account/checkverifycode',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.checkVerifyCode);
router.post('/account/checkverifycode', tabsMiddleware.getCommonHeader, AccountController.checkVerifyCode);
router.post('/account/checkpassword',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.checkPassword);
router.post('/account/checkpassword', tabsMiddleware.getCommonHeader, AccountController.checkPassword);
router.post('/account/verifypassword',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.verifyPassword);
router.post('/account/verifypassword', tabsMiddleware.getCommonHeader, AccountController.verifyPassword);
router.post('/account/modifypwd',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.modifyPwd);
router.post('/account/modifypwd', tabsMiddleware.getCommonHeader, AccountController.modifyPwd);
router.post('/account/sendemail', AccountController.sendEmail);
router.post('/account/checkemail',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.checkEmail);
router.post('/account/checkemail', tabsMiddleware.getCommonHeader, AccountController.checkEmail);
router.post('/account/modifyemail',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.modifyEmail);
router.post('/account/modifyemail', tabsMiddleware.getCommonHeader, AccountController.modifyEmail);
router.get('/account/sendemailsuccess',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.sendEmailSuccess);
router.get('/account/sendemailsuccess', tabsMiddleware.getCommonHeader, AccountController.sendEmailSuccess);
router.get('/account/mailresult',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AccountController.mailResult);
router.get('/account/mailresult', tabsMiddleware.getCommonHeader, AccountController.mailResult);
router.post('/account/checkmobile', AccountController.checkMobile);
... ... @@ -252,8 +229,7 @@ router.post('/account/modifymobile', AccountController.modifyMobile);
// 地址管理
router.get('/address',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], AddressController.index);
router.get('/address', tabsMiddleware.getCommonHeader, AddressController.index);
router.get('/address/area', UserController.getProviceList);
... ... @@ -267,8 +243,7 @@ router.get('/address/defaultAddress', AddressController.defaultAddress);
// 兑换礼品卡
router.get('/gift',
[tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], giftController.index);
router.get('/gift', tabsMiddleware.getCommonHeader, giftController.index);
router.post('/gift/exchange', giftController.exchange);
... ...
... ... @@ -43,7 +43,9 @@
<div class="coupons-text">
{{#categorys}}<p>限品类:{{.}}</p>{{/categorys}}
{{#brands}}<p>限品牌:{{.}}</p>{{/brands}}
{{#if isNoLimit}}<p>全场通用</p>{{/if}}
<p>特例商品({{extraPro}}等特例商品)暂不支持使用优惠券。</p>
{{#explains}}<p>说明:{{.}}</p>{{/explains}}
</div>
</div>
<div class="coupons-opt">
... ... @@ -76,6 +78,7 @@
{{#brands}}<p>限品牌:{{.}}</p>{{/brands}}
{{#if isNoLimit}}<p>全场通用</p>{{/if}}
<p>特例商品({{extraPro}}等特例商品)暂不支持使用优惠券。</p>
{{#explains}}<p>说明:{{.}}</p>{{/explains}}
</div>
</div>
<div class="coupons-opt">
... ... @@ -109,7 +112,9 @@
<div class="coupons-text">
{{#categorys}}<p>限品类:{{.}}</p>{{/categorys}}
{{#brands}}<p>限品牌:{{.}}</p>{{/brands}}
{{#if isNoLimit}}<p>全场通用</p>{{/if}}
<p>特例商品({{extraPro}}等特例商品)暂不支持使用优惠券。</p>
{{#explains}}<p>说明:{{.}}</p>{{/explains}}
</div>
</div>
<div class="coupons-opt">
... ...
... ... @@ -6,7 +6,7 @@
const _ = require('lodash');
const CAPTCHA = require('../data/captcha.json');
const length = CAPTCHA.length || -1;
const length = CAPTCHA.length - 1 || -1;
exports.gen = () => {
if (length !== -1) {
... ...
... ... @@ -95,7 +95,7 @@ const suggest4Old = (req, res, next) => {
}).catch(next);
};
const serachFilterBrands = (req, res, next) => {
const searchFilterBrands = (req, res, next) => {
search.getBrands4Filter(Object.assign({}, req.query, {
keyword: req.query.query || ''
})).then(result => {
... ... @@ -117,17 +117,12 @@ const serachFilterBrands = (req, res, next) => {
*/
const searchHistory = (req, res) => {
let history = req.cookies['_History'] || ''; //eslint-disable-line
let q = req.query.query ? _.trim(decodeURIComponent(req.query.query)) : '';
let history = _.trim(req.cookies['_History']); //eslint-disable-line
let q = _.trim(decodeURIComponent(req.query.query) || '');
history = _.filter(history.split(','), old => old && old !== q);
let data = [];
let ResData = {};
history = history ? history.split(',') : [];
history = _.reject(history, old => old === q ? true : false);
if (q !== '') {
if (q) {
history.unshift(q);
res.cookie('_History', _.take(history, 9).join(','), {
domain: config.cookieDomain,
... ... @@ -135,19 +130,15 @@ const searchHistory = (req, res) => {
});
}
_.forEach(history, function(item) {
let list = {};
list['keyword'] = item; //eslint-disable-line
list['href'] = helpers.urlFormat('', {query: list['keyword']}, 'search'); //eslint-disable-line
data.push(list);
let data = _.map(history, (item) => {
return {
keyword: item,
href: helpers.urlFormat('', {query: item}, 'search')
};
});
ResData['data'] = data; //eslint-disable-line
res.type('text/javascript');
res.send(req.query.callback + '(' + JSON.stringify(ResData) + ')');
res.send(req.query.callback + '(' + JSON.stringify({ data }) + ')');
};
... ... @@ -159,11 +150,6 @@ const searchHistory = (req, res) => {
*/
const searchRecommend = (req, res, next) => {
search.getSearchRecommend(req.yoho.channel, req.query).then(result => {
if (req.query.json === '1') {
return res.send(result);
}
let dest = {
code: 200,
message: 'recommend',
... ... @@ -176,32 +162,11 @@ const searchRecommend = (req, res, next) => {
}).catch(next);
};
/**
* 搜索少或无 有可能喜欢
**/
const searchLessRecommend = (req, res, next) => {
let channel = req.yoho.channel;
let uid = req.user.uid;
let udid = req.yoho.udid;
let page = Number(req.query.page || 1);
if (page <= 0 || page >= 6) {
page = 1;
}
search.getSearchLessProduct(channel, uid, udid, page).then(result => {
return res.send(result);
}).catch(next);
};
module.exports = {
index,
suggest,
suggest4Old,
serachFilterBrands,
searchHistory,
searchRecommend,
searchLessRecommend
searchFilterBrands,
searchHistory, // 搜索历史记录
searchRecommend // 搜索框下方 热门搜索
};
... ...
... ... @@ -425,17 +425,14 @@ const getBrands4Filter = (params) => {
* @return
*/
const getSearchRecommend = (channel, params) => {
let finalParams = {
return api.get('', {
method: 'app.search.getTerms',
content: params.content || '',
yh_channel: channel,
sort: params.sort,
status: params.status,
type: params.type
};
return api.get('', finalParams, config.apiCache);
}, config.apiCache);
};
/**
... ...
... ... @@ -40,6 +40,7 @@ const transPrice = (price) => {
* @return {[type]} [description]
*/
exports.getSearchData = (params, channel) => {
let searchParams = searchHandler.getSearchParams(params);
switch (channel) {
... ... @@ -114,7 +115,7 @@ exports.getSearchData = (params, channel) => {
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
shopEntry: result[3],
name: params.query,
suggest: (termsSuggestion.length !== 0) ? termsSuggestion.splice(0, 3) : false,
suggest: (termsSuggestion.length !== 0) ? termsSuggestion.slice(0, 3) : false,
changedQuery: result[2].data.isChangedQuery === 'Y',
suggestFirst: finalResult.search.suggestFirst,
suggestSecond: finalResult.search.suggestSecond
... ... @@ -227,33 +228,28 @@ exports.getBrands4Filter = (params) => {
* @return {[type]} [description]
*/
exports.getSearchRecommend = (channel, params) => {
let channelNum = (function() {
switch (channel) {
case 'boys':
return 1;
case 'girls':
return 2;
case 'kids':
case 'lifestyle':
return 3;
default:
return 1;
}
}());
let channelNum = 1;
switch (channel) {
case 'boys':
channelNum = 1;
break;
case 'girls':
channelNum = 2;
break;
case 'kids':
case 'lifestyle':
channelNum = 3;
break;
default:
break;
}
return searchApi.getSearchRecommend(channelNum, params).then(result => {
return searchApi.getSearchRecommend(channelNum, params).then((result) => {
if (result.code === 200) {
let resData = {
code: 200,
hotTerms: []
};
resData.hotTerms = _.map(result.data.hotTerms, function(value) {
resData.hotTerms = _.map(result.data.hotTerms, (value) => {
return {
href: helpers.urlFormat('', {query: value.content}, 'search'),
content: value.content,
... ...
... ... @@ -67,6 +67,22 @@ exports.studentsNum = (data) => {
*/
exports.studentResource = (data) => {
let dest = {couponObj: {}};
let rightsTextObj = [{
rightName: '认证立赠100有货币',
rightContent: '认证成功,立即赠送100有货币。'
},{
rightName: '新品立享9折',
rightContent: '学生购买指定原价新品时,可立即享受9折优惠,此折扣与VIP折扣不可同时享受。'
},{
rightName: '每1元返1个有货币',
rightContent: '学生购买指定商品时,每1元返1个有货币(以商品的实际成交金额计算);<br>' +
'有货币返还时间:确认收货7日后,系统自动将对应数量的有货币返还至购买账户;<br>' +
'有货币有效期:获得当日至次年12月31日,逾期自动作废;<br>' +
'查看有货币:登录后,点击“个人中心”在“我的有货币”中可以查看有货币余额及明细。'
},{
rightName: '分期付款',
rightContent: '开通有货分期后,可享受部分商品30天延后付款,最长6个月的分期付款,开启任性购物模式。'
}];
_.forEach(data, (value) => {
switch (value.template_name) {
... ... @@ -77,6 +93,10 @@ exports.studentResource = (data) => {
Object.assign(dest.couponObj, {couponItem: getCoupon(value.data), floorId: value.template_id});
break;
case 'recommend_content_five':
Object.assign(value.data.list[0], rightsTextObj[0]);
Object.assign(value.data.list[1], rightsTextObj[1]);
Object.assign(value.data.list[2], rightsTextObj[2]);
Object.assign(value.data.list[3], rightsTextObj[3]);
Object.assign(dest, {rightsObj: {rightsItem: value.data.list || {}, floorId: value.template_id}});
break;
case 'image_list':
... ... @@ -99,6 +119,7 @@ exports.studentResource = (data) => {
break;
}
});
_.isEmpty(dest.couponObj) ? delete dest.couponObj : '';
return dest;
};
... ...
... ... @@ -85,7 +85,7 @@ router.post('/detail/notify/cancel', auth, notify.cancel); // 删é™
// 搜索
router.get('/search/index', gbk2utf, search.index);
router.get('/search/filter/brands', search.serachFilterBrands);
router.get('/search/filter/brands', search.searchFilterBrands);
router.get('/search/suggest', search.suggest); // 搜索提示
router.get('/api/suggest', search.suggest4Old);
router.get('/search/history', search.searchHistory); // 搜索历史提示
... ...
... ... @@ -67,16 +67,15 @@
</div>
{{/unless}}
{{/if}}
{{/if_cond}}
{{#if changedQuery}}
<div class="search-suggest-less">
没有找到&nbsp;"<em>{{name}}</em>"&nbsp;相关的商品,
为您推荐&nbsp;"<a href="/?query={{suggestFirst}}">{{suggestFirst}}</a>"&nbsp;的搜索结果。或者试试{{#suggestSecond}}&nbsp;"<a href="/?query={{.}}">{{.}}</a>"&nbsp;{{/suggestSecond}}
</div>
{{/if}}
{{#if changedQuery}}
<div class="search-suggest-less">
没有找到&nbsp;"<em>{{name}}</em>"&nbsp;相关的商品,
为您推荐&nbsp;"<a href="/?query={{suggestFirst}}">{{suggestFirst}}</a>"&nbsp;的搜索结果。{{#if suggestSecond}}或者试试{{#suggestSecond}}&nbsp;"<a href="/?query={{.}}">{{.}}</a>"&nbsp;{{/suggestSecond}}{{/if}}
</div>
{{/if}}
{{/if_cond}}
{{> list/top-coupon}}
... ...
... ... @@ -3,6 +3,10 @@
<div class="stu-rights-item">
<img class="" src="{{image2 src w=300 h=300}}">
</img>
<div class="item-content hide">
<p class="item-title">{{rightName}}</p>
<p class="item-detail">{{{rightContent}}}</p>
</div>
</div>
{{/rightsItem}}
</div>
... ...
... ... @@ -17,14 +17,14 @@ module.exports = {
cookieDomain: '.yohobuy.com',
domains: {
// test3
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
//singleApi: 'http://api-test3.yohops.com:9999/',
//api: 'http://api-test3.yohops.com:9999/',
//service: 'http://service-test3.yohops.com:9999/',
// prod
// singleApi: 'http://single.yoho.cn/',
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
singleApi: 'http://single.yoho.cn/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
// gray
// singleApi: 'http://single.gray.yohops.com/',
... ...
... ... @@ -106,7 +106,7 @@
\{{#hotTerms}}
<li>
<a style="display: block;" href="\{{href}}" title="\{{content}}"
act="\{{href}}">
act="\{{href}}" target="_blank">
<span class="searchvalue">\{{content}}</span>
</a>
</li>
... ... @@ -114,7 +114,7 @@
\{{#guessTerms}}
<li>
<a style="display: block;" href="\{{href}}" title="\{{content}}"
act="\{{href}}">
act="\{{href}}" target="_blank">
<span class="searchvalue">\{{content}}</span>
</a>
</li>
... ...
{
"name": "yohobuy-node",
"version": "5.4.18",
"version": "5.4.19",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -328,6 +328,7 @@ function submitSearch() {
if (searchKey === '') {
$('#query-key').val(defaultSearch);
}
$searchKey.val(searchKey);
$searchForm.submit();
}
... ... @@ -713,6 +714,8 @@ if ($miniCart && $miniCart.length) {
$goCart.hover(function() {
var data, _html = '';
$searchHistory.hide();
if ($goCart.hasClass('on-hover')) {
return;
}
... ... @@ -735,6 +738,8 @@ if ($miniCart && $miniCart.length) {
data = $dom.data(),
callback;
$searchHistory.hide();
if (data) {
callback = function() {
$dom.closest('.goods-item').remove();
... ... @@ -923,9 +928,14 @@ function actionAddKeyWords() {
function searchSuggestHistory() {
var param = {
return_type: 'jsonp',
query: encodeURIComponent($searchKey.val()) || ''
query: encodeURIComponent(window.queryString().query.replace(/\+/ig, ' '))
};
if ($searchKey.attr('alt')) {
param.query = '';
$searchKey.attr('alt', false);
}
$.getJSON('//search.yohobuy.com/product/search/history?callback=?', param, function(jsonData) {
if ($searchKey.val() === '') {
... ... @@ -945,6 +955,7 @@ function searchSuggestHistory() {
$('.search-suggest-title .searchDel').click(function() {
window.setCookie('_History', '', {domain: '.yohobuy.com'});
$(this).closest('.search-suggest-history').hide();
$searchKey.attr('alt', true);
return false;
});
... ... @@ -952,7 +963,6 @@ function searchSuggestHistory() {
});
}
/**
* 搜索 历史记录 dom
* @return {[type]} [description]
... ... @@ -970,7 +980,7 @@ $searchKey.focus(function() {
});
/**
* 搜索 热门搜索和默认搜索 api
* 搜索 热门搜索 api
* @return {[type]} [description]
*/
function searchSuggestRecommend(channel, key) {
... ... @@ -995,6 +1005,7 @@ function searchSuggestRecommend(channel, key) {
}
});
}
/**
... ... @@ -1003,8 +1014,12 @@ function searchSuggestRecommend(channel, key) {
*/
$(function() {
searchSuggestRecommend();
if (location.href.indexOf('www.yohobuy.com') < 0) {
searchSuggestHistory();
}
});
actionCover();
actionAddKeyWords();
setTimeout(emailUserCertTip, 0);
... ...
... ... @@ -17,7 +17,9 @@ var $sortItem = $('.sort-item'),
$stuYear = $('#stu-entrance-year-show'),
$stuYearWrap = $stuYear.parent(),
$identityForm = $('#identity-form'),
$identityWrap = $('#identity-wrap');
$identityWrap = $('#identity-wrap'),
$rightsItem = $('#stuRights .stu-rights-item'),
rightsText = '';
var $rightDia = $('#rights-dia'),
$couponDia = $('#coupon-dia');
... ... @@ -444,21 +446,17 @@ $couponDia.on('click', function() {
createStuDialog('stu-agree-dialog', cont);
});
$rightsItem.each(function(index,ele) {
var title = $(ele).find('.item-title').html(),
detail = $(ele).find('.item-detail').html(),
i = Number(index) + 1;
rightsText += '<p>权益' + i + ':' + title + '</p><p>' + detail + '</p>';
i !== $rightsItem.length ? rightsText+='<br>' : '';
});
$rightDia.on('click', function() {
var cont = '<h3 class="dia-title">特权详细说明</h3>' +
'<p>权益1:新品立享9折</p>' +
'<p>学生购买指定原价新品时,可立即享受9折优惠,与VIP折扣不可同时享受。</p><br>' +
'<p>权益2:每1元返1个有货币</p>' +
'<p>学生购买指定商品时,以商品的实际成交金额计算,每1元返1个有货币;</p>' +
'<p>返有货币时间:确认收货7日后,系统将自动将对应数量的有货币返至购买账户;</p>' +
'<p>有货币有效期:获得当日至次年12月31日,逾期自动作废;</p>' +
'<p>查看有货币:登录后,点击“个人中心”在“我的有货币”中可以查看有货币余额及明细。</p><br>' +
'<p>权益3:免单抽奖</p>' +
'<p>每月将在累计购物金额最高的学校中,抽取3名幸运学生用户,获得免单资格;</p>' +
'<p>免单用户名单将在每月第1个工作日公布在有货微信公众号上,可关注【有货YOHOBUY】;</p>' +
'<p>免单用户将在中奖次日获得与实付金额等额的现金券,使用时间:中奖当月。</p><br>' +
'<p>权益4:学生专享活动</p>' +
'<p>每月不定期的开展学生专享活动,可打开有货APP推送,及时查收学生专享活动通知。</p>';
var cont = '<h3 class="dia-title">特权详细说明</h3>' + rightsText;
createStuDialog('stu-rights-dialog', cont);
... ... @@ -660,28 +658,6 @@ $(function() {
}, 100);
var rightsFirst = '<div class="item-content hide">' +
'<p class="item-title">新品立享9折</p>' +
'<p>学生购买指定原价新品时,可立即享受9折优惠,与VIP折扣不可同时享受。</p></div>';
var rightsSecond = '<div class="item-content hide">' +
'<p class="item-title">每1元返1个有货币</p>' +
'<p>学生购买指定商品时,以商品的实际成交金额计算,每1元返1个有货币;</p>' +
'<p>返有货币时间:确认收货7日后,系统将自动将对应数量的有货币返至购买账户;</p>' +
'<p>有货币有效期:获得当日至次年12月31日,逾期自动作废;</p>' +
'<p>查看有货币:登录后,点击“个人中心”在“我的有货币”中可以查看有货币余额及明细。</p></div>';
var rightsThird = '<div class="item-content hide">' +
'<p class="item-title">免单抽奖</p>' +
'<p>每月将在累计购物金额最高的学校中,抽取3名幸运学生用户,获得免单资格;</p>' +
'<p>免单用户名单将在每月第1个工作日公布在有货微信公众号上,可关注【有货YOHOBUY】;</p>' +
'<p>免单用户将在中奖次日获得与实付金额等额的现金券,使用时间:中奖当月。</p></div>';
var rightsFourth = '<div class="item-content hide">' +
'<p class="item-title">学生专享活动</p>' +
'<p>每月不定期的开展学生专享活动,可打开有货APP推送,及时查收学生专享活动通知。</p></div>';
$('.coupon > a').each(function() {
couponIds.push($(this).attr('data-id'));
});
... ... @@ -815,14 +791,9 @@ $(function() {
});
// 学生权益,悬浮显示内容
$('#stuRights .stu-rights-item:eq(0)').append(rightsFirst);
$('#stuRights .stu-rights-item:eq(1)').append(rightsSecond);
$('#stuRights .stu-rights-item:eq(2)').append(rightsThird);
$('#stuRights .stu-rights-item:eq(3)').append(rightsFourth);
// 悬浮效果
$('#stuRights .stu-rights-item:eq(0), #stuRights .stu-rights-item:eq(1),' +
'#stuRights .stu-rights-item:eq(2), #stuRights .stu-rights-item:eq(3)').hover(function() {
$rightsItem.hover(function() {
var content = $(this).find('.item-content');
var gapHeight;
... ...
... ... @@ -16,11 +16,12 @@
}
.coupons-info {
width: 390px;
width: 388px;
.coupons-text {
color: #000;
padding: 0 25px;
text-align: left;
}
}
... ... @@ -106,6 +107,7 @@
.coupons-dtl {
width: 100px;
height: 45px;
margin-left: 5px;
line-height: 23px;
text-align: left;
... ... @@ -119,6 +121,7 @@
height: 30px;
display: inline-block;
line-height: 30px;
float: left;
}
.use-btn {
... ...
... ... @@ -469,6 +469,7 @@
.stu-good-detail {
position: relative;
overflow: visible;
height: auto;
}
.good-detail-text > .price .stu-tag {
... ...