Authored by zhangxiaoru

eitorial

... ... @@ -10,9 +10,12 @@ const editorialModel = require('../models/editorial');
const index = (req, res, next) => {
let pageNum = req.query.page || 1;
let limit = req.query.limit || 20;
let type = req.query.type || 0;
editorialModel.getIndexData(type).then((result) => {
// let gender = req.query.brand || 1;
editorialModel.getIndexData(type, pageNum, limit).then((result) => {
res.display('index', {
module: 'editorial',
page: 'index',
... ... @@ -47,10 +50,20 @@ const index = (req, res, next) => {
}).catch(next);
};
// const getChannelData = (channel, tag, title) => {
// }
const list = (req, res) => {
let pageNum = req.query.page || 1;
let limit = req.query.limit || 20;
let tag = req.params.tag || '暗黑';
let authorId = req.params.authorId || 0;
// let curChannel = getChannelData(req.channel, req.query.query);
editorialModel.getListData().then((result) => {
editorialModel.getListData(pageNum, limit, tag, authorId).then((result) => {
res.display('list', {
module: 'editorial',
page: 'list',
... ... @@ -68,7 +81,7 @@ const list = (req, res) => {
name: '资讯'
}
],
pathTitle: '户外',
pathTitle: req.query.query,
msg: result,
paginationOpts: {
page: pageNum, // current page: http://host/?page=2
... ... @@ -85,206 +98,154 @@ const list = (req, res) => {
});
};
const detail = (req, res) => {
// editorialModel.getListData().then( => {
res.display('detail', {
module: 'editorial',
page: 'detail',
title: '资讯详情',
editorialDetail: {
nav: [
{
link: '/editorial?type=0',
pathTitle: '首页',
name: 'MEN首页'
},
{
link: '/editorial?type=1',
pathTitle: '资讯',
name: '资讯'
}
],
header: {
title: '黑白搭配,穿衣灵感,黑白搭配,穿衣灵感,黑白搭配,穿衣灵感,黑白搭配,穿衣灵感,黑白搭配,穿衣灵感,黑白搭配,穿衣灵感',
avatar: '//devlup.com/wp-content/uploads/2013/07/images.jpg',
name: '二京赋',
time: '2016/07/05 19:36',
click: '26',
commentNum: '45'
},
const detail = (req, res, next) => {
let id = req.params.id || 52571;
content: {
pic: {
img: '#'
},
text: {
articleText: '我服务而恢复力而柔软如个为福建和爱我发'
},
relatedReco: {
relatedTitle: '推荐搭配',
goods: [
{
img: 'http://placehold.it/274x366',
link: '',
name: 'Fred Perry Bomber jacket',
price: '1015.00'
},
{
img: 'http://placehold.it/274x366',
link: '',
name: 'Fred Perry Bomber jacket',
price: '1015.00'
},
{
img: 'http://placehold.it/274x366',
link: '',
name: 'Fred Perry Bomber jacket',
price: '1015.00'
},
{
img: 'http://placehold.it/274x366',
link: '',
name: 'Fred Perry Bomber jacket',
price: '1015.00'
},
{
img: 'http://placehold.it/274x366',
link: '',
name: 'Fred Perry Bomber jacket',
price: '1015.00'
}
]
},
relatedGoods: {
relatedTitle: '推荐搭配',
goods: [
{
img: 'http://placehold.it/274x366',
link: '',
name: 'Fred Perry Bomber jacket',
price: '1015.00'
},
{
img: 'http://placehold.it/274x366',
link: '',
name: 'Fred Perry Bomber jacket',
price: '1015.00'
},
{
img: 'http://placehold.it/274x366',
link: '',
name: 'Fred Perry Bomber jacket',
price: '1015.00'
},
{
img: 'http://placehold.it/274x366',
link: '',
name: 'Fred Perry Bomber jacket',
price: '1015.00'
}
]
}
},
brands: {
relatedTitle: '推荐搭配',
relatedBrands: [
{
url: 'http://placehold.it/274x366',
thumb: 'wed',
name: 'Fred Perry'
},
{
url: 'http://placehold.it/274x366',
thumb: 'wed',
name: 'Fred Perry'
},
{
url: 'http://placehold.it/274x366',
thumb: 'wed',
name: 'Fred Perry'
},
{
url: 'http://placehold.it/274x366',
thumb: 'wed',
name: 'Fred Perry'
},
{
url: 'http://placehold.it/274x366',
thumb: 'wed',
name: 'Fred Perry'
},
editorialModel.getDetailData(id).then((result) => {
res.display('detail', {
module: 'editorial',
page: 'detail',
title: '资讯详情',
editorialDetail: {
nav: [
{
url: 'http://placehold.it/274x366',
thumb: 'wed',
name: 'Fred Perry'
link: '/editorial?type=0',
pathTitle: '首页',
name: 'MEN首页'
},
{
url: 'http://placehold.it/274x366',
thumb: 'wed',
name: 'Fred Perry'
link: '/editorial?type=1',
pathTitle: '资讯',
name: '资讯'
}
]
},
userInfo: {
likeNum: '10'
},
share: {
shareImg: 'hjchsk',
shareDesc: 'wjhdfwe',
weixinUrl: 'http://www.baidu.com'
},
tag: [
{
name: '户外'
},
{
name: '户外'
},
{
name: '户外'
},
{
name: '户外'
],
header: result.head,
content: result.content,
tags: result.tags,
userInfo: result.head,
comment: result.comment,
brands: result.brands,
article: {
nextChapter: '来来来,让我们好好聊聊',
lastChapter: '除了黑白灰'
},
{
name: '户外'
// content: {
// goods: [
// {
// img: 'http://placehold.it/274x366',
// link: '',
// name: 'Fred Perry Bomber jacket',
// price: '1015.00'
// }
// ]
// },
// relatedGoods: {
// relatedTitle: '推荐搭配',
// goods: [
// {
// img: 'http://placehold.it/274x366',
// link: '',
// name: 'Fred Perry Bomber jacket',
// price: '1015.00'
// }
//
// ]
// }
// },
// brands: [
// {
// url: 'http://placehold.it/274x366',
// thumb: 'wed',
// name: 'Fred Perry'
// },
// {
// url: 'http://placehold.it/274x366',
// thumb: 'wed',
// name: 'Fred Perry'
// },
// {
// url: 'http://placehold.it/274x366',
// thumb: 'wed',
// name: 'Fred Perry'
// },
// {
// url: 'http://placehold.it/274x366',
// thumb: 'wed',
// name: 'Fred Perry'
// }
// ],
share: {
shareImg: 'hjchsk',
shareDesc: 'wjhdfwe',
weixinUrl: 'http://www.baidu.com'
}
],
nextChapter: 'hbrfbhwej',
lastChapter: 'fwehjfdw',
comment: {
commentNum: '4',
list: [
{
avatar: '#',
name: 'rcfse',
content: 'cec',
time: 'efrf'
},
{
avatar: '#',
name: 'rcfse',
content: 'cec',
time: 'efrf'
}
]
},
helpers: {
// import component, path depends on your project
pagination: require('../../../doraemon/components/pagination/pagination').createPagination
}
},
helpers: {
// import component, path depends on your project
pagination: require('../../../doraemon/components/pagination/pagination').createPagination
}
});
});
}).catch(next);
};
// });
let setCollect = (req, res, next) => {
let uid = req.user.uid;
let id = req.params.id || 52571;
editorialModel.setCollect(id, uid).then((result) => {
res.json(result);
}).catch(next);
};
let cancelCollect = (req, res, next) => {
let uid = req.user.uid;
let id = req.params.id || 52571;
editorialModel.setCollect(id, uid).then((result) => {
res.json(result);
}).catch(next);
};
// 点赞
let setPraise = (req, res, next) => {
let udid = req.user.uid;
let id = req.params.id || 52571;
editorialModel.setPraise(id, udid).then((result) => {
res.json(result);
}).catch(next);
};
let cancelPraise = (req, res, next) => {
let udid = req.user.uid;
let id = req.params.id || 52571;
editorialModel.cancelPraise(id, udid).then((result) => {
res.json(result);
}).catch(next);
};
let addComment = (req, res, next) => {
let uid = req.user.uid;
let id = req.params.id || 52571;
let content = req.body.content;
editorialModel.setCollect(id, uid, content).then((result) => {
res.json(result);
}).catch(next);
};
module.exports = {
index, // 资讯页
list,
detail
detail,
setCollect,
cancelCollect,
setPraise,
cancelPraise,
addComment
};
... ...
... ... @@ -4,6 +4,8 @@ const serviceAPI = global.yoho.ServiceAPI;
// const api = global.yoho.API;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
const Promise = require('bluebird');
const co = Promise.coroutine;
// const moment = require('moment');
const logger = global.yoho.logger;
... ... @@ -38,6 +40,12 @@ const _processListData = (list) => {
data.publishTime = data.publishTime.replace(/年|月/g, '/');
data.publishTime = data.publishTime.replace(/日/g, '');
if (data.isPraise === 'N') {
data.isPraise = false;
} else {
data.isPraise = true;
}
return data;
});
... ... @@ -57,19 +65,23 @@ const _getResources = (type) => {
});
};
const _getBreakingSort = () => {
return serviceAPI.get('guang/api/*/article/getList', {}).then((result) => {
const _getBreakingSort = (type, pageNum, limit) => {
return serviceAPI.get('guang/api/*/article/getList', {
sort_id: type,
page: pageNum,
limit: limit
}).then((result) => {
if (result && result.code === 200) {
return _processListData(result.data);
} else {
logger.error('资讯列表数据返回 code 不是 200');
logger.error('资讯首页列表数据返回 code 不是 200');
return {};
}
});
};
const getIndexData = (type) => {
return Promise.all([_getResources(type), _getBreakingSort()])
const getIndexData = (type, pageNum, limit) => {
return Promise.all([_getResources(type), _getBreakingSort(type, pageNum, limit)])
.then((result) => {
return {
msgTypes: result[0],
... ... @@ -78,8 +90,13 @@ const getIndexData = (type) => {
});
};
const getListData = () => {
return serviceAPI.get('guang/api/*/article/getList', {}).then((result) => {
const getListData = (pageNum, limit, tag, authorId) => {
return serviceAPI.get('guang/api/*/article/getList', {
page: pageNum,
limit: limit,
tag: tag,
author_id: authorId
}).then((result) => {
if (result && result.code === 200) {
return _processListData(result.data);
} else {
... ... @@ -89,8 +106,314 @@ const getListData = () => {
});
};
// 详情页
const _getAuthorData = (id) => {
return serviceAPI.get('/guang/service/*/author/getAuthor', {
author_id: id
}).then((result) => {
if (result && result.code === 200) {
return result.data;
} else {
logger.error('作者信息返回 code 不是 200');
return {};
}
});
};
const _processHeadData = (list) => {
return co(function*() {
list = list || [];
list = camelCase(list);
let newData = {
headData: {},
tags: []
};
_.forEach(list, function(data, index) {
if (index === 0) {
if (data.isPraise === 'N') {
data.isPraise = false;
} else {
data.isPraise = true;
}
if (data.isFavor === 'N') {
data.isFavor = false;
} else {
data.isFavor = true;
}
newData.headData = {
title: data.intro,
click: data.viewNum,
time: data.publishTime,
isLike: data.isPraise,
isFavor: data.isFavor,
likeNum: data.praiseNum
};
}
if (index === 1) {
newData.headData = _.assign(newData.headData, {
authorId: data.authorId
});
_.forEach(data.tags, function(value) {
value.url = `/editorial/list/?query=${value.name}`;
});
newData.tags = data.tags;
}
if (index === 2) {
newData.headData = _.assign(newData.headData, {
commentNum: data.total
});
}
});
newData.headData.time = newData.headData.time.replace(/-/g, '/');
newData.headData.time = newData.headData.time.replace(':00', '', 2);
let id = newData.headData.authorId;
let data = yield _getAuthorData(id);
newData.headData = _.assign(newData.headData, {
authorUrl: data.url,
avatar: data.avatar,
name: data.name
});
return newData;
})();
};
// const _getGoodsSort = (skn) => {
// return api.get('', {
// product_skn: 51137901,
// method: 'h5.product.data'
// }).then((result) => {
// if (result && result.code === 200) {
// console.log(result)
// return result;
// } else {
// logger.error('数据返回 code 不是 200');
// return {};
// }
// });
// };
const _processContentData = (list) => {
list = list || [];
list = camelCase(list);
_.forEach(list, function(data) {
if (data.text) {
data.text.data.text = data.text.data.text.replace(/<.*?>/ig, '');
}
// if (data.goods) {
// console.log(data.goods)
// _.forEach(data.goods, function(data, index) {
// console.log(index)
// _.forEach(data, function(value) {
// // console.log(value)
// // // _getGoodsSort(value.id);
// });
// });
// }
});
return list;
};
// // const _processCommentsData = (list) => {
// // list = list || [];
// // list = camelCase(list);
// // //let commentNum = list.list.length;
// // console.log(list)
// // }
// // head数据
const _getHeadData = (id) => {
return serviceAPI.get('/guang/api/*/article/getArticleBaseInfo', {
id: id
}).then((result) => {
if (result && result.code === 200) {
return result.data;
} else {
logger.error('资讯详情head数据返回 code 不是 200');
return {};
}
});
};
// // content数据
const _getContentData = (id) => {
return serviceAPI.get('/guang/service/*/article/getArticleContent', {
article_id: id
}).then((result) => {
if (result && result.code === 200) {
return _processContentData(result.data);
} else {
logger.error('资讯详情内容数据返回 code 不是 200');
return {};
}
});
};
// // 文章信息
const _getArticleData = (id) => {
return serviceAPI.get('/guang/service/v2/article/getArticle', {
article_id: id
}).then((result) => {
if (result && result.code === 200) {
return result.data;
} else {
logger.error('资讯详情内容数据返回 code 不是 200');
return {};
}
});
};
// 评论列表
const _getCommentsData = (id) => {
return serviceAPI.get('/guang/api/*/comments/getList', {
article_id: id
}).then((result) => {
if (result && result.code === 200) {
return camelCase(result.data);
} else {
logger.error('评论内容数据返回 code 不是 200');
return {};
}
});
};
// 相关品牌
const _getRelateBrand = (id) => {
return serviceAPI.get('guang/service/v2/article/getBrand', {
article_id: id
}).then((result) => {
if (result && result.code === 200) {
console.log(result.data);
return camelCase(result.data);
} else {
logger.error('相关文章数据返回 code 不是 200');
return {};
}
});
};
// 资讯收藏
const setCollect = (id, uid) => {
if (!uid) {
return Promise.resolve({
code: 400,
message: '未登录'
});
}
return serviceAPI.get('/guang/api/*/favorite/setFavorite', {
article_id: id,
uid: uid
});
};
// 取消收藏
const cancelCollect = (id, uid) => {
if (!uid) {
return Promise.resolve({
code: 400,
message: '未登录'
});
}
return serviceAPI.get('/guang/api/*/favorite/cancelFavorite', {
article_id: id,
uid: uid
});
};
// 点赞
const setPraise = (id, udid) => {
return serviceAPI.get('/guang/api/*/praise/setPraise', {
article_id: id,
udid: udid
});
};
// 取消点赞
const cancelPraise = (id, udid) => {
return serviceAPI.get('/guang/api/*/praise/cancel', {
article_id: id,
udid: udid
});
};
// 添加评论
const addComment = (id, uid, comment) => {
if (!uid) {
return Promise.resolve({
code: 400,
message: '未登录'
});
}
return serviceAPI.get('/guang/api/*/comments/add', {
article_id: id,
uid: uid,
content: comment
});
};
const getDetailData = (id) => {
return co(function *() {
let result = yield Promise.all([_getHeadData(id),
_getArticleData(id),
_getContentData(id),
_getCommentsData(id),
_getRelateBrand(id)]);
let res = yield _processHeadData([result[0], result[1], result[3]]);
return {
head: res.headData,
tags: res.tags,
content: result[2],
comment: result[3],
brands: result[4]
};
})();
};
module.exports = {
getIndexData,
getListData
getListData,
getDetailData,
setCollect,
cancelCollect,
setPraise,
cancelPraise,
addComment
};
... ...
... ... @@ -12,6 +12,13 @@ const editorial = require(cRoot + '/editorial');
router.get('/', editorial.index); // 资讯首页
router.get('/list', editorial.list); // 资讯列表页
router.get('/detail', editorial.detail);// 资讯详情页
router.get('/(:id).html', editorial.detail);// 资讯详情页
// router.get(/\/([\d]+).html/, editorial.detail);
router.post('/info/collect', editorial.setCollect);// 资讯收藏
router.post('/info/cancelcollect', editorial.cancelCollect);// 资讯取消收藏
router.get('/info/praise', editorial.setPraise);// 点赞
router.get('/info/cancelPraise', editorial.cancelPraise);// 取消点赞
router.post('/info/comment', editorial.addComment);// 添加评论
module.exports = router;
... ...
... ... @@ -27,35 +27,46 @@
<div class="article-main">
{{# content}}
{{# pic}}
{{# singleImage}}
{{# data}}
<div class="article-pic block">
<img src="{{img}}">
<img src="{{image src 930 660}}">
</div>
{{/ pic}}
{{/ data}}
{{/ singleImage}}
{{# text}}
<div class="article-text block">
<p>{{articleText}}</p>
{{# data}}
<p>{{text}}</p>
{{/ data}}
</div>
{{/ text}}
{{# relatedReco}}
{{# goodsGroup}}
<div class="related-reco">
{{> article-related}}
<div class="article-title">
<div class="title-line"></div>
<div class="text-center">
<div class="text">
<span>推荐搭配</span>
</div>
</div>
</div>
<div class="related-goods">
{{# goods}}
{{# list}}
{{> goods}}
{{/ goods}}
{{/ list}}
</div>
</div>
{{/ relatedReco}}
{{/ goodsGroup}}
{{# relatedGoods}}
<div class="related-reco">
{{> article-related}}
<div class="related-goods">
{{# goods}}
{{# goods}}
{{> goods}}
{{/ goods}}
</div>
... ... @@ -64,36 +75,40 @@
{{/ content}}
{{#if brands}}
{{# brands}}
<div class="related-brand">
{{> article-related}}
<div class="brands">
{{# relatedBrands}}
<div class="brand">
<a class="thumb" href="{{url}}" target="_blank">
<img src="{{thumb}}">
</a>
<p class="brand-name">{{name}}</p>
<div class="article-title">
<div class="title-line"></div>
<div class="text-center">
<div class="text">
<span>相关品牌</span>
</div>
{{/ relatedBrands}}
</div>
</div>
<div class="brands">
{{# brands}}
<div class="brand">
<a class="thumb" href="{{url}}" target="_blank">
<img src="{{thumb}}">
</a>
<p class="brand-name">{{name}}</p>
</div>
{{/ brands}}
</div>
</div>
{{/brands}}
{{/if}}
</div>
{{# userInfo}}
<div class="user-handle">
<ul class="clearfix">
<li id="prise-btn" class="like-status{{#isLike}} liked{{/isLike}}">
<li id="prise-btn" class="like-status{{# isLike}} liked{{/ isLike}}">
<a href="javascript:;">
<i class="iconfont">&#xe60e;</i>
<span class="like-num">{{likeNum}}</span>
</a>
</li>
<li id="collect-btn" class="sort-collect{{#isCollected}} collected{{/isCollected}}">
<li id="collect-btn" class="sort-collect{{# isCollected}} collected{{/ isCollected}}">
<a href="javascript:;">
<i class="iconfont">&#xe619;</i>
<span>收藏</span>
... ... @@ -104,19 +119,20 @@
{{/ userInfo}}
{{> share}}
<div class="article-tag">
<i class="tag-icon iconfont">&#xe615;</i>
<ul>
{{# tag}}
{{# tags}}
<li>
<a href="{{url}}" target="_blank">{{name}}</a>
</li>
{{/ tag}}
{{/ tags}}
</ul>
</div>
<div class="chapter">
{{# article}}
<p class="chapter-right">
<span>下一篇</span><br>
<a href="{{href}}">{{nextChapter}}</a>
... ... @@ -125,6 +141,7 @@
<span>上一篇</span><br>
<a href="{{href}}">{{lastChapter}}</a>
</p>
{{/ article}}
</div>
<div id="comment-area" class="comment-area">
... ... @@ -142,4 +159,4 @@
</div>
{{/ editorialDetail}}
</div>
\ No newline at end of file
</div>
... ...
{{# comment}}
<h4>
<span class="comment-num">{{commentNum}}</span>
<span class="comment-num">{{total}}</span>
条评论
</h4>
<p class="comments-empty">还没有评论,快抢沙发吧</p>
... ... @@ -9,12 +9,12 @@
{{# list}}
<li class="clearfix">
<div class="author">
<img class="comment-user-avatar" src="{{avatar}}" alt="">
<p class="comment-user-name">{{name}}</p>
<img class="comment-user-avatar" src="{{avator}}" alt="">
<p class="comment-user-name">{{username}}</p>
</div>
<div class="comment-info">
<p class="comment-content">{{content}}</p>
<p class="comment-time">{{time}}</p>
<p class="comment-time">{{createTime}}</p>
</div>
</li>
{{/ list}}
... ...
<div class="content-msg clearfix" data-id="{{id}}">
<div class="msg-left">{{categoryName}}</div>
<div class="msg-right">
<a class="msg-title" href="{{url}}" target="_blank">{{title}}</a>
<a href="{{url}}" target="_blank">
<a class="msg-title" href="/editorial/{{id}}.html" target="_blank">{{title}}</a>
<a href="/editorial/{{id}}.html" target="_blank">
<img src="{{image src 640 430 1}}">
</a>
<div class="content">{{intro}}</div>
... ... @@ -12,7 +12,7 @@
<b class="time-word">{{publishTime}}</b>
</span>
<span class="like-comment">
<i class="iconfont like-icon{{#if isPraise}} liked{{/if}}">&#xe60e;</i>
<i class="iconfont like-icon{{#if isPraise}}liked{{/if}}">&#xe60e;</i>
<b class="like-num">{{praiseNum}}</b>
</span>
</div>
... ...
... ... @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: ['./views/partial', `${doraemon}/partial`],
helpers: 'helpers'
helpers: global.yoho.helpers
}));
// router
... ...
... ... @@ -20,7 +20,8 @@ module.exports = {
cookieDomain: 'yohoblk.com',
domains: {
api: 'http://devapi.yoho.cn:58078/', // devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
service: 'http://devservice.yoho.cn:28077/', // testservice.yoho.cn:28077 devservice.yoho.cn:58077
// service: 'http://devservice.yoho.cn:service/', // testservice.yoho.cn:28077 devservice.yoho.cn:58077
service: 'http://service.yoho.cn/',
search: 'http://192.168.102.216:8080/yohosearch/'
},
useOneapm: false,
... ...
... ... @@ -11,7 +11,7 @@
<i class="iconfont douban" data-type="douban" title="分享到豆瓣">&#xe623;</i>
<div class="weixin-share-box"></div>
</span>
<input id="share-img" type="hidden" value="{{shareImg}}">
<input id="share-img" type="hidden" value="{{image shareImg 90 90}}">
<input id="share-desc" type="hidden" value="{{shareDesc}}">
<input id="weixin-url" type="hidden" value="{{weixinUrl}}">
{{/ share}}
... ...
No preview for this file type
... ... @@ -2,7 +2,7 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>
Created by FontForge 20120731 at Thu Jul 14 10:06:11 2016
Created by FontForge 20120731 at Tue Jul 19 17:45:22 2016
By admin
</metadata>
<defs>
... ... @@ -19,7 +19,7 @@ Created by FontForge 20120731 at Thu Jul 14 10:06:11 2016
bbox="0 -224 1303 896.303"
underline-thickness="50"
underline-position="-100"
unicode-range="U+0078-E643"
unicode-range="U+0078-E646"
/>
<missing-glyph horiz-adv-x="374"
d="M34 0v682h272v-682h-272zM68 34h204v614h-204v-614z" />
... ... @@ -233,5 +233,13 @@ t-14.5 40.5t-39.5 15.5z" />
<glyph glyph-name="uniE643" unicode="&#xe643;"
d="M512 896q-139 0 -257 -68.5t-186.5 -186.5t-68.5 -257t68.5 -257t186.5 -186.5t257 -68.5t257 68.5t186.5 186.5t68.5 257t-68.5 257t-186.5 186.5t-257 68.5zM563 26h-102v102h102v-102zM669 422l-46 -47q-32 -32 -46 -62t-14 -83h-102v26q0 84 60 145l63 64
q30 30 30 73q0 42 -30 72t-72 30t-72 -30t-30 -72h-103q0 84 60 144t145 60t145 -60t60 -144q0 -68 -48 -116z" />
<glyph glyph-name="uniE644" unicode="&#xe644;"
d="M707 803q-57 0 -108.5 -27.5t-87.5 -75.5q-36 48 -87.5 75.5t-108.5 27.5q-105 0 -179 -81t-74 -196q0 -42 13 -84t25.5 -64t34.5 -57q27 -42 72 -92.5t86 -89.5t88 -79.5t66 -55.5t32 -25q14 -11 32 -11t32 11q13 9 32 24.5t66 56t88 79.5t86 89.5t72 92.5
q22 35 34.5 57t25.5 64t13 84q0 115 -74 196t-179 81zM841 356q-26 -40 -70 -89t-84.5 -87t-86.5 -77t-62.5 -52.5t-26.5 -21.5q-10 8 -26.5 21t-62.5 52.5t-86 77.5t-84.5 87t-70.5 89q-20 32 -31.5 53t-21.5 53t-10 64q0 89 57.5 152t139.5 63q59 0 107.5 -35t71.5 -93v1
q4 -14 17 -14t17 14q23 57 71.5 92t107.5 35q82 0 139.5 -63t57.5 -152q0 -46 -16 -83.5t-47 -86.5z" />
<glyph glyph-name="uniE645" unicode="&#xe645;"
d="M933 411h-394v394q0 11 -8 19t-19 8t-19 -8t-8 -19v-394h-394q-11 0 -19 -8t-8 -19t8 -19t19 -8h394v-394q0 -11 8 -19t19 -8t19 8t8 19v394h394q11 0 19 8t8 19t-8 19t-19 8z" />
<glyph glyph-name="uniE646" unicode="&#xe646;"
d="M922 812h-922l1024 -1024v922q0 42 -30 72t-72 30zM891 642l-236 -307q-6 -8 -15.5 -9t-16.5 5q-1 1 -1 2l-2 2l-98 106q-10 12 -10 28t10.5 27t25 11t24.5 -11q2 -2 4 -5l63 -99l217 283q6 8 15.5 9t16.5 -6t8 -17.5t-5 -18.5z" />
</font>
</defs></svg>
... ...
No preview for this file type
No preview for this file type
/**
* 资讯详情
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/07/05
*/
var $ = require('yoho-jquery');
// lazyLoad = require('yoho-jquery-lazyload'),
var $commentArea = $('#comment-area'),
articleId = $('.detail-body').data('id');
var $commentList = $commentArea.find('.comments-wrap'),
$commentNum = $('#article-comment > .comment-num'),
commenting = false, // 评论请求尚未返回变量
locating = false, // 评论页面正在跳转
$commentBtn = $('#comment-btn'),
MAX_COMMENTS_WORDS = 100,
$wordCountTip = $('#word-count-tip'),
_alert;
require('../plugins/share');
$(document).click(function() {
$(this).closest('.weixin-share-box').hide();
$('#prise-btn').click(function() {
var prising = false,
url,
$this = $(this);
if (prising) {
return;
}
$this.toggleClass('liked');
if ($this.hasClass('liked')) {
// 点赞
url = '/editorial/info/praise';
} else {
// 取消点赞
url = '/editorial/info/cancelPraise';
}
prising = true;
$.ajax({
type: 'GET',
url: url,
data: {
id: articleId
}
}).then(function(data) {
if (data.code === 200) {
$this.find('.like-num').html(data.data);
}
prising = false;
});
}).bind('mouseenter mouseleave', function() {
$(this).toggleClass('hover');
});
// 文章收藏与取消收藏
$('#collect-btn').click(function() {
var collecting = false,
url,
$this = $(this);
if (collecting) {
return;
}
if ($this.hasClass('collected')) {
// 取消收藏
url = '/editorial/info/cancelcollect';
} else {
// 收藏
url = '/editorial/info/collect';
}
collecting = true;
$.ajax({
type: 'post',
url: url,
data: {
id: articleId
}
}).then(function(data) {
switch (data.code) {
// case 401:
// // 防止从已有col的页面再次进行跳转后出错的情况
// if (/\?col=(1|0)/.test(location.href)) {
// hrefUrl = location.href.replace(/\?col=(1|0)/, '?col=' + col);
// } else {
// hrefUrl = location.href + '?col=' + col;
// }
// location.href = '//www.yohobuy.com/signin.html?refer=' + encodeURI(hrefUrl);
// break;
case 400:
new _alert(data.message);
break;
case 200:
if (/\?col=(1|0)/.test(location.href)) {
// 如果页面url中含有col,为了防止页面刷新时收藏或者取消收藏会根据col来的问题,进行页面跳转拿掉参数
location.href = location.href.replace(/\?col=(1|0)/, '');
} else {
$this.toggleClass('collected');
}
break;
default:
break;
}
collecting = false;
});
}).bind('mouseenter mouseleave', function() {
$(this).toggleClass('hover');
});
function showComment() {
var commonlist = $('.comments-list').find('li').length;
if (commonlist === 0) {
$('.commnets-resultwrapper').hide();
$('.comments-empty').show();
} else {
$('.commnets-resultwrapper').show();
$('.comments-empty').hide();
}
}
showComment();
function comment() {
var commentInfo = $('#comment-info').val();
if (commentInfo === '') {
new _alert('评论不能为空');
return false;
}
commenting = true;
$.ajax({
url: '/editorial/info/comment',
data: {
id: articleId,
comment: commentInfo
},
type: 'post',
success: function(data) {
switch (data.code) {
// case 401:
// locating = true;
// location.href = '//www.yohobuy.com/signin.html?refer=' +
// window.escape(location.href + '#comment-info');
// break;
case 400:
new _alert(data.message);
break;
case 200:
if (data.data) {
$commentList.html(data.data.content);
$commentNum.html(data.data.count);
showComment();
// clear comment-text
$('#comment-info').val('').keyup();
}
break;
default:
break;
}
commenting = false;
}
});
}
$commentBtn.click(function(e) {
// 页面正在跳转或者正在AJAX请求时评论无效
if (locating || commenting) {
return false;
}
// 字数不符合要求
if ($('#comment-info').val().length - MAX_COMMENTS_WORDS > 0) {
return;
}
e.preventDefault();
comment(articleId);
});
$('#comment-info').keyup(function() {
var len = $(this).val().length,
showTxt;
if (len === 0) {
$wordCountTip.html('');
$commentBtn.addClass('disable');
} else {
if (len - MAX_COMMENTS_WORDS <= 0) {
showTxt = '还可以输入' + (MAX_COMMENTS_WORDS - len) + '字';
$commentBtn.removeClass('disable');
} else {
showTxt = '已超过<span class="exceed-count">' + (len - MAX_COMMENTS_WORDS) + '</span>字';
$commentBtn.addClass('disable');
}
}
$wordCountTip.html(showTxt);
});
// init
$('#comment-info').trigger('keyup');
... ...
... ... @@ -14,15 +14,48 @@ lazyLoad($('.content-msg img.lazy'));
$('.editorial-index-page').on('click', '.like-icon', function() {
var $this = $(this),
num = parseInt($this.next().html(), 10);
// prising = false,
// num = parseInt($this.next().html(), 10),
msgId = $this.closest('.msg-content').data('id'),
url;
// if (prising === msgId) {
// return;
// }
// prising = msgId;
$this.toggleClass('liked');
if ($this.hasClass('liked')) {
$this.removeClass('liked');
num = num - 1;
url = '/editorial/info/cancelPraise';
} else {
$this.addClass('liked');
num = num + 1;
console.log(num);
url = '/editorial/info/praise';
}
$this.next().html(num);
$.ajax({
type: 'GET',
url: url,
data: {
id: msgId,
time: new Date().getTime()
}
}).then(function(data) {
if (data.code === 200) {
console.log(data);
$this.next('b').html(data.data);
}
// if (data.code === 200) {
// if (data.data * 1 === 0) {
// $this.next('b').addClass('num-0').children('.num').html('0'); // 隐藏数字显示
// } else {
// console.log(data.data)
// $this.next('b').removeClass('num-0').children('.num').html(data.data);
// }
// }
// prising = false;
});
}).on('mouseenter mouseleave', '.like-icon', function() {
$(this).closest('.like').toggleClass('hover');
});
... ...
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
require('../common/header');
require('../common/return-top');
lazyLoad($('.content-msg img.lazy'));
$('.editorial-list-page').on('click', '.like-icon', function() {
var $this = $(this),
msgId = $this.closest('.msg-content').data('id'),
url;
$this.toggleClass('liked');
if ($this.hasClass('liked')) {
url = '/editorial/info/cancelPraise';
} else {
url = '/editorial/info/praise';
}
$.ajax({
type: 'GET',
url: url,
data: {
id: msgId,
time: new Date().getTime()
}
}).then(function(data) {
if (data.code === 200) {
$this.next('b').removeClass('num-0').children('.num').html(data.data);
}
// if (data.code === 200) {
// if (data.data * 1 === 0) {
// $this.next('b').addClass('num-0').children('.num').html('0'); // 隐藏数字显示
// } else {
// console.log(data.data)
// $this.next('b').removeClass('num-0').children('.num').html(data.data);
// }
// }
// prising = false;
});
}).on('mouseenter mouseleave', '.like-icon', function() {
$(this).closest('.like').toggleClass('hover');
});
... ...
... ... @@ -3,6 +3,8 @@
* @author: yyqing<yanqing.yang@yoho.cn>
* @date: 2016/7/15
*/
require('../plugins/share');
var $ = require('yoho-jquery'),
lazyload = require('yoho-jquery-lazyload'),
common = require('../common');
... ...
... ... @@ -23,8 +23,8 @@ $(function() {
Cart.editColorOrSize($(this).attr('data-productId'));
}).delegate('#checkout_btn', 'click', function(e) {
e.preventDefault();
if(!$(this).hasClass('disable')) {
window.location.href = "/shopping/order";
if (!$(this).hasClass('disable')) {
window.location.href = '/shopping/order';
}
});
... ...
.share {
height: 25px;
width: 300px;
line-height: 25px;
position: relative;
... ... @@ -22,8 +23,6 @@
.weixin-share-box {
position: absolute;
width: 282px;
height: 302px;
padding-top: 9px;
text-align: center;
top: 15px;
... ...
... ... @@ -10,8 +10,8 @@
.detail-title {
font-size: 24px;
text-align: center;
height: 55px;
overflow: hidden;
line-height: 40px;
word-wrap: break-word;
}
.article-info {
... ... @@ -239,10 +239,10 @@
.article-tag {
float: left;
width: 100%;
height: 70px;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
padding: 20px 0;
overflow: hidden;
.tag-icon {
float: left;
... ... @@ -253,6 +253,7 @@
ul {
float: left;
width: 890px;
li {
float: left;
... ...