Authored by 陈峰

merge hotfix/rele5.2

... ... @@ -55,7 +55,6 @@ const getRssArticle = (gender) => {
resolve(result);
}
};
return new Promise((resolve) => {
artListFunc(0, article.data.list.artList.length, resolve);
});
... ... @@ -96,4 +95,4 @@ const _genIntro = (id) => {
module.exports = {
getRssArticle
};
};
\ No newline at end of file
... ...
... ... @@ -11,11 +11,11 @@ const headerModel = require('../../../doraemon/models/header'); // 头部model
const _ = require('lodash');
const suggestData = (req, res, next) => {
let uid = req.user.uid;
let udid = req.sessionID || 'yoho';
let page = req.query.page || 1;
let limit = 10;
suggestModel.suggestData(udid, page, limit).then((result) => {
suggestModel.suggestData(uid, udid, page, limit).then((result) => {
res.render('suggest', {
module: 'home',
... ...
... ... @@ -11,14 +11,13 @@ const serviceAPI = global.yoho.ServiceAPI;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
const suggestData = (udid, page, limit) => {
const suggestData = (uid, udid, page, limit) => {
return serviceAPI.get('suggest/api/v1/suggest/getList', {
udid: udid,
page: page,
limit: limit
}).then((result) => {
if (result && result.code === 200 && result.data) {
_.forEach(result.data.list, function(data) {
... ... @@ -36,7 +35,6 @@ const suggestData = (udid, page, limit) => {
};
const upAndDown = (uid, udid, reliable, suggestId) => {
return serviceAPI.get('suggest/api/v1/suggest/is_reliable', {
uid: uid,
udid: udid,
... ...
... ... @@ -176,12 +176,12 @@ exports.consults = (req, res, next) => {
if (!req.query.product_id) {
return next();
}
let uid = req.user.uid || 0;
let headerData = headerModel.setNav({
navTitle: '购买咨询'
});
detailRelated.consults(req.query).then((result) => {
detailRelated.consults(req.query, uid).then((result) => {
res.render('detail/consults', Object.assign({
title: '购买咨询',
pageHeader: headerData,
... ... @@ -253,8 +253,7 @@ exports.consultsubmit = (req, res, next) => {
return res.json(data);
}
detailRelated.addConsult(req.user.uid, req.body.product_id, req.body.content).then((result) => {
return detailRelated.addConsult(req.user.uid, req.body.product_id, req.body.content).then((result) => {
if (result) {
Object.assign(data, result);
}
... ...
... ... @@ -64,12 +64,13 @@ const _formatConsultsList = (data) => {
* @limit {[number]} 每页咨询数量
* @return {[object]}
*/
const getConsults = (id, page, limit) => {
const getConsults = (id, page, limit, uid) => {
let params = {
method: 'app.consult.li',
product_id: id,
page: page ? page : 1,
limit: limit ? limit : 300
limit: limit ? limit : 300,
uid
};
return api.get('', params, {
... ... @@ -160,10 +161,10 @@ let comments = (params) => {
* @params {[object]} 查询参数
* @return {[object]}
*/
let consults = (params) => {
let consults = (params, uid) => {
return api.all([
_getCommonConsult(),
getConsults(params.product_id, 1, 60)
getConsults(params.product_id, 1, 60, uid)
]).then(result => {
let data = {
link: `/product/detail/consultform?product_id=${params.product_id}`
... ...
... ... @@ -76,7 +76,9 @@ if (navtabHammer) {
if (gotoConsultHammer) {
gotoConsultHammer.on('tap', function() {
location.href = $(gotoConsultEle).find('a').attr('href');
var link = $(gotoConsultEle).find('a').attr('href');
link += (link.indexOf('?') >=0 ? '&' : '?') + 'from=' + encodeURIComponent(location.href);
location.href = link;
});
}
... ...
... ... @@ -32,6 +32,11 @@ $content.on('focus', function() {
$content.val('请输入咨询内容');
}
});
var getUrlParam = function (paramName) {
var reg = "[\\?|\\&]+" + paramName + "=([^&]*)[^&]?";
var exp = (window.location.href + "").match(reg);
return exp ? exp[1] : "";
}
// 提交表单请求
$consultForm.on('submit', function() {
... ... @@ -68,7 +73,12 @@ $consultForm.on('submit', function() {
} else {
tip.show('提交成功~');
setTimeout(function() {
window.history.go(-1);
var from = getUrlParam('from');
if (from) {
window.location = decodeURIComponent(from);
} else {
window.history.go(-1);
}
}, 3000);
}
}).fail(function() {
... ...
... ... @@ -127,7 +127,7 @@ function render(data) {
$('#limitProductCode').val(data.cartInfo.limitProductCode).removeClass(dbClass);
}
}
if (data.isCollect) {
if (data.isCollect === true) {
$('#likeBtn').addClass('liked');
}
if (data.tickets) {
... ...