Authored by 陈峰

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

... ... @@ -47,7 +47,7 @@ let _channelPage = (req, res, data) => {
*/
let index = (req, res, next) => {
channelModel.getChannelSwitchData().then((result) => {
res.render('index', {
res.render('channel-index', {
module: 'channel',
page: 'index',
title: 'Yoho!Buy 有货',
... ...
... ... @@ -42,6 +42,7 @@ const editor = (req, res, next) => {
let authorData = datas[0],
articleListData = datas[1];
let build = [];
if (articleListData.data.list.artList) {
articleListData.data.list.artList.forEach(articleData => {
build.push(guangProcess.formatArticle(articleData, true, isApp, false, uid));
... ... @@ -60,7 +61,7 @@ const editor = (req, res, next) => {
} else {
return next();
}
}).catch(next);
};
... ... @@ -143,7 +144,7 @@ const index = (req, res, next) => {
};
indexModel.getArticle(param).then(result => {
res.render('index', Object.assign(responseData, result));
res.render('guang-index', Object.assign(responseData, result));
}).catch(next);
};
... ... @@ -178,7 +179,7 @@ const tag = (req, res, next) => {
};
responseData.pageHeader.navTitle = param.tag || '标签';
... ... @@ -187,9 +188,60 @@ const tag = (req, res, next) => {
}).catch(next);
};
/**
* 列表页(列表首页、标签列表页、作者列表页)动态数据,如:查看数,点赞数,评论数,是否点赞,是否回复
* @param req
* @param res
*/
const listDynamicData = (req, res) => {
let ids = req.query.ids;
let udid = req.sessionID;
let other = {};
let query = req.query.query,
type = req.query.type;
if (req.user.uid) {
other.uid = req.user.uid;
}
if (query) {
other.query = query;
}
if (type) {
other.type = type;
}
indexModel.getDynamicDataByIds(ids, udid, other).then(ret => {
res.send(ret);
});
};
/**
* 详情页动态数据,如:评论数,回复数,是否点赞,是否收藏
* @param req
* @param res
*/
const detailDynamicData = (req, res) => {
let id = req.query.id,
uid = req.user.uid,
udid = req.sessionID;
indexModel.getDynamicDataById(id, uid, udid).then((ret) => {
res.status(200).send(ret);
}).catch(() => {
res.status(400);
});
};
module.exports = {
editor,
pageData,
index,
tag
tag,
listDynamicData,
detailDynamicData
};
... ...
... ... @@ -298,10 +298,59 @@ const getTagEditor = (param) => {
};
/**
* 获取制指定文章的动态信息
* @param ids
* @param udid
* @param other [Obejct] 包含uid,query,type等非必传参数
* @returns {Promise.<T>|*}
*/
const getDynamicDataByIds = (ids, udid, other) => {
let params = {
articleIds: ids,
udid: udid
};
if (other.uid) {
_.assign(params, {
uid: other.uid
});
}
if (other.query) {
_.assign(params, {
query: other.query
});
}
if (other.type) {
_.assign(params, {
type: other.type
});
}
return serviceAPI.get('guang/api/*/article/getSimpleArticleList', params, {cache: true});
};
/**
* 获取制指定文章的动态信息
* @param ids
* @returns {Promise.<T>|*}
*/
const getDynamicDataById = (id, uid, udid) => {
return serviceAPI.get('/gateway/guang/api/*/article/getArticlePraiseAndFavor', {
id: id,
uid: uid,
udid: udid
});
};
module.exports = {
getAuthor,
getArticleList,
getPageData,
getArticle,
getTagEditor
getTagEditor,
getDynamicDataByIds,
getDynamicDataById
};
... ...
... ... @@ -52,4 +52,7 @@ router.post('/plustar/brandinfoAsync', plustar.getDetailDataAsync); // 国际优
router.get('/rss', rss.index); // 订阅资讯
router.get('/info/listData', index.listDynamicData);
router.get('/info/detailData', index.detailDynamicData);
module.exports = router;
... ...
<div class="guang-list-page guang-page yoho-page">
{{# guang}}
<ul id="guang-nav" class="guang-nav clearfix">
{{# navs}}
<li class="guang-nav-item {{#focus}}focus{{/focus}}" data-type={{typeId}}>
{{type}}
</li>
{{/ navs}}
</ul>
<div id="info-list" class="info-list-container">
{{# infos}}
<div class="info-list{{^show}} hide{{/show}}">
{{#if show}}
{{#if ../swiper}}
<div class="swiper-container swiper-cont-{{typeId}}">
<div class="swiper-wrapper swiper-wrap-{{typeId}}">
{{# ../swiper}}
<div class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{/ ../swiper}}
</div>
<div class="swiper-pagination swiper-pagi-{{typeId}}"></div>
</div>
{{/if}}
{{/if}}
{{# info}}
{{> info}}
{{/ info}}
</div>
{{/ infos}}
</div>
<div id="load-more-info" class="load-more-info">
<div class="loading status hide">
正在加载...
</div>
<span class="no-more status">没有更多啦</span>
</div>
<input id="gender" type="hidden" value={{gender}}>
{{/ guang}}
</div>
\ No newline at end of file
... ...
... ... @@ -35,7 +35,8 @@ const newGoods = (req, res, next) => {
dayLimit: 1,
discount: '',
cartUrl: helpers.urlFormat('/cart/index/index', null),
pageFooter: true
pageFooter: true,
showDownloadApp: true
});
}).catch(next);
};
... ...
... ... @@ -56,6 +56,13 @@ exports.activityDetail = (req, res, next) => {
}).catch(next);
};
// 奥莱活动倒计时时间
exports.activityTime = (req, res, next) => {
outletModel.getActivityTime(req.query).then(times => {
res.json(times);
}).catch(next);
};
// 奥莱活动频道列表页
exports.activityList = (req, res, next) => {
let headerData = headerModel.setNav({
... ...
... ... @@ -102,7 +102,7 @@ let breakingYards = (req, res, next) => {
saleModel.getBreakCodeData({
yhChannel: params.channel
}).then((result) => {
res.render('sale/break-code', Object.assign(params.renderData, result));
}).catch(next);
};
... ... @@ -141,6 +141,14 @@ let discountDetail = (req, res, next) => {
}).catch(next);
};
let getTime = (req, res, next) => {
let id = req.query.id;
saleModel.getDiscountTime(id, req.yoho.channel).then((time) => {
res.json(time);
}).catch(next);
};
/**
* vip 会员专享
* @param {[object]} req
... ... @@ -224,5 +232,6 @@ module.exports = {
discountDetail,
vip,
filter,
search
search,
getTime
};
... ...
... ... @@ -122,6 +122,7 @@ const _convertActicityData = (data) => {
discountText = 0;
data = data || [];
_.forEach(data, (item) => {
if (item.promotionName) {
discountArr = item.promotionName.split('~');
... ... @@ -252,8 +253,29 @@ const getRecentActivity = (type, categoryId) => {
});
};
// pageCache 单独获取活动时间
const getActivityTime = (params) => {
return api.get('', _.assign({
method: 'app.outlets.activityGet',
platform: 3 // h5平台代号
}, params)).then(res => {
var times = [];
if (res && res.code === 200) {
_.forEach(res.data, item => {
times.push(item.startLeftTime > 0 ? dateFormate(item.startTime) : item.endLeftTime);
});
return times;
} else {
log.error('the response code of "app.outlets.activityGet" is NOT 200', res);
return {};
}
});
};
module.exports = {
getContent: getContent,
getActivity: getActivity,
getRecentActivity: getRecentActivity
getRecentActivity: getRecentActivity,
getActivityTime: getActivityTime
};
... ...
... ... @@ -131,7 +131,7 @@ const _processBreakingSort = (list) => {
const sub = [];
list = list || [];
_.forEach(list, (data, index) => {
const allSub = [];
... ... @@ -382,8 +382,9 @@ const getDiscountDetailData = (id, yhChannel) => {
title: res[0] && res[0].title,
product_pool: res[0] && res[0].product_pool,
activity: {
cover_url: res[0] && res[0].cover_url,
left_time: res[0] && res[0].left_time
cover_url: res[0] && res[0].cover_url
// left_time: res[0] && res[0].left_time
}
};
} else {
... ... @@ -393,6 +394,22 @@ const getDiscountDetailData = (id, yhChannel) => {
});
};
const getDiscountTime = (id, yhChannel) => {
let param = {
id: id,
yh_channel: channelType[yhChannel] || '1'
};
return _discount(param).then((result) => {
if (result && result.code === 200) {
return result.data[0].left_time;
} else {
logger.error('get discount time code no 200');
return {};
}
});
};
module.exports = {
getSaleData,
getBreakCodeData,
... ... @@ -401,5 +418,6 @@ module.exports = {
getVipData,
getFilterData,
getSearchData,
saleNav
saleNav,
getDiscountTime
};
... ...
... ... @@ -64,12 +64,14 @@ router.get('/sale/discount', sale.discount);
router.get('/sale/discount/detail', sale.discountDetail);
router.get('/sale/breakingYards', sale.breakingYards);
router.get('/sale/vip', sale.vip);
router.get('/sale/discount/getTime', sale.getTime);
router.get('/sale/search', sale.search);
router.get('/sale/filter', sale.filter);
router.get('/outlet', outlet.index);
router.get('/outlet/activity', outlet.activityDetail);
router.get('/outlet/activityTime', outlet.activityTime);
router.get('/outlet/activityinfo', outlet.activityList);
... ...
... ... @@ -41,3 +41,5 @@
{{> common/suspend-cart}}
</div>
{{> download-app}}
... ...
... ... @@ -7,7 +7,7 @@
{{# activity}}
<img src="{{image cover_url 640 200}}"/>
<p class="activity-time" data-time-s="{{left_time}}"><i class="iconfont time-ico">&#xe603;</i><span></span></p>
<p class="activity-time" data-time-s=""><i class="iconfont time-ico">&#xe603;</i><span></span></p>
{{/ activity}}
</div>
... ...
/**
* 动态获取页面数据
* @author liuchuanyang
* @date 2016/10/09
*/
var $ = require('yoho-jquery');
require('../common');
function getDynamicById(id) {
'use strict';
var param = {
id: id
};
// //guang.yohobuy.com/guang/info/detailData
return $.getJSON('/guang/info/detailData', param);
}
function renderData(data) {
'use strict';
if (data && data.code === 200 && data.data) {
$('.guang-detail-page .page-view').text(data.data.browseNum || 0);
}
}
function refreshData() {
'use strict';
var qs = window.queryString;
var id = qs.id;
getDynamicById(id).done(renderData);
}
refreshData();
... ...
... ... @@ -26,6 +26,7 @@ var setting = {
var $infos = $('#info-list');
require('../common');
require('./list-dynamic');
info.initInfosEvt($infos);
... ...
... ... @@ -22,6 +22,7 @@ var $infoList = $('#info-list'),
curType = $curNav.data('type');
require('../common');
require('./list-dynamic');
var state = {};
... ... @@ -49,8 +50,6 @@ info.initInfosEvt($infoList);
end: false
};
});
console.log(state);
}());
$nav.bind('contextmenu', function(e) {
return false;
... ...
... ... @@ -28,6 +28,7 @@ scrollToEl = document.querySelector('#wrapper .collocation-block');
require('../common');
require('../plugin/wx-share')();
require('./detail-dynamic');
/**
* 计算搭配的箭头的位置
... ... @@ -196,17 +197,17 @@ $('img').on('load', function() {
// pagecache 前端判断是否显示头
var param = location.search;
var isHeader = navigator.userAgent.indexOf('MicroMessenger') > -1 || param.indexOf('app_version') > -1 || param.indexOf('appVersion') > -1;
isHeader && $('#yoho-header').remove();
if ($('.guang-detail-page').hasClass('guang-detail')) {
useIscroll = true;
} else if($('.guang-detail-page').hasClass('guang-ezine')) {
} else if ($('.guang-detail-page').hasClass('guang-ezine')) {
useIscroll = false;
}
$('.main-wrap').css({
position: 'static'
})
});
pageInIscroll = isIphone && useIscroll;
... ...
/**
* 动态获取页面数据
* @author liuchuanyang
* @date 2016/10/09
*/
var $ = require('yoho-jquery');
var $msgs = $('#info-list');
require('../common');
function getDynamicByIds(ids) {
'use strict';
var data = {
ids: ids
};
var qs = window.queryString;
if (qs.query) {
// 标签列表
data.query = qs.query;
} else if (qs.type) {
// 逛首页type
data.type = qs.type;
} else if (!qs.author_id) {
// 非编辑页的情况下,为逛首页默认type=0
data.type = '0';
}
return $.ajax({
type: 'GET',
url: '/guang/info/listData',
data: data
});
}
function renderData(data) {
'use strict';
var i,
it,
$it;
var list;
if (data && data.code === 200 && (list = data.data.artList)) {
for (i = 0; i < list.length; i++) {
it = list[i];
if (it && it.articleId) {
$it = $('.guang-info[data-id=' + it.articleId + ']', $msgs);
// 浏览数目
$it.find('.page-view').text(it.views_num);
// 点赞状态
if (it.isPraise === 'Y') {
$it.find('.like-btn').addClass('liked');
} else {
$it.find('.like-btn').removeClass('liked');
}
// 点赞数目
$it.find('.like-count').text(it.praise_num);
// 评论数目
$it.find('.like-count').text(it.comment_num);
}
}
}
}
(function() {
'use strict';
var idArr = [];
$msgs.find('.guang-info').each(function() {
var id = $(this).data('id');
if (id) {
idArr.push(id);
}
});
getDynamicByIds(idArr.join(',')).then(renderData);
}());
... ...
... ... @@ -4,6 +4,7 @@
* @date: 2016/5/20
*/
var $ = require('yoho-jquery'),
tip = require('../plugin/tip'),
lazyLoad = require('yoho-jquery-lazyload');
var countDown = require('../plugin/countdown'),
... ... @@ -13,4 +14,24 @@ search.start();
lazyLoad($('img.lazy'));
countDown();
$.ajax({
type: 'GET',
url: '/product/sale/discount/getTime',
data: {
id: window.queryString.id
},
success: function(data) {
if (data) {
// $('.activity-time').attr('data-time-s', data);
countDown({
endTime: [data]
});
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
... ...
... ... @@ -33,6 +33,8 @@ var now = new Date(),
month = now.getMonth() + 1,
date = now.getDate();
require('../../common/footer');
var $listNav = $('#list-nav'),
// 导航数据信息
... ...
var $ = require('yoho-jquery'),
Countdown = require('./outlet/countdown');
// Countdown = require('./outlet/countdown'),
ajaxActivityTime = require('./outlet/ajaxActivityTime');
var search = require('./sale/search');
var el = $('.cd-lite');
// var el = $('.cd-lite');
search.start();
new Countdown.Countdown({
el: el
ajaxActivityTime({
sort: 1, // 接口规定传1
id: window.queryString.id,
type: 0 // 接口规定传0
});
// new Countdown.Countdown({
// el: el
// });
$('.back-ground-white').css('padding', '0');
... ...
... ... @@ -2,27 +2,26 @@
* Created by runner on 16/6/14.
*/
var $ = require('yoho-jquery'),
Countdown = require('./outlet/countdown'),
iscroll = require('./outlet/nav');
iscroll = require('./outlet/nav'),
ajaxActivityTime = require('./outlet/ajaxActivityTime');
var $el = $('.cd-lite');
var $el = $('.cd-lite'),
$indexNav = $('#index_nav');
require('../common');
require('./outlet/set-backurl');
if ($el.length > 0) {
$el.each(function() {
new Countdown.Countdown({
el: $(this)
});
ajaxActivityTime({
type: window.queryString.type || 2
});
}
// 导航滚动
if ($('#index_nav').length > 0) {
if ($indexNav.length > 0) {
iscroll({
el: '#index_nav'
}).goto($('#index_nav').find('.active').index());
}).goto($indexNav.find('.active').index());
}
if ($('.back-ground-white').length < 1) {
... ...
... ... @@ -5,23 +5,46 @@ var $ = require('yoho-jquery'),
tip = require('../plugin/tip'),
iscroll = require('./outlet/nav');
var $bgw = $('.back-ground-white'),
$indexNav = $('#index_nav');
require('../common');
require('./outlet/set-backurl');
// 导航滚动
if ($('#index_nav').length > 0) {
if ($indexNav.length > 0) {
iscroll({
el: '#index_nav'
}).goto($('#index_nav').find('.active').index());
}).goto($indexNav.find('.active').index());
}
if ($('.back-ground-white').length < 1) {
if ($bgw.length < 1) {
$('.empty').show();
}
$('.back-ground-white').on('click', function() {
$bgw.on('click', function() {
tip.show('活动即将开始,敬请期待!');
return false;
});
$('.cd-medium').show();
$.ajax({
type: 'GET',
url: '/product/outlet/activityTime',
data: {
type: window.queryString.type || 3
},
success: function(data) {
var $cdMedium = $('.cd-medium');
if (data) {
$cdMedium.each(function(key, item) {
$(item).html(data[key]);
});
$cdMedium.show();
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
... ...
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
lazyLoad = require('yoho-jquery-lazyload'),
Countdown = require('./outlet/countdown');
ajaxActivityTime = require('./outlet/ajaxActivityTime');
var $el = $('.cd-lite');
var $categoryNavItem = $('.outlet-category-nav a');
... ... @@ -39,10 +39,9 @@ function searchInitParam(dom) {
}
if ($el.length > 0) {
$el.each(function() {
new Countdown.Countdown({
el: $(this)
});
ajaxActivityTime({
type: 0, // 获取全部奥莱活动列表, 不区分是否将开始或结束
yh_channel: window.queryString.yh_channel
});
}
... ...
/**
* 获取奥莱活动时间
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/10/10
*/
var $ = require('yoho-jquery'),
Countdown = require('../outlet/countdown'),
tip = require('../../plugin/tip');
var $el = $('.cd-lite');
module.exports = function(params) {
$.ajax({
type: 'GET',
url: '/product/outlet/activityTime',
data: params,
success: function(data) {
if (data) {
$el.each(function(key, item) {
$(item).attr('data-config', '{"leftTime": ' + data[key] + ' }');
new Countdown.Countdown({
el: $(item)
});
});
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
};
... ...