Authored by 陈峰

Merge branch 'master' into feature/11.11

... ... @@ -27,10 +27,12 @@ const editor = (req, res, next) => {
id = req.query.id || 0,
title = '编辑简介',
parameter = {},
isApp = req.query.app_version || req.query.appVersion || false,
isApp = req.yoho.isApp,
gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
if (isApp === false) {
if (isApp) {
uid = req.query.uid;
} else {
parameter = {
pageHeader: headerModel.setNav({
navTitle: title
... ... @@ -45,6 +47,11 @@ const editor = (req, res, next) => {
if (articleListData.data && articleListData.data.list && articleListData.data.list.artList) {
articleListData.data.list.artList.forEach(articleData => {
articleData.colparam = {
urlpath: req.path,
param: `?id=${id}`
}
build.push(guangProcess.formatArticle(articleData, true, isApp, false, uid));
});
... ... @@ -81,7 +88,11 @@ const editor = (req, res, next) => {
const pageData = (req, res, next) => {
/* 判断是不是AJAX请求 */
if (!req.xhr) {
res.json({ code: 400, message: '非法请求', data: '' });
res.json({
code: 400,
message: '非法请求',
data: ''
});
return;
}
... ... @@ -95,15 +106,23 @@ const pageData = (req, res, next) => {
isTab = req.query.isTab || false,
showAuthor = false;
let uid = req.user.uid,
let uid = req.user.uid || req.query.uid,
udid = req.sessionID;
if (!stringProcess.isNumeric(sortId)) {
res.json({ code: 400, message: '参数错误', data: '' });
res.json({
code: 400,
message: '参数错误',
data: ''
});
return;
}
if (!page && !isNaN(page)) {
res.json({ code: 400, message: '参数错误', data: '' });
res.json({
code: 400,
message: '参数错误',
data: ''
});
return;
}
if (!authorId && isNaN(authorId)) {
... ... @@ -111,9 +130,15 @@ const pageData = (req, res, next) => {
}
return indexModel.getPageData(gender, sortId, uid, udid, page, tag, authorId, isApp, showAuthor, isTab).then(data => {
if (data) {
res.render('index/page', Object.assign(data, { layout: false }));
res.render('index/page', Object.assign(data, {
layout: false
}));
} else {
res.json({ code: 400, message: '', data: '' });
res.json({
code: 400,
message: '',
data: ''
});
}
}).catch(next);
... ... @@ -139,7 +164,7 @@ const index = (req, res, next) => {
};
let param = {
uid: req.user.uid,
uid: req.user.uid || req.query.uid,
udid: req.user.udid,
... ... @@ -182,13 +207,12 @@ const tag = (req, res, next) => {
tag: req.query.query,
isApp: req.query.app_version || req.query.appVersion || false,
gender: req.query.gender || '1,3',
uid: req.user.uid || 0,
uid: req.user.uid || req.query.uid || 0,
udid: req.sessionID,
type: req.query.type || 0
type: req.query.type || 0,
path: req.path
};
responseData.pageHeader.navTitle = param.tag || '标签';
... ... @@ -213,7 +237,7 @@ const listDynamicData = (req, res) => {
type = req.query.type;
if (req.user.uid) {
other.uid = req.user.uid;
other.uid = req.user.uid || req.query.uid;
}
if (query) {
... ... @@ -237,7 +261,7 @@ const listDynamicData = (req, res) => {
const detailDynamicData = (req, res) => {
let id = req.query.id,
uid = req.user.uid,
uid = req.user.uid || req.query.uid,
udid = req.sessionID;
indexModel.getDynamicDataById(id, uid, udid).then((ret) => {
... ... @@ -254,4 +278,4 @@ module.exports = {
tag,
listDynamicData,
detailDynamicData
};
};
\ No newline at end of file
... ...
... ... @@ -51,8 +51,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
src: helpers.image(imgs[0].src, 315, 420)
}, {
src: helpers.image(imgs[1].src, 315, 420)
}
];
}];
contents.push(build);
joinContentFunc(++i, len);
... ... @@ -80,7 +79,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
for (let o = 0; o < product.data.product_list.length; o++) {
let goods = product.data.product_list[o];
// 最多显示4个
// 最多显示4个
if (o > 3) {
break;
}
... ... @@ -94,7 +93,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
});
}
// 多个商品
// 多个商品
if (product.data.product_list.length && (product.data.product_list.length > 1)) {
build.relatedReco = reco;
} else if (product.data.product_list.length === 1) { // 单个商品
... ... @@ -249,13 +248,17 @@ const index = (req, res, next) => {
parameter = {},
title = '逛';
// pagecache 前端做
// userAgent = req.get('User-Agent'),
// isWeixin = userAgent.includes('MicroMessenger'); // 标识是否是微信访问
// pagecache 前端做
// userAgent = req.get('User-Agent'),
// isWeixin = userAgent.includes('MicroMessenger'); // 标识是否是微信访问
// 判断参数是否有效, 无效会跳转到错误页面
if (!stringProcess.isNumeric(id)) {
res.json({ code: 400, message: '非法请求', data: '' });
res.json({
code: 400,
message: '非法请求',
data: ''
});
return;
}
parameter = {
... ... @@ -297,7 +300,6 @@ const index = (req, res, next) => {
// guang双头部的问题 20160601
// 正确的URL
data.guang.author.url = helpers.https(`${detail.getAuthor.url}&openby:yohobuy={"action":"go.h5","params":{"param":{},"share":"","id":${detail.getAuthor.author_id},"type":0,"islogin":"N","url":"${detail.getAuthor.url}"}}`);
// 错误的URL
// data.guang.author.url = helpers.https(`${detail.getAuthor.url}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${detail.getAuthor.author_id}"},"share":"","id":${detail.getAuthor.author_id},"type":0,"islogin":"N","url":"${helpers.urlFormat('/author/index', {}, 'guang')}"}}`);
}
... ... @@ -340,7 +342,6 @@ const index = (req, res, next) => {
data.description = detail.getArticle.article_summary;
data.description_more = true;
}
// 标识有微信分享
data.hasWxShare = true;
res.render('info/index', Object.assign({
... ... @@ -369,7 +370,11 @@ const mini = (req, res, next) => {
// 判断参数是否有效, 无效会跳转到错误页面
if (!stringProcess.isNumeric(id)) {
res.json({ code: 400, message: '非法请求', data: '' });
res.json({
code: 400,
message: '非法请求',
data: ''
});
return;
}
... ... @@ -440,7 +445,11 @@ const foryoho = (req, res, next) => {
// 判断参数是否有效, 无效会跳转到错误页面
if (!stringProcess.isNumeric(id)) {
res.json({ code: 400, message: '非法请求', data: '' });
res.json({
code: 400,
message: '非法请求',
data: ''
});
return;
}
... ... @@ -492,4 +501,4 @@ module.exports = {
index,
mini,
foryoho
};
};
\ No newline at end of file
... ...
... ... @@ -59,7 +59,7 @@ const collectArticle = (req, res, next) => {
/* 判断用户是否登录 */
let id = req.body.id,
opt = req.body.opt || 'ok',
uid = req.user.uid;
uid = req.body.uid;
if (!stringProcess.isNumeric(id) || !stringProcess.isNumeric(uid)) {
res.json(result);
... ...
... ... @@ -166,7 +166,9 @@ const getArticle = (param) => {
let page = param.page ? param.page : 1;
Object.assign(param, { page: page });
Object.assign(param, {
page: page
});
return api.all([
_category(),
... ... @@ -182,7 +184,7 @@ const getArticle = (param) => {
};
// 顶部的分类列表
let curIndex = 0;// 当前tab顺序
let curIndex = 0; // 当前tab顺序
let indexTmp = 0;
... ... @@ -265,7 +267,9 @@ const getTagEditor = (param) => {
let page = param.page ? param.page : 1;
Object.assign(param, { page: page });
Object.assign(param, {
page: page
});
return api.all([
_article(param)
... ... @@ -285,10 +289,15 @@ const getTagEditor = (param) => {
let inf = [];
let infoList = result[0].data.list.artList;
infoList.forEach(val => {
val.url = helpers.https(`${val.url}&openby:yohobuy={"action":"go.h5","params":{"param":{},"share":"","id":"","type":0,"islogin":"N","url":"${val.url}"}}`);
inf.push(guangProcess.formatArticle(val, true, false, true));
val.colparam = {
urlpath: param.path,
param: ''
};
if (param.tag) {
val.colparam.param = `?query=${param.tag}`;
}
inf.push(guangProcess.formatArticle(val, true, param.isApp, true));
});
resu.guang.infos = inf;
... ... @@ -333,7 +342,9 @@ const getDynamicDataByIds = (ids, udid, other) => {
});
}
return serviceAPI.get('guang/api/v6/article/getSimpleArticleList', params, {cache: true});
return serviceAPI.get('guang/api/v6/article/getSimpleArticleList', params, {
cache: true
});
};
/**
... ... @@ -343,7 +354,7 @@ const getDynamicDataByIds = (ids, udid, other) => {
*/
const getDynamicDataById = (id, uid, udid) => {
return serviceAPI.get('/gateway/guang/api/v6/article/getArticlePraiseAndFavor', {
return serviceAPI.get('guang/api/v6/article/getArticlePraiseAndFavor', {
id: id,
uid: uid,
udid: udid
... ...
... ... @@ -40,11 +40,11 @@ const packageData = (id, isApp) => {
cache: true
}).then(data => {
// 接口要判断一下返回状态是否成功
if (data === '' && data.code !== 200) {
if (!data || data.code !== 200) {
result.code = 400;
return result;
}
let article = data.data;
let article = data.data || {};
result.getArticle = article;
... ... @@ -136,7 +136,9 @@ const packageData = (id, isApp) => {
}
}
getArticleContent.splice(preCount, 0, {weixinPublic: datas[4].data});
getArticleContent.splice(preCount, 0, {
weixinPublic: datas[4].data
});
}
if (datas[0]) {
result.getAuthor = datas[0].data;
... ... @@ -177,4 +179,4 @@ const intro = (id) => {
module.exports = {
packageData,
intro
};
};
\ No newline at end of file
... ...
... ... @@ -252,9 +252,6 @@ const getRelatedEditorial = (brandId, uid, udid, clientType, isApp) => {
pageView: data.views_num
});
});
return list;
} else {
logger.error('editorial data return code is not 200');
... ... @@ -264,13 +261,19 @@ const getRelatedEditorial = (brandId, uid, udid, clientType, isApp) => {
};
// 是否收藏
const isCollection = (uid, brandId, clientType) => {
return serviceAPI.get('shops/service/v1/favorite/getUidBrandFav', {
uid: uid,
const isCollection = (brandId, clientType, uid) => {
let param = {
brandId: brandId,
client_type: clientType,
private_key: privateKeyList[clientType]
}).then((result) => {
};
if (uid) {
param.uid = uid;
}
return serviceAPI.get('shops/service/v1/favorite/getUidBrandFav', param).then((result) => {
if (result && result.code === 200) {
... ... @@ -313,7 +316,7 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
jumpToApp = 1;
}
return Promise.all([isCollection(uid, brandId, clientType), getRelatedEditorial(brandId, uid, udid, clientType, isApp), getNewProduct(brandId, gender, url, isApp)]).then((result) => {
return Promise.all([isCollection(brandId, clientType, uid), getRelatedEditorial(brandId, uid, udid, clientType, isApp), getNewProduct(brandId, gender, url, isApp)]).then((result) => {
list = _.assign(list, {
isLike: result[0],
... ... @@ -341,7 +344,7 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
* [品牌详情异步数据]
*/
const getDetailDataAsync = (brandId, uid, udid, clientType, isApp) => {
return Promise.all([isCollection(uid, brandId, clientType), getRelatedEditorial(brandId, uid, udid, clientType, isApp)]).then((result) => {
return Promise.all([isCollection(brandId, clientType, uid), getRelatedEditorial(brandId, uid, udid, clientType, isApp)]).then((result) => {
return {
isLike: result[0],
infos: result[1]
... ...
... ... @@ -80,14 +80,18 @@ const _formatOrderGoods = (orderGoods, count, haveLink, tickets) => {
* 获取快递有关信息
* @private
*/
const _assignExpressInfo = (showLogistics, order, result) => {
if (showLogistics && order.express_company.caption && order.express_number) {
Object.assign(result, {
const _assignExpressInfo = (showLogistics, order) => {
let data = {};
if (showLogistics && order.express_company && order.express_company.caption) {
data = {
logisticsUrl: helpers.urlFormat('/home/logistic', {order_code: order.order_code}),
logisticsCompany: order.express_company.caption,
logisticsNum: order.express_number
});
logisticsNum: order.express_number || ''
};
}
return data;
};
/**
... ... @@ -164,7 +168,7 @@ const _getOrderStatus = (order, showLogistics) => {
qrcode: helpers.urlFormat(`/home/QRcode/${order.order_code}`)
});
} else {
_assignExpressInfo(showLogistics, order, result);
Object.assign(result, _assignExpressInfo(showLogistics, order));
}
break;
case 6:
... ... @@ -180,7 +184,7 @@ const _getOrderStatus = (order, showLogistics) => {
qrcode: helpers.urlFormat(`/home/QRcode/${order.order_code}`)
});
} else {
_assignExpressInfo(showLogistics, order, result);
Object.assign(result, _assignExpressInfo(showLogistics, order));
}
break;
default:
... ... @@ -213,7 +217,7 @@ const _getOrderStatus = (order, showLogistics) => {
Object.assign(result, {
unreceived: true
});
_assignExpressInfo(showLogistics, order, result);
Object.assign(result, _assignExpressInfo(showLogistics, order));
break;
case 6:
... ... @@ -221,7 +225,7 @@ const _getOrderStatus = (order, showLogistics) => {
Object.assign(result, {
completed: true
});
_assignExpressInfo(showLogistics, order, result);
Object.assign(result, _assignExpressInfo(showLogistics, order));
break;
default:
break;
... ...
... ... @@ -29,7 +29,7 @@ const closeReasons = () => {
const _assignExpressInfo = (showLogistics, order) => {
let data = {};
if (showLogistics && order.expressCompany.caption) {
if (showLogistics && order.expressCompany && order.expressCompany.caption) {
data = {
logisticsUrl: helpers.urlFormat('/home/logistic', {order_code: order.orderCode}),
logisticsCompany: order.expressCompany.caption,
... ...
... ... @@ -180,6 +180,9 @@ const _shopCouponsList = (shopId, uid) => {
* @private
*/
const getBrandFavStatus = (params) => {
if (params.uid === 'undefined') {
params.uid = 0;
}
return api.get('', {
method: 'app.favorite.isFavorite',
uid: params.uid || 0,
... ...
... ... @@ -4,7 +4,7 @@
</a>
<div class="descripition">
{{shop_intro}}
{{{shop_intro}}}
</div>
<p class="sign-icon">
... ...
... ... @@ -146,39 +146,42 @@ function initInfosEvt($container) {
// APP收藏
$btn = $this.closest('.collect-btn');
if ($btn.length > 0) {
e.preventDefault();
if ($btn.hasClass('collected')) {
opt = 'cancel';
}
$info = $this.closest('.guang-info');
var uid = getUrlParam('uid');
if (uid) {
e.preventDefault();
if ($btn.hasClass('collected')) {
opt = 'cancel';
}
if (getUrlParam('yh_channel')) {
yhChannel = getUrlParam('yh_channel');
}
$info = $this.closest('.guang-info');
$.ajax({
type: 'POST',
url: '/guang/opt/collectArticle',
data: {
id: $info.data('id'),
opt: opt,
yh_channel: yhChannel,
uid: getUrlParam('uid')
},
success: function(data) {
if (data.code && data.code === 200) {
if (getUrlParam('yh_channel')) {
yhChannel = getUrlParam('yh_channel');
}
// 切换收藏状态
$btn.toggleClass('collected');
} else {
tip.show(data.message);
$.ajax({
type: 'POST',
url: '/guang/opt/collectArticle',
data: {
id: $info.data('id'),
opt: opt,
yh_channel: yhChannel,
uid: uid
},
success: function(data) {
if (data.code && data.code === 200) {
// 切换收藏状态
$btn.toggleClass('collected');
} else {
tip.show(data.message);
}
},
error: function() {
tip.show('网络断开连接了~');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
});
}
}
});
... ... @@ -251,9 +254,9 @@ function loadMore($container, opt, url) {
if (opt.page === 1) {
loading.hideLoadingMask();
$loading.removeClass('hide');// 显示空屏加载时hide的隐藏
$loading.removeClass('hide'); // 显示空屏加载时hide的隐藏
window.rePosFooter();// 插入内容后重新计算底部位置
window.rePosFooter(); // 插入内容后重新计算底部位置
}
opt.page++;
... ... @@ -275,4 +278,4 @@ exports.mySwiper = mySwiper;
exports.initSwiper = initSwiper;
exports.initInfosEvt = initInfosEvt;
exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis;
exports.loadMore = loadMore;
exports.loadMore = loadMore;
\ No newline at end of file
... ...
... ... @@ -12,6 +12,7 @@ var scrollFn,
scrollTop,
RECPOSE,
isApp,
searching = false,
speckParamApp = {
udid: '',
apt: '',
... ... @@ -165,6 +166,7 @@ plusstar = {
this.common.codeDefault = code;// 记住最后一次的tab code
this.common.page = 1;// 商品列表从第一页开始
searching = false;
$.ajax({
type: 'GET',
... ... @@ -223,6 +225,12 @@ plusstar = {
var that = this,
skn = [];
if (searching) {
return true;
}
searching = true;
if (that.common.page > that.common.pageTotal) {
return false;
}
... ... @@ -243,6 +251,7 @@ plusstar = {
dataType: 'html',
success: function(data) {
skn = [];
searching = false;
loading.hideLoadingMask();
if (data === '') {
... ... @@ -272,6 +281,7 @@ plusstar = {
$('.resources .goods .page-total').remove();
},
error: function() {
searching = false;
tip.show('网络断开连接了~');
loading.hideLoadingMask();
}
... ...
... ... @@ -54,7 +54,7 @@ ListData.prototype.getListData = function(page) {
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: 'http:' + '//m.yohobuy.com' + self.opt.url,
url: location.protocol + '//m.yohobuy.com' + self.opt.url,
data: {
page: this.opt.page
},
... ...
... ... @@ -427,10 +427,11 @@ seckillObj = {
};
$(function() {
seckillObj.init();
});
window.seckillRefresh = function() {
// location.reload();
};
$(function() {
seckillObj.init();
});
... ...
... ... @@ -60,9 +60,12 @@
.selected {
display: none;
color: #d0021b !important;
font-weight: bold;
height: 79px;
line-height: 40px;
.time {
font-weight: bold;
}
}
.normal {
display: block;
... ...
... ... @@ -5,7 +5,7 @@
font-size: 24px;
line-height: 1.4;
color: #b0b0b0;
padding: 40px 30px 185px;
padding: 30px 30px 185px;
h5 {
font-size: 25px;
... ...
... ... @@ -80,11 +80,15 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr
if (isApp) {
result.collect = {};
result.collect.isCollected = articleData.isFavor === true;
let originUrl = helpers.urlFormat('/author/index', null, 'guang'); // 跳转回的链接
let colparam = articleData.colparam || {
urlpath: '',
param: ''
}
let originUrl = helpers.urlFormat(colparam.urlpath || '/author/index', null, 'guang'); // 跳转回的链接
let collectUrl = 'javascript:;'; // 根据用户是否登录做处理的链接
if (!uid) {
let playUrlEncode = originUrl.replace(/\//g, '\\/');
let playUrlEncode = `${originUrl}${colparam.param}`.replace(/\//g, '\\\/');
collectUrl = `${originUrl}?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"${playUrlEncode}","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}`;
}
... ... @@ -110,7 +114,7 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr
// 编辑人员 app跳转url处理 20160601
let isLogin = uid ? true : false;
articleData.author.url = `${helpers.https(articleData.author.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${articleData.author.author_id}"},"share":"","id":${articleData.author.author_id},"type":0,"islogin":"${isLogin}","url":"https:${helpers.urlFormat('/author/index', {uid: uid}, 'guang')}"}}&uid=${uid}`;
articleData.author.url = `${helpers.https(articleData.author.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{},"share":"","id":${articleData.author.author_id},"type":0,"islogin":"${isLogin}","url":"${articleData.author.url}"}}`;
result.author = articleData.author;
if (result.author.avatar) {
result.author.avatar = result.author.avatar.replace('http://', '//');
... ... @@ -270,7 +274,7 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height,
// TODO student price
result.studentPrice = parseInt(productData.sales_price * 100 * 0.9) / 100;
result.is_soon_sold_out = (productData.is_soon_sold_out === 'Y');
let url = helpers.urlFormat(`/product/pro_${productData.product_id}_${productData.goods_list[0].goods_id}/${productData.cn_alphabet}.html`);
let url = encodeURI(helpers.urlFormat(`/product/pro_${productData.product_id}_${productData.goods_list[0].goods_id}/${productData.cn_alphabet}.html`));
result.url = url.replace('http://', '//');
... ... @@ -282,8 +286,8 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height,
if (showTags) {
result.tags = {
is_new: showNew && productData.is_new === 'Y', // 新品
is_discount: showSale && productData.is_discount === 'Y', // 在售
is_limited: productData.is_limited && productData.is_limited === 'Y', // 限量
is_discount: showSale && productData.is_discount === 'Y', // 在售
is_limited: productData.is_limited && productData.is_limited === 'Y', // 限量
is_yohood: productData.is_yohood && productData.is_yohood === 'Y', // YOHOOD
midYear: productData.midear && productData.midear === 'Y', // 年中
yearEnd: productData.yearnd && productData.yearnd === 'Y', // 年末
... ... @@ -294,7 +298,7 @@ const formatProduct = (productData, showTags, showNew, showSale, width, height,
if (result.is_soon_sold_out && result.tags.is_discount) {
result.tags.is_new = false;
} else if (result.tags.is_discount &&
(result.tags.is_new || result.tags.is_limited || result.tags.is_yohood || result.tags.is_advance)// 打折与其它组合则隐藏打折
(result.tags.is_new || result.tags.is_limited || result.tags.is_yohood || result.tags.is_advance) // 打折与其它组合则隐藏打折
) {
result.tags.is_discount = false;
} else if (result.tags.is_yohood && result.tags.is_new) { // YOHOOD和新品组合显示YOHOOD
... ... @@ -312,4 +316,4 @@ module.exports = {
getFilterUrl,
formatProduct,
getProductIcon
};
};
\ No newline at end of file
... ...