Authored by 陈轩

Merge remote-tracking branch 'origin/release/5.1' into release/5.1

... ... @@ -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));
... ... @@ -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
};
... ...
... ... @@ -9,6 +9,7 @@ const api = global.yoho.API;
const logger = global.yoho.logger;
const helpers = global.yoho.helpers;
const guangProcess = require(`${global.utils}/guang-process`);
const _ = require('lodash');
/**
* [获取作者信息]
... ... @@ -65,12 +66,13 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u
sort_id: sortId,
tag: tag,
author_id: authorId,
limit: limit
limit: 20
};
return serviceAPI.get('guang/api/v2/article/getList', param, {
cache: useCache
}).then((result) => {
console.log(result);
if (result && result.code === 200) {
return result;
} else {
... ... @@ -297,10 +299,60 @@ 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
};
... ...
... ... @@ -6,7 +6,6 @@
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const _ = require('lodash');
const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/';
const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/';
... ... @@ -84,14 +83,6 @@ const packageData = (id, isApp) => {
cache: true
}));
if (isApp) {
promises.push(api.get('', {
method: 'app.resources.getSingleTemplate',
module: 'wechat',
key: 'guang_detail_wechat'
}));
}
// 获取资讯相关的其它资讯
if (typeof article.tag !== 'undefined') {
param = {
... ... @@ -108,10 +99,19 @@ const packageData = (id, isApp) => {
cache: true
}));
}
if (isApp) {
promises.push(api.get('', {
method: 'app.resources.getSingleTemplate',
module: 'wechat',
key: 'guang_detail_wechat'
}));
}
return Promise.all(promises).then(datas => {
let getArticleContent = datas[1].data;
if (datas[3].data) {
if (isApp && datas[4].data) {
let preCount = 0;
let i;
... ... @@ -122,14 +122,14 @@ const packageData = (id, isApp) => {
}
}
getArticleContent.splice(preCount, 0, {weixinPublic: datas[3].data});
getArticleContent.splice(preCount, 0, {weixinPublic: datas[4].data});
}
result.getAuthor = datas[0].data;
result.getArticleContent = getArticleContent;
result.getBrand = datas[2].data;
if (datas.length === 5) {
result.getOtherArticle = datas[4].data;
if (datas.length === 5 && isApp || datas.length === 4 && !isApp) {
result.getOtherArticle = datas[3].data;
}
return result;
});
... ...
... ... @@ -51,4 +51,7 @@ router.get('/plustar/brandinfo', plustar.getDetailData); // 祕
router.get('/rss', rss.index); // 订阅资讯
router.get('/info/listData', index.listDynamicData);
router.get('/info/detailData', index.detailDynamicData);
module.exports = router;
... ...
... ... @@ -94,7 +94,7 @@ const _getShopDecorator = (shopId) => {
cache: true,
code: 200
}).then((result) => {
return result.data;
return (result && result.data) || {};
});
};
... ... @@ -748,14 +748,28 @@ const getShopCategory = (params) => {
_.forEach(value.sub, (subValue, subKey) => {
value.sub[subKey].url = helpers.urlFormat('/product/search/list', {
shop_id: params.shopId,
sort: _.get(value, 'relation_parameter.sort', ''),
sort: _.get(subValue, 'relation_parameter.sort', ''),
title: subValue.category_name,
query: subValue.category_name
});
});
let subCategory = [
{
category_name: '全部' + value.category_name,
url: helpers.urlFormat('/product/search/list', {
shop_id: params.shopId,
sort: _.get(value, 'relation_parameter.sort', ''),
title: '全部' + value.category_name,
query: value.category_name
})
}
];
subCategory = subCategory.concat(value.sub);
finalResult.category.push({
subcategory: value.sub
subcategory: subCategory
});
});
... ...
... ... @@ -58,6 +58,12 @@ $categoryContainer.on('touchend', function(e) {
$cur, index;
$cur = $this.closest('.p-level-item');
// 第一次单击右则空白处,出现冒泡
if ($(e.target).closest('.sub-level').length <= 0) {
e.preventDefault();
}
if ($cur.length > 0) {
index = $cur.index();
$subLevel = $this.closest('.content').find('.sub-level');
... ...
/**
* 动态获取页面数据
* @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;
... ...
... ... @@ -258,7 +258,7 @@ function loadMore($container, opt, url) {
delete opt.isTab;
},
error: function() {
console.log('error')
// console.log('error')
tip.show('网络断开连接了~');
searching = false;
delete opt.isTab;
... ...
... ... @@ -29,6 +29,7 @@ scrollToEl = document.querySelector('#wrapper .collocation-block');
require('../common');
require('../plugin/wx-share')();
require('./detail-dynamic');
/**
* 计算搭配的箭头的位置
... ... @@ -196,12 +197,12 @@ $('img').on('load', function() {
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('like');
} else {
$it.find('.like-btn').removeClass('like');
}
// 点赞数目
$it.find('.like-count').text(it.praise_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);
}());
... ...
... ... @@ -135,7 +135,8 @@ function initFilter(opt) {
var $this = $(e.target),
$cur;
// e.preventDefault();//防止透点
// 这行不能注释,iphone下会出现穿透
e.preventDefault();// 防止透点
if ($this.closest('.filter-body').length > 0) {
$cur = $this.closest('.sub-item');
... ...
... ... @@ -34,6 +34,11 @@ $categoryContainer.on('touchend', function(e) {
$cur = $this.closest('.p-level-item');
// 第一次单击右则空白处,出现冒泡
if ($(e.target).closest('.sub-level').length <= 0) {
e.preventDefault();
}
$subLevelContainer = $this.closest('.content').find('.sub-level-container');
$subLevelContainer.removeClass('hide');
... ...