Authored by 姜枫

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

... ... @@ -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;
... ...
... ... @@ -46,9 +46,12 @@ const getAllChannels = (params) => {
* @return {[array]}
*/
const getProductBatch = (productSkn, options) => {
productSkn = _.isArray(productSkn) ? productSkn : [productSkn];
productSkn = _.uniq(_.isArray(productSkn) ? productSkn : [productSkn]);
return api.get('', {
method: 'h5.product.batch',
limit: productSkn.length,
page: 1,
productSkn: productSkn.join(',')
}).then(result => {
return result && result.data ? productProcess.processProductList(result.data.product_list, options) : [];
... ...
... ... @@ -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;
... ...
{
"name": "m-yohobuy-node",
"version": "11.11.1",
"version": "5.0.11",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -161,6 +161,10 @@ $('.coupon-message-op-rel').on('click', function() {
location.reload();
});
$('.nav-home').on('touchstart', function() {
$('.homebuttom').toggleClass('hide');
});
if ($('#noData').length > 0) {
if (location.href.indexOf('?openby:yohobuy=') <= 0) {
tip.show('网络异常!');
... ... @@ -170,4 +174,4 @@ if ($('#noData').length > 0) {
$mask.on('click', function() {
$mask.hide();
$message.hide();
});
});
\ No newline at end of file
... ...
... ... @@ -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;
... ...
... ... @@ -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
});
... ...
... ... @@ -23,6 +23,8 @@ var $addressForm = $('.edit-address'),
newArea = [],
chinaAddressList;
require('../common.js');
$($editAddressPage, $addressListPage).css('min-height', function() {
return $(window).height() - $('#yoho-header').height();
});
... ... @@ -80,6 +82,7 @@ $addressForm.on('submit', function() {
isSubmiting = true;
loading.showLoadingMask();
$submit.css('background', '#777');
console.log(window.queryString.refer);
$.ajax({
method: 'POST',
url: '/home/saveAddress',
... ...
... ... @@ -46,8 +46,8 @@
overflow: hidden;
width: 100%;
height: 90px;
background-color: #fff;
//background-image: linear-gradient(#323232, #414141);
background-color: #000;
background-image: linear-gradient(#323232, #414141);
color: #fff;
line-height: 90px;
... ...
... ... @@ -14,8 +14,8 @@
padding: 10px 30px;
min-width: 246px;
border-radius: 10px;
background-color: #fff;
//background-image: linear-gradient(to bottom, #000 0%, #333 100%);
background-color: #000;
background-image: linear-gradient(to bottom, #000 0%, #333 100%);
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.6);
text-align: center;
font-size: 28px;
... ...