Authored by lijing

逛标签页

... ... @@ -65,6 +65,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
skns.push(goods.id);
arr[goods.id] = goods.src;
});
// 通过SKN获取商品信息
productDetailModel.productInfoBySkns(skns).then((product) => {
if (product.data.product_list) {
... ... @@ -149,10 +150,11 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
} else {
resolve(contents);
}
}
};
joinContentFunc(0, articleContent.length);
});
}
};
/**
* [处理品牌数据]
* @param {[array]} getBrand [品牌原数据]
... ... @@ -163,7 +165,8 @@ const _relatedBrand = (getBrand) => {
brand.thumb = brand.thumb.replace('http://', '//');
});
return relatedBrand;
}
};
/**
* [处理标签数据]
* @param {[array]} tags [标签原数据]
... ... @@ -180,7 +183,8 @@ const _relatedTag = (tags, isApp) => {
relatedTag.push(value);
});
return relatedTag;
}
};
/**
* [处理相关文章数据]
* @param {[array]} getOtherArticle [相关文章原数据]
... ... @@ -198,7 +202,8 @@ const _relatedInfo = (getOtherArticle, isApp) => {
relatedInfo.push(value);
});
return relatedInfo;
}
};
/**
* [处理分享内容]
* @param {[int]} id [资讯id]
... ... @@ -217,7 +222,8 @@ const _shareInfo = (id, getArticle) => {
shareInfo.shareImg = helpers.image(getArticle.cover_image, 640, 320);
}
return shareInfo;
}
};
/**
* [逛资讯详情页]
*/
... ... @@ -247,7 +253,7 @@ const index = (req, res, next) => {
}
// 获取详情内容信息, 异常则跳到错误页面
return infoModel.package(id, isApp).then(detail => {
return infoModel.packageData(id, isApp).then(detail => {
let data = {
guangDetail: true,
guang: {}
... ... @@ -278,12 +284,13 @@ const index = (req, res, next) => {
pageView: detail.getArticle.pageViews,
content: []
};
if (detail.getArticleContent) {
//生成内容部分
// 生成内容部分
return _pageArticleContent(detail.getArticleContent, isApp, gender).then((contents) => {
guang.detail.content = contents;
// 相关品牌
if (detail.getBrand && detail.getBrand.length) {
guang.relatedBrand = _relatedBrand(detail.getBrand);
... ... @@ -326,6 +333,7 @@ const index = (req, res, next) => {
}
}).catch(next);
};
/**
* [逛mini内容页]
*/
... ... @@ -341,7 +349,7 @@ const mini = (req, res, next) => {
}
// 获取详情内容信息, 异常则跳到错误页面
return infoModel.package(id, isApp).then(detail => {
return infoModel.packageData(id, isApp).then(detail => {
let data = {
guangEzine: true,
guang: {}
... ... @@ -360,12 +368,13 @@ const mini = (req, res, next) => {
pageView: detail.getArticle.pageViews,
content: []
};
if (detail.getArticleContent) {
//生成内容部分
// 生成内容部分
return _pageArticleContent(detail.getArticleContent, isApp, gender).then((contents) => {
guang.detail.content = contents;
// 相关品牌
if (detail.getBrand && detail.getBrand.length) {
guang.relatedBrand = _relatedBrand(detail.getBrand);
... ... @@ -410,7 +419,7 @@ const foryoho = (req, res, next) => {
}
// 获取详情内容信息, 异常则跳到错误页面
return infoModel.package(id, isApp).then(detail => {
return infoModel.packageData(id, isApp).then(detail => {
let data = {};
if (detail.code !== 400) {
... ... @@ -421,16 +430,17 @@ const foryoho = (req, res, next) => {
data.brand = detail.getBrand;
if (detail.getArticleContent) {
//生成内容部分
// 生成内容部分
return _pageArticleContent(detail.getArticleContent, isApp, gender).then((contents) => {
data.content = contents;
//内容中的相关推荐和悬浮商品移到data层级
// 内容中的相关推荐和悬浮商品移到data层级
let relatedRecoIndex = data.content.findIndex((cont) => {
return typeof cont.relatedReco !== 'undefined';
})
});
let collocationIndex = data.content.findIndex((cont) => {
return typeof cont.collocation !== 'undefined';
})
});
if (relatedRecoIndex > 0) {
data.goods = data.content[relatedRecoIndex].relatedReco;
data.content.splice(relatedRecoIndex, 1);
... ... @@ -448,7 +458,7 @@ const foryoho = (req, res, next) => {
}
}).catch(next);
}
};
module.exports = {
index,
... ...
... ... @@ -9,18 +9,17 @@ const mRoot = '../models';
const plustarModel = require(`${mRoot}/plustar`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
let channels = {
boys: 1,
girl: 2,
kids: 3,
lifestyle: 4
boys: '1,3',
girl: '2,3',
kids: '3,3',
lifestyle: '4'
};
const getListData = (req, res, next) => {
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
let recom = '4';
let all = '1';
// console.log(gender);
console.log(gender);
plustarModel.getListData(gender, recom, all).then((result) => {
... ... @@ -41,6 +40,41 @@ const getListData = (req, res, next) => {
}).catch(next);
};
const getDetailData = (req, res, next) => {
let id = req.query.id || 342;
let uid = req.user.uid || 8039759;
let udid = req.sessionID;
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
let isApp = req.query.app_version || req.query.appVersion || false;
let clientType = req.body.client_type || '';
let version = req.body.app_version || '';
if (clientType.toLowerCase() === 'ios' && version) {
clientType = 'iphone';
} else if (clientType.toLowerCase() === 'android' && version) {
clientType = 'android';
} else {
clientType = 'h5';
}
plustarModel.getDetailData(id, uid, udid, gender, isApp, clientType).then((result) => {
res.render('plustar/detail', {
module: 'guang',
page: 'plustar-detail',
pageHeader: headerModel.setNav({
navTitle: result.brandInfo.brandName
// navTitle: '介绍'
}),
pageFooter: true,
ps: {
brandInfo: result.brandInfo
}
});
}).catch(next);
};
module.exports = {
getListData
getListData,
getDetailData
};
... ...
/**
* 逛rss订阅
* @author: chenfeng<feng.chen@yoho.cn>
* @date: 2016/09/13
*/
'use strict';
const mRoot = '../models';
const rssModel = require(`${mRoot}/rss`);
const helpers = global.yoho.helpers;
/**
* [订阅逛最新的资讯]
*/
const index = (req, res, next) => {
let gender = req.query.gender || '1,2,3',
items = [];
res.setHeader('Content-Type', 'text/xml; charset=utf-8');
return rssModel.getRssArticle(gender).then((result) => {
return res.render('rss/index', {
layout: false,
time: (new Date()).toUTCString(),
items: result
});
});
};
module.exports = {
index
};
... ...
... ... @@ -14,7 +14,7 @@ const api = global.yoho.API;
* @param {string} opt [操作(ok:表示确定,cancel:表示取消)]
* @return {[array]}
*/
const _favoriteBrand = (uid, id, isBrand, opt) => {
const favoriteBrand = (uid, id, isBrand, opt) => {
let param = {
uid: uid,
type: isBrand ? 'brand' : 'product'
... ... @@ -32,5 +32,5 @@ const _favoriteBrand = (uid, id, isBrand, opt) => {
module.exports = {
favoriteBrand: _favoriteBrand
favoriteBrand
};
... ...
... ... @@ -15,7 +15,7 @@ const guangProcess = require(`${global.utils}/guang-process`);
* @param {[int]} id [作者id]
* @return {[object]}
*/
const _getAuthor = (id) => {
const getAuthor = (id) => {
return serviceAPI.get('guang/service/v1/author/getAuthor', {
author_id: id
}, {
... ... @@ -56,7 +56,7 @@ const _category = () => {
* @param {Boolean} useCache [是否使用缓存]
* @return {[array]}
*/
const _getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, useCache) => {
const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, useCache) => {
let param = {
page: page || 1,
uid: uid || 0,
... ... @@ -95,8 +95,8 @@ const _getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit,
* @param {Boolean} isTab [是否为tab切换操作]
* @return {[array]}
*/
const _getPageData = (gender, sortId, uid, udid, page, tag, authorId, isApp, showAuthor, isTab) => {
return _getArticleList(gender, sortId, uid, udid, page, tag, authorId).then(article => {
const getPageData = (gender, sortId, uid, udid, page, tag, authorId, isApp, showAuthor, isTab) => {
return getArticleList(gender, sortId, uid, udid, page, tag, authorId).then(article => {
let result = {};
if (!article.data.list.artList) {
... ... @@ -297,9 +297,9 @@ const getTagEditor = (param) => {
};
module.exports = {
getAuthor: _getAuthor,
getArticleList: _getArticleList,
getPageData: _getPageData,
getAuthor,
getArticleList,
getPageData,
getArticle,
getTagEditor
};
... ...
... ... @@ -15,7 +15,7 @@ const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/';
* @param {Boolean} isApp [标识是否是APP访问]
* @return {[array]}
*/
const _package = (id, isApp) => {
const packageData = (id, isApp) => {
let result = {
getAuthor: {},
getArticle: {},
... ... @@ -110,6 +110,23 @@ const _package = (id, isApp) => {
});
};
/**
* [获取详情信息]
* @param {[int]} id [资讯id]
* @return {[object]}
*/
const intro = (id) => {
let param = {
article_id: id,
client_type: 'h5'
};
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, param, {
cache: true
});
};
module.exports = {
package: _package
packageData,
intro
};
... ...
... ... @@ -13,7 +13,7 @@ const serviceAPI = global.yoho.ServiceAPI;
* @param {[string]} opt [操作(ok:表示确定,cancel:表示取消)]
* @return {[array]}
*/
const _praiseArticle = (udid, id, opt) => {
const praiseArticle = (udid, id, opt) => {
let param = {
article_id: id,
udid: udid
... ... @@ -33,7 +33,7 @@ const _praiseArticle = (udid, id, opt) => {
* @param {[string]} opt [操作(ok:表示确定,cancel:表示取消)]
* @return {[array]}
*/
const _collectArticle = (uid, id, opt) => {
const collectArticle = (uid, id, opt) => {
let param = {
article_id: id,
uid: uid
... ... @@ -48,6 +48,6 @@ const _collectArticle = (uid, id, opt) => {
module.exports = {
praiseArticle: _praiseArticle,
collectArticle: _collectArticle
praiseArticle,
collectArticle
};
... ...
... ... @@ -3,13 +3,16 @@ const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const _ = require('lodash');
const productProcess = require('../../../utils/product-process');
const logger = global.yoho.logger;
const camelCase = global.yoho.camelCase;
const formaData = (data, gender) => {
let build = [];
//console.log(data)
_.forEach(data, function(val) {
//多张图
if(val.data[1]) {
// console.log(data)
_.forEach(data, function(val) {
// 多张图
if (val.data[1]) {
let imgs = [];
... ... @@ -19,33 +22,33 @@ const formaData = (data, gender) => {
obj = _.assign(obj, {
url: '/plustar/brandinfo?id=' + val.id + '&gender=' + gender,
img: list.src,
deps: val.brand_title
deps: val.brand_title
});
imgs.push(obj);
})
});
build.push({
imgs: imgs
})
});
}
//单张图
if(val.data[0]) {
// 单张图
if (val.data[0]) {
_.forEach(val.data, function(list) {
build.push({
url: '/plustar/brandinfo?id=' + val.id + '&gender=' + gender,
img: list.src,
deps: val.brand_title
})
})
});
});
}
})
});
return build;
}
};
const getContentData = (gender, type) => {
... ... @@ -55,7 +58,7 @@ const getContentData = (gender, type) => {
brand_type: type
}).then((result) => {
if (result && result.code === 200) {
//console.log(result)
// console.log(result)
return formaData(result.data.data.list[0].data, gender);
} else {
logger.error('列表 list data return code is not 200');
... ... @@ -64,8 +67,6 @@ const getContentData = (gender, type) => {
});
};
const getListData = (gender, recom, all) => {
return Promise.all([getContentData(gender, recom), getContentData(gender, all)]).then((result) => {
return {
... ... @@ -75,7 +76,73 @@ const getListData = (gender, recom, all) => {
});
};
// 相关资讯
const getRelatedEditorial = () => {
};
// 是否收藏
const isCollection = (uid, brandId, clientType) => {
return serviceAPI.get('shops/service/v1/favorite/getUidBrandFav', {
uid: uid,
brandId: brandId,
client_type: clientType
}).then((result) => {
// console.log(result)
if (result && result.code === 200) {
// console.log(result.data)
let isLike = true;
return isLike;
} else {
let isLike = false;
return isLike;
}
});
};
// 品牌详情
const getBrandData = (id, clientType, uid) => {
return serviceAPI.get('guang/api/v1/plustar/getbrandinfo', {
id: id,
client_type: clientType
}).then((result) => {
if (result && result.code === 200) {
// console.log(result.data)
let list = result.data || [];
list = camelCase(list);
let brandId = result.data.brand_id;
return isCollection(uid, brandId, clientType).then((result) => {
// console.log(result)
list = _.assign(list, {
isLike: result
});
return list;
});
} else {
logger.error('detail data return code is not 200');
return {};
}
});
};
const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
return Promise.all([getBrandData(id, clientType, uid), getRelatedEditorial(gender)]).then((result) => {
// console.log(result[0].brandDomain)
return {
brandInfo: result[0],
newArrival: result[1]
};
});
};
module.exports = {
getListData,
getContentData
getContentData,
getDetailData
};
... ...
/**
* 逛rss订阅models
* @author: chenfeng<feng.chen@yoho.cn>
* @date: 2016/09/13
*/
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
const mRoot = '../models';
const indexModel = require(`${mRoot}/index`);
const infoModel = require(`${mRoot}/info`);
const guangProcess = require(`${global.utils}/guang-process`);
const htmlProcess = require(`${global.utils}/html-process`);
const helpers = global.yoho.helpers;
/**
* [获取订阅的资讯文章列表]
* @param {[int]} gender [性别参数(1,3表示男, 2,3表示女, 默认为所有)]
* @return {[array]}
*/
const getRssArticle = (gender) => {
let result = [],
article = {},
articlePromise;
switch (gender) {
case '1,3':
articlePromise = indexModel.getArticleList('1,3', 0, 0, '', 1, null, null, 100, false);
break;
case '2,3':
articlePromise = indexModel.getArticleList('2,3', 0, 0, '', 1, null, null, 100, false);
break;
default:
articlePromise = indexModel.getArticleList('1,2,3', 0, 0, '', 1, null, null, 100, false);
break;
}
return articlePromise.then((article) => {
// 内容列表
if (article.data.list.artList) {
let build = {};
let artListFunc = (i, len, resolve) => {
if (i < len) {
let value = article.data.list.artList[i];
if (typeof value.id !== 'undefined') {
build = guangProcess.formatArticle(value, false, false, true);
build.author.name = build.author.name || '';
return _genIntro(value.id).then((intro) => {
build.intro = intro;
result.push(build);
artListFunc(++i, len, resolve);
});
}
} else {
resolve(result);
}
};
return new Promise((resolve) => {
artListFunc(0, article.data.list.artList.length, resolve);
});
}
});
};
/**
* [构建信息内容]
* @param {[int]} id [资讯id]
* @return {[string]}
*/
const _genIntro = (id) => {
let result = '';
return infoModel.intro(id).then((resData) => {
if (resData.data) {
resData.data.forEach((value) => {
if (value.text) { // 文字
result += htmlProcess.removeHtml(htmlProcess.escapeToHtml(value.text.data.text)) + '<br/>';
} else if (value.singleImage) { // 单张图
result += `<img src="${helpers.image(value.singleImage.data[0].src, 640, 640)}"/><br/>`;
} else if (value.smallPic && value.smallPic.data) { // 多张小图
value.smallPic.data.forEach((small) => {
result += `<img src="${helpers.image(small.src, 315, 420)}"/>`;
});
result += '<br/>';
}
});
return result;
}
});
};
module.exports = {
getRssArticle
};
... ...
... ... @@ -14,6 +14,7 @@ const index = require(cRoot + '/index');
const opt = require(cRoot + '/opt');
const info = require(cRoot + '/info');
const plustar = require(cRoot + '/plustar');
const rss = require(cRoot + '/rss');
const router = express.Router(); // eslint-disable-line
... ... @@ -42,6 +43,9 @@ router.get('/info/index', info.index); // 逛详情页
router.get('/info/mini', info.mini); // 逛mini内容页
router.get('/info/foryoho', info.foryoho); // 逛foryoho内容页
router.get('/plustar', plustar.getListData); // 国际优选
router.get('/plustar', plustar.getListData); // 国际优选列表页
router.get('/plustar/brandinfo', plustar.getDetailData); // 国际优选详情页
router.get('/rss', rss.index); // 订阅资讯
module.exports = router;
... ...
<div class="ps-detail-page ps-page yoho-page">
{{# ps}}
{{# brandInfo}}
<div id="brand-info" class="header brand-info ps-block" data-id="{{brandId}}">
<img class="banner lazy" data-original="{{image coverImg 640 309}}">
<img class="logo lazy" src="{{brandIco}}">
<div class="header-content clearfix">
<p class="name-islike-container">
<span class="name">{{brandName}}</span>
<a id="brand-like" class="brand-islike iconfont {{# isLike}}like{{/ isLike}}" href="{{likeUrl}}">
&#xe605;
</a>
</p>
<div id="more-intro-click-range" class="clearfix">
<div id="intro" class="intro">
{{{brandIntro}}}
</div>
{{#if brandIntro}}
<span id="more-intro" class="more-intro">
<span id="intro-more-txt">more</span>
<i class="icon iconfont">&#xe609;</i>
</span>
{{/if}}
</div>
</div>
</div>
{{/ brandInfo}}
{{# newArrival}}
<div class="new-arrival ps-block">
<div class="floor-header-more">
<h2>NEW ARRIVAL</h2>
<a class="more-btn iconfont buriedpoint" href="{{moreUrl}}" data-bp-id="shop_more_btn_0">&#xe606;</a>
</div>
<div class="new-arrival-content clearfix">
{{# naList}}
{{> good}}
{{/ naList}}
</div>
<div class="more-goods-container">
<a class="mg-text" href="{{moreUrl}}">
更多商品
<span class="more-prods iconfont">&#xe604;</span>
</a>
</div>
</div>
{{/ newArrival}}
{{#if infos}}
<div class="related-infos ps-block">
<div>
<h2 class="related-info-title">相关资讯</h2>
</div>
<div id="related-infos-container" class="related-infos-container">
{{# infos}}
{{> guang/info}}
{{/ infos}}
</div>
</div>
{{/if}}
<input id="jump-to-app" type="hidden" value="{{jumpToApp}}">
{{!-- wx-share --}}
<input id="shareLink" type="hidden" value="{{shareLink}}">
<input id="shareImg" type="hidden" value="{{shareImg}}">
<input id="shareTitle" type="hidden" value="{{shareTitle}}">
<input id="shareDesc" type="hidden" value="{{shareDesc}}">
{{/ ps}}
</div>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>有货逛</title>
<link>http://yohobuy.com</link>
<generator>http://m.yohobuy.com</generator>
<description>Yoho!Buy有货 | 年轻人潮流购物中心</description>
<atom:link href="http://guang.m.yohobuy.com/rss" rel="self"></atom:link>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/>
<language>zh-cn</language>
<copyright>2015 yoho.inc</copyright>
<lastBuildDate>{{time}}</lastBuildDate>
<ttl>50</ttl>
{{# items}}
<item>
<title><![CDATA[{{title}}]]></title>
<link>
<![CDATA[{{{url}}}&ref=rss]]>
</link>
<description>
<![CDATA[{{{intro}}}]]>
</description>
<pubDate>{{publishTime}}</pubDate>
<author>
<![CDATA[{{author.name}}]]>
</author>
<guid>
<![CDATA[{{{url}}}&ref=rss]]>
</guid>
<source>有货</source>
</item>
{{/items}}
</channel>
</rss>
\ No newline at end of file
... ...
/**
* PLUS+STAR详情页
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/10
*/
var $ = require('yoho-jquery'),
Hammer = require('yoho-hammer'),
ellipsis = require('yoho-mlellipsis'),
lazyLoad = require('yoho-jquery-lazyload');
var $intro = $('#intro'),
$imt = $('#intro-more-txt'),
$infosContainer = $('#related-infos-container');
var info = require('./info');
var tip = require('../plugin/tip');
var brandId = $('#brand-info').data('id');
var jumpToApp = $('#jump-to-app').val();
var mIntro, aIntro, logoImg;
var moreHammer, likeHammer, $goodName, $title;
var saveImage = require('../home/save-image');
require('../plugin/wx-share');
require('../common');
ellipsis.init();
// Init LazyLoad
lazyLoad($('img.lazy'));
logoImg = saveImage.getSourceUrl($('.logo').attr('src'), 'brandLogo');
$('.logo').attr('src', logoImg);
if ($('.good-detail-text .name').length > 0) {
$('.good-detail-text .name').each(function() {
$goodName = $(this);
$title = $goodName.find('a');
$title[0].mlellipsis(2);
});
}
// 文字介绍文字截取
$intro[0].mlellipsis(3);
// 获取截取文字和完整文字
setTimeout(function() {
mIntro = $intro.text();
aIntro = $intro.attr('title');
});
info.initInfosEvt($infosContainer);
// 文字介绍收起与展开
moreHammer = new Hammer(document.getElementById('more-intro-click-range'));
moreHammer.on('tap', function(e) {
var $this = $imt.parent();
$this.toggleClass('spread');
if ($this.hasClass('spread')) {
// 显示
$intro.text(aIntro);
$imt.text('收起');
} else {
// 隐藏
$intro.text(mIntro);
$imt.text('more');
$(window).scrollTop(0, 400); // 滑动到顶部
}
e.preventDefault(); // 防止收缩后误点到商品产生跳转
});
// 品牌收藏
likeHammer = new Hammer(document.getElementById('brand-like'));
likeHammer.on('tap', function(e) {
var opt = 'ok',
$this = $(e.target);
// jumpToApp = 1表示APP未登录的情况,此时不发送ajax请求而由a链接直接跳转APP
if (jumpToApp === '1') {
return;
}
e.preventDefault();
if ($this.hasClass('like')) {
opt = 'cancel';
}
$.ajax({
type: 'POST',
url: '/guang/opt/favoriteBrand',
data: {
id: brandId,
opt: opt
},
success: function(data) {
if (data.code === 200) {
$this.toggleClass('like');
tip.show(data.message);
} else if (data.code === 400 || data.code === 412) {
location.href = data.data; // 未登录跳转登录页面
} else {
tip.show(data.message);
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
});
// console.log($('.logo').attr('src'))
... ...
var domainList = {
'01': [
'img10.static.yhbimg.com',
'img11.static.yhbimg.com'
],
'02': [
'img12.static.yhbimg.com',
'img13.static.yhbimg.com'
],
'yhb-head': 'head.static.yhbimg.com'
};
var table = '00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D';
/* Number */
var crc32 = function(str, crc) {
if (crc == window.undefined) {
crc = 0;
}
var n = 0; // a number between 0 and 255
var x = 0; // an hex number
crc = crc ^ (-1);
for (var i = 0, iTop = str.length; i < iTop; i++) {
n = (crc ^ str.charCodeAt(i)) & 0xFF;
x = '0x' + table.substr(n * 9, 8);
crc = (crc >>> 8) ^ x;
}
return crc ^ (-1);
};
function getDomain(bucket, filename) {
var domain = '';
var node = '';
var domainL, nodeNum;
if (domainList[bucket]) {
domain = domainList[bucket];
} else {
node = filename.substring(15, 17);
if (domainList[node]) {
domainL = domainList[node];
nodeNum = Math.abs(crc32(filename).toString()) % domainL.length;
domain = domainL[nodeNum];
}
}
return domain;
}
function getSourceUrl(fileName, bucket) {
var domain = '';
bucket = bucket || 'yhfair';
if (fileName.indexOf('http://') === 0) {
return fileName;
}
domain = getDomain(bucket, fileName);
return '//' + domain + '/' + bucket + fileName;
}
function saveImage(data) {
var imgExtra = '?imageMogr2/thumbnail/130x130/extent/130x130/background/d2hpdGU=/position/center/quality/90';
var imgList = [];
data = JSON.parse(data).data;
if (data && data.imagesList) {
for (var i = 0; i < data.imagesList.length; i++) {
imgList.push({
imgUrl: getSourceUrl(data.imagesList[i], 'suggest') + imgExtra,
imgRelUrl: data.imagesList[i]
});
}
data = {
imgList: imgList
};
}
return data;
}
module.exports = {
saveImage,
getSourceUrl
};
... ...
... ... @@ -10,7 +10,7 @@ const helpers = global.yoho.helpers;
* @param {[string]} url [需要转换的url]
* @return {[string]} [description]
*/
const _transHttpsUrl = (url) => {
const transHttpsUrl = (url) => {
return url.replace(/^\/\//g, 'http://');
};
... ... @@ -19,7 +19,7 @@ const _transHttpsUrl = (url) => {
* @param {[string]} url [url地址]
* @return {[strng]}
*/
const _getFilterUrl = (url) => {
const getFilterUrl = (url) => {
url = url.replace('.m.yohobuy.com', global.yoho.config.subDomains.host).replace('www.yohobuy.com', global.yoho.config.siteUrl);
const whiteDomains = ['m.yohobuy.com', 'cdn.yoho.cn/myohobuy'];
... ... @@ -31,7 +31,7 @@ const _getFilterUrl = (url) => {
}
if (url.includes('feature.yoho.cn')) {
url = _transHttpsUrl(url);
url = transHttpsUrl(url);
}
if (url.includes('openby:yohobuy=')) {
let filters = ['openby:yohobuy=', '&', '?'];
... ... @@ -55,7 +55,7 @@ const _getFilterUrl = (url) => {
* @param {[string]} reqQueryString [查询字符串]
* @return {[array | false]}
*/
const _formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryString) => {
const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryString) => {
// 资讯ID不存在,则不显示
if (!articleData.id) {
return false;
... ... @@ -73,7 +73,7 @@ const _formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQuerySt
if (result.url.includes('feature.yoho.cn') ||
result.url.includes('cdn.yoho.cn')) {
result.url = _transHttpsUrl(result.url);
result.url = transHttpsUrl(result.url);
}
// 收藏
... ... @@ -104,7 +104,7 @@ const _formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQuerySt
// 判断是否显示作者信息
if (showAuthor && articleData.author) {
if (!isApp) {
articleData.author.url = _getFilterUrl(articleData.author.url);
articleData.author.url = getFilterUrl(articleData.author.url);
}
// 编辑人员 app跳转url处理 20160601
... ... @@ -148,7 +148,7 @@ const _formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQuerySt
* @param {[int]} type [类型]
* @return {[type]}
*/
const _getProductIcon = (type) => {
const getProductIcon = (type) => {
const icons = {
1: 'cloth',
3: 'pants',
... ... @@ -218,7 +218,7 @@ const _procProductImg = (images, gender) => {
* @param int gender 性别
* @return array | false
*/
const _formatProduct = (productData, showTags, showNew, showSale, width, height, isApp, showPoint, gender) => {
const formatProduct = (productData, showTags, showNew, showSale, width, height, isApp, showPoint, gender) => {
// 商品信息有问题,则不显示
if (!productData.product_skn || !productData.goods_list[0]) {
return false;
... ... @@ -260,7 +260,7 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height,
if (showPoint) {
if (result.price) {
result.price += '.00'
result.price += '.00';
}
if (result.salePrice) {
result.salePrice += '.00';
... ... @@ -284,11 +284,12 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height,
is_new: showNew && productData.is_new === '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', //年末
is_yohood: productData.is_yohood && productData.is_yohood === 'Y', // YOHOOD
midYear: productData.midear && productData.midear === 'Y', // 年中
yearEnd: productData.yearnd && productData.yearnd === 'Y', // 年末
is_advance: productData.is_advance && productData.is_advance === 'Y' // 再到着
};
// 打折与即将售完组合显示打折
if (result.is_soon_sold_out && result.tags.is_discount) {
result.tags.is_new = false;
... ... @@ -306,9 +307,9 @@ const _formatProduct = (productData, showTags, showNew, showSale, width, height,
module.exports = {
formatArticle: _formatArticle,
transHttpsUrl: _transHttpsUrl,
getFilterUrl: _getFilterUrl,
formatProduct: _formatProduct,
getProductIcon: _getProductIcon
formatArticle,
transHttpsUrl,
getFilterUrl,
formatProduct,
getProductIcon
};
... ...
/**
* html字符处理
*/
'use strict';
const _htmlMap = {'<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;'};
const _EscapeMap = {'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"'};
/**
* [移除html标签]
*/
const removeHtml = (str) => {
return str.replace(/<[^>]+>/g, '');
};
/**
* [html转为转义]
*/
const htmlToEscape = (html) => {
return html.replace(/[<>&"]/g, (e) => {
return _htmlMap[e];
});
};
/**
* [转义符转为html]
*/
const escapeToHtml = (str) => {
return str.replace(/&(lt|gt|nbsp|amp|quot);/g, (match, e) => {
return _EscapeMap[e];
});
};
module.exports = {
removeHtml,
htmlToEscape,
escapeToHtml
};
... ...
... ... @@ -9,10 +9,10 @@
* @param {[string]} str [验证参数]
* @return {[Boolean]}
*/
const _isNumeric = (str) => {
const isNumeric = (str) => {
return /^\d+(\.\d+)?$/.test(str);
};
module.exports = {
isNumeric: _isNumeric
isNumeric
};
... ...