Authored by 徐祁xuqi

Merge branch 'qCloud' of http://git.yoho.cn/fe/yohobuywap-node into qCloud

Conflicts:
	package.json
... ... @@ -81,6 +81,8 @@ const getDetailData = (req, res, next) => {
let isApp = req.query.app_version || req.query.appVersion || false;
let clientType = req.body.client_type || '';
let version = req.body.app_version || '';
let userAgent = req.get('User-Agent');
let isWeixin = userAgent.includes('MicroMessenger'); // 标识是否是微信访问
if (clientType.toLowerCase() === 'ios' && version) {
clientType = 'iphone';
... ... @@ -90,18 +92,26 @@ const getDetailData = (req, res, next) => {
clientType = 'h5';
}
plustarModel.getDetailData(id, uid, udid, gender, isApp, clientType).then((result) => {
result.brand_intro = htmlProcess.removeHtml(result.brand_intro);
result.clientType = clientType;
result.brandId = result.brand_id;
res.render('plustar/detail', {
module: 'guang',
page: 'plustar-detail',
title: result.brand_name,
pageHeader: headerModel.setNav({
navTitle: result.brand_name
}),
ps: result
});
result.brandIntro = htmlProcess.removeHtml(result.brandIntro);
if (!isApp & !isWeixin) {
res.render('plustar/detail', {
module: 'guang',
page: 'plustar-detail',
title: result.brandName,
pageHeader: headerModel.setNav({
navTitle: result.brandName
}),
ps: result
});
} else {
res.render('plustar/detail', {
module: 'guang',
page: 'plustar-detail',
title: result.brandName,
ps: result
});
}
}).catch(next);
};
... ...
... ... @@ -114,10 +114,13 @@ const packageData = (id, isApp) => {
}
return Promise.all(promises).then(datas => {
let getArticleContent = {};
if (datas) {
if (datas[1]) {
let getArticleContent = datas[1].data;
getArticleContent = datas[1].data;
result.getArticleContent = getArticleContent;
... ...
... ... @@ -4,6 +4,15 @@ const serviceAPI = global.yoho.ServiceAPI;
const _ = require('lodash');
const logger = global.yoho.logger;
const helpers = global.yoho.helpers;
const htmlProcess = require(`${global.utils}/html-process`);
const privateKeyList = {
android: 'fd4ad5fcfa0de589ef238c0e7331b585',
iphone: 'a85bb0674e08986c6b115d5e3a4884fa',
ipad: 'ad9fcda2e679cf9229e37feae2cdcf80',
web: '0ed29744ed318fd28d2c07985d3ba633',
h5: 'fd4ad5fcfa0de589ef238c0e7331b585'
};
const formaData = (data, gender) => {
let build = [];
... ... @@ -60,7 +69,7 @@ const getContentData = (gender, type, channel, isRecommend) => {
if (result && result.code === 200) {
return formaData(result.data.data.list[0].data, gender);
} else {
logger.error('列表 list data return code is not 200');
logger.error('list data return code is not 200');
return {};
}
});
... ... @@ -85,7 +94,7 @@ const getBrandsData = (gender, starBrand, originalBrand, channel, isRecommend) =
};
// 新品到着
const getNewProduct = (brandId, gender, url) => {
const getNewProduct = (brandId, gender, url, isApp) => {
return api.get('', {
method: 'app.search.li',
... ... @@ -143,6 +152,14 @@ const getNewProduct = (brandId, gender, url) => {
newArrival.moreUrl = url;
let productUrl = '//m.yohobuy.com/product/pro_' + list.product_id + '_' +
list.goods_list[0].goods_id + '/' + list.cn_alphabet + '.html';
if (isApp) {
console.log(productUrl);
productUrl += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${list.product_skn}"}}`;
}
obj = _.assign(obj, {
id: list.product_skn,
product_id: list.product_id,
... ... @@ -152,8 +169,7 @@ const getNewProduct = (brandId, gender, url) => {
studentPrice: list.sales_price * 0.9,
is_soon_sold_out: list.is_soon_sold_out === 'Y',
isShowSaleTagDis: list.sales_price * 2 < list.market_price,
url: '/product/pro_' + list.product_id + '_' +
list.goods_list[0].goods_id + '/' + list.cn_alphabet + '.html',
url: productUrl,
tags: tag
});
... ... @@ -167,6 +183,8 @@ const getNewProduct = (brandId, gender, url) => {
}
});
}
return newArrival;
... ... @@ -178,14 +196,15 @@ const getNewProduct = (brandId, gender, url) => {
};
// 相关资讯
const getRelatedEditorial = (brandId, uid, udid, clientType) => {
const getRelatedEditorial = (brandId, uid, udid, clientType, isApp) => {
return serviceAPI.get('guang/service/v1/article/getArticleByBrand', {
brand_id: brandId,
uid: uid,
udid: udid,
client_type: clientType,
limit: 3
limit: 3,
private_key: privateKeyList[clientType]
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -193,9 +212,13 @@ const getRelatedEditorial = (brandId, uid, udid, clientType) => {
let list = [];
_.forEach(result.data, function(data) {
if (isApp) {
data.url = data.url + '';
}
list.push({
id: data.id,
url: data.url,
url: isApp ? `${helpers.https(data.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${data.id}"},"shareparam":{"id":"${data.id}"},"share":"/guang/api/v1/share/guang","id":${data.id},"type":1,"url":"http:${helpers.urlFormat('/info/index', null, 'guang')}","islogin":"N"}}` : data.url,
title: data.title,
text: data.intro,
img: helpers.image(data.src, 640, 640),
... ... @@ -205,6 +228,8 @@ const getRelatedEditorial = (brandId, uid, udid, clientType) => {
});
});
return list;
} else {
logger.error('editorial data return code is not 200');
... ... @@ -218,7 +243,8 @@ const isCollection = (uid, brandId, clientType) => {
return serviceAPI.get('shops/service/v1/favorite/getUidBrandFav', {
uid: uid,
brandId: brandId,
client_type: clientType
client_type: clientType,
private_key: privateKeyList[clientType]
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -243,6 +269,7 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
}).then((result) => {
if (result && result.code === 200) {
let list = result.data || [];
let jumpToApp;
let url;
... ... @@ -256,12 +283,34 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
url = '//' + brandDomain + '.m.yohobuy.com';
}
// return Promise.all([isCollection(uid, brandId, clientType), getRelatedEditorial(brandId, uid, udid, clientType), getNewProduct(brandId, gender, url)]).then((result) => { //pagecache重构
return getNewProduct(brandId, gender, url).then((result) => {
if (isApp & !uid) {
jumpToApp = 1;
}
let likeUrl = helpers.urlFormat('/plustar/brandinfo', {
id: brandId
}, 'guang');
if (isApp) {
let $url = likeUrl;
$url += '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
+ brandId + '}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"' + brandId + '"}},"priority":"Y"}}';
} else {
let $url = helpers.urlFormat('/signin.html', {refer: likeUrl});
}
return Promise.all([isCollection(uid, brandId, clientType), getRelatedEditorial(brandId, uid, udid, clientType, isApp), getNewProduct(brandId, gender, url, isApp)]).then((result) => {
list = _.assign(list, {
// isLike: result[0], //pagecache重构
// infos: result[1], //pagecache重构
newArrival: result
isLike: result[0],
infos: result[1],
newArrival: result[2],
jumpToApp: jumpToApp,
shareLink: '//guang.m.yohobuy.com/plustar/brandinfo?id=' + id,
shareTitle: list.brandName,
shareImg: list.brandIco,
shareDesc: htmlProcess.removeHtml(list.brandIntro)
});
return list;
... ...
... ... @@ -121,7 +121,7 @@
<div id="productDesc" {{#if limit}}class="limit"{{/if}}> </div>
{{> detail/recommend-for-you}}
{{> cart/chose-panel}}
<div class="chose-panel"></div>
<div class="cart-bar data-bind">
<a href="" class="num-incart iconfont"><span class="num-tag hide"></span>&#xe62c;</a>
... ...
<div class="chose-panel data-bind">
<div class="main">
<div class="infos">
<div class="basic-info" >
<img class="thumb" src="">
<div class="text-info">
<p class="name"></p>
<p class="price">
<span class="sale-price"></span>
<span class="market-price data-bind"></span>
</p>
</div>
</div>
<div class="chose-items">
<div class="color-list block-list">
<span class="name"></span>
<ul id="" data-index="" class="size-row clearfix ">
<li class="block" data-num="">
</li>
</ul>
</div>
<div class="size-list block-list">
<span class="name"></span>
<ul class="size-row clearfix">
<li class="block " data-num="" data-id="" data-skuid="">
</li>
</ul>
</div>
<div class="num">
<span class="name">数量</span>
<div class="clearfix">
<a class="btn btn-minus" href="javascript:void(0);">
<span class="iconfont ">&#xe625;</span>
</a>
<input id="good-num" class="good-num disabled" type="text" value="1" disabled="true">
<a class="btn btn-plus" href="javascript:void(0);">
<span class="iconfont ">&#xe624;</span>
</a>
</div>
<span class="left-num"></span>
<input id="left-num" type="hidden" value="0">
<input id="limitNum" type="hidden" value="">
</div>
</div>
</div>
<div class="btn-wrap">
<button id="chose-btn-sure" class="btn btn-sure"></button>
</div>
</div>
</div>
<input id="promotionId" type="hidden" value="">
<input id="single" type="hidden" value="">
\ No newline at end of file
... ...
{
"name": "m-yohobuy-node",
"version": "11.11.1",
"version": "5.0.11",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -38,7 +38,7 @@
"request-promise": "^3.0.0",
"serve-favicon": "^2.3.0",
"uuid": "^2.0.3",
"yoho-node-lib": "0.1.22",
"yoho-node-lib": "0.1.23",
"yoho-zookeeper": "^1.0.3"
},
"devDependencies": {
... ...
... ... @@ -198,7 +198,7 @@ function reMarginFooter(fixedElement) {
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas'));
(function() {
var uid = getUid();
var uid = getUid() || queryString().uid;
uid = uid === 0 ? '' : uid;
... ...
... ... @@ -8,6 +8,61 @@ module.exports = function(data, callback) {
callback && callback();
};
function render(data) {
var htmlTemplate = '<div class="main">' +
' <div class="infos">' +
' <div class="basic-info" >' +
' <img class="thumb" src="">' +
' <div class="text-info">' +
' <p class="name"></p>' +
' <p class="price">' +
' <span class="sale-price"></span>' +
' <span class="market-price data-bind"></span>' +
' </p>' +
' </div>' +
' </div>' +
' <div class="chose-items">' +
' <div class="color-list block-list">' +
' <span class="name"></span>' +
' <ul id="" data-index="" class="size-row clearfix ">' +
' <li class="block" data-num="">' +
' </li>' +
' </ul>' +
' </div>' +
' <div class="size-list block-list">' +
' <span class="name"></span>' +
' <ul class="size-row clearfix">' +
' <li class="block " data-num="" data-id="" data-skuid="">' +
' </li>' +
' </ul>' +
' </div>' +
'' +
' <div class="num">' +
' <span class="name">数量</span>' +
' <div class="clearfix">' +
' <a class="btn btn-minus" href="javascript:void(0);">' +
' <span class="iconfont ">&#xe625;</span>' +
' </a>' +
' <input id="good-num" class="good-num disabled" type="text" value="1" disabled="true">' +
' <a class="btn btn-plus" href="javascript:void(0);">' +
' <span class="iconfont ">&#xe624;</span>' +
' </a>' +
' </div>' +
' <span class="left-num"></span>' +
' <input id="left-num" type="hidden" value="0">' +
' <input id="limitNum" type="hidden" value="">' +
' </div>' +
'' +
' </div>' +
' </div>' +
' <div class="btn-wrap">' +
' <button id="chose-btn-sure" class="btn btn-sure"></button>' +
' </div>' +
'</div>';
$('#promotionId').remove();
$('#single').remove();
$('.chose-panel').addClass('data-bind').html(htmlTemplate).append('<input id="promotionId" type="hidden" value="">').append('<input id="single" type="hidden" value="">');
if (data.cartInfo) {
$chosePanel.removeClass(dbClass);
var cartInfo = data.cartInfo;
... ...
... ... @@ -206,6 +206,8 @@ function loadMore($container, opt, url) {
loading.showLoadingMask();
}
opt.app_version = '1';
num = $container.find('.guang-info').length;
searching = true;
$.ajax({
... ...
... ... @@ -9,20 +9,14 @@ var mySwiper;
require('../common');
lazyLoad($('img.lazy'));
$('.star-content li').each(function(key, item) {
$(item).find('.swiper-container').addClass('swiper-' + key);
var mySwiper;
mySwiper = new Swiper('.swiper-' + key, {
lazyLoading: true,
pagination: '.swiper-' + key + ' .pagination-inner'
});
});
lazyLoad($('img.lazy'));
$('#nav-tab').bind('contextmenu', function(e) {
return false;
});
$('#nav-tab').on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li');
... ... @@ -30,15 +24,36 @@ $('#nav-tab').on('touchend touchcancel', function(e) {
return;
}
$navs.toggleClass('focus');
$contents.toggleClass('hide');
$navs.removeClass('focus');
$this.addClass('focus');
$contents.addClass('hide');
$contents.eq($this.index()).removeClass('hide');
if (typeof $this.swiper === 'undefined') { // 解决隐藏式,swiper不渲染
$this.swiper = false;
$contents.find('li').each(function(key, item) {
$(item).find('.swiper-container').addClass('swiper-' + key);
mySwiper = new Swiper('.swiper-' + key, {
lazyLoading: true,
pagination: '.swiper-' + key + ' .pagination-inner'
});
});
}
$(document).trigger('scroll'); //Trigger lazyLoad
$(document).trigger('scroll'); // Trigger lazyLoad
});
if ($('#nav-tab').find('li:eq(0)').hasClass('focus')) {
// 解决li隐藏 swiper不渲染的问题
$('#nav-tab').find('li:eq(0)').removeClass('focus');
$('#nav-tab').find('li:eq(0)').trigger('touchend');
}
$('#nav-tab').on('touchstart', function(e) {
var target = e.target || e.srcElement;
target.className = 'bytouch ' + target.className;
}).on('touchend touchcancel', function() {
$navs.removeClass('bytouch');
});
\ No newline at end of file
});
... ...