Authored by htoooth

hbs

... ... @@ -150,8 +150,9 @@ const indexComment = (req, res, next) => {
let pid = req.query.productId || 0;
let page = req.query.page || 1;
let size = req.query.size || 10;
let filterId = req.query.filterId || 7; // 7全部,6有图
return service.getShareOrderListAsync(pid, page, size).then((result) => {
return service.getShareOrderListAsync(pid, page, size, filterId).then((result) => {
let pageResponse = _.get(result, 'data.pageResponse', {});
return res.json({
... ...
... ... @@ -16,16 +16,20 @@ const api = global.yoho.API;
* @returns {Promise}
* @see http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/sns/show/show_productShareOrderList.md
*/
const getShareOrderListAsync = (pid, page, size) => {
// filterId = filterId || 0;
const getShareOrderListAsync = (pid, page, size, filterId) => {
filterId = filterId || 7;
return api.get('', {
method: 'show.productShareOrderList',
productId: pid,
page: page,
limit: size
limit: size,
filterId: filterId
});
};
module.exports = {
getShareOrderListAsync
};
... ...
... ... @@ -353,36 +353,8 @@
</div>
</div>
{{/ detail}}
<script id="comments-tpl" type="text/html">
\{{# comments}}
<li>
<div class="user-info clearfix">
<img class="user-avatar pull-left" src="\{{avatar}}">
<p>
<span class="name">\{{userName}} </span>
购买了\{{color}}/\{{size}}
<br>
<span class="date">\{{date}}</span>
</p>
</div>
<p class="comment">\{{comment}}</p>
</li>
\{{/ comments}}
</script>
<script id="consults-tpl" type="text/html">
\{{# consults}}
<li>
<div class="user-info clearfix">
<img class="user-avatar" src="\{{avatar}}">
<p>
<span class="question">\{{question}}</span>
<br>
<span class="date">\{{date}}</span>
</p>
</div>
<p class="consult">\{{answer}}</p>
</li>
\{{/ consults}}
</script>
</div>
... ...
{{# comments}}
<li>
<div class="user-info clearfix">
<img class="user-avatar pull-left" src="{{avatar}}">
<p>
<span class="name">{{userName}} </span>
购买了{{color}}/{{size}}
<br>
<span class="date">{{date}}</span>
</p>
</div>
<p class="comment">{{comment}}</p>
</li>
{{/ comments}}
... ...
{{# consults}}
<li>
<div class="user-info clearfix">
<img class="user-avatar" src="{{avatar}}">
<p>
<span class="question">{{question}}</span>
<br>
<span class="date">{{date}}</span>
</p>
</div>
<p class="consult">{{answer}}</p>
</li>
{{/ consults}}
... ...
... ... @@ -37,6 +37,11 @@ var oldtatus = {
html: '<a class="coupon-btn">去使用</a>'
};
var commentType = {
PIC: 6,
ALL: 7
}
var $saleReturn = $('#saleReturn');
var dialogTpl = require('hbs/product/coupon-dialog.hbs');
... ... @@ -717,8 +722,8 @@ function fetchComment() {
var commentPage = 1,
consultPage = 1;
var commentsTpl = Handlebars.compile($('#comments-tpl').html()),
consultsTpl = Handlebars.compile($('#consults-tpl').html());
var commentsTpl = require('hbs/product/comment-item.hbs'),
consultsTpl = require('hbs/product/consult-item.hbs');
var $commentsUl = $('#comments-ul'),
$consultsUl = $('#consults-ul');
... ... @@ -729,21 +734,26 @@ function fetchComment() {
var loadingComments,
loadingConsults;
// 购买评价
function loadComments() {
function loadComments(type) {
if (loadingComments) {
return;
}
loadingComments = true;
$.ajax({
return $.ajax({
type: 'GET',
url: '/product/detail/comment',
data: {
productId: id,
page: commentPage
page: commentPage,
filterId: type
}
}).then(function(data) {
});
}
// 购买评价
function loadAllComments() {
loadComments(commentType.ALL).then(function(data) {
var res;
if (data.code === 200) {
... ... @@ -767,6 +777,13 @@ function fetchComment() {
});
}
// 购买有图评价
function loadPicComments() {
loadComments(commentType.PIC).then(function(data){
});
}
// 顾客咨询
function loadConsults() {
if (loadingConsults) {
... ... @@ -834,7 +851,7 @@ function fetchComment() {
var $this = $(this);
if ($this.hasClass('load-more-comments')) {
loadComments();
loadAllComments();
} else {
loadConsults();
}
... ... @@ -898,7 +915,7 @@ function fetchComment() {
});
});
loadComments();
loadAllComments();
loadConsults();
}
... ...