Authored by 陈峰

常规bug修复

... ... @@ -34,7 +34,7 @@ const getRssArticle = (gender) => {
break;
}
return articlePromise.then((article) => {
// 内容列表
// 内容列表
if (article.data.list.artList) {
let build = {};
... ... @@ -48,17 +48,17 @@ const getRssArticle = (gender) => {
build.intro = intro;
result.push(build);
artListFunc(++i, len, resolve);
});
}
} else {
});
}
} else {
resolve(result);
}
};
}
};
return new Promise((resolve) => {
artListFunc(0, article.data.list.artList.length, resolve);
});
});
}
}
});
};
... ... @@ -75,20 +75,20 @@ const _genIntro = (id) => {
resData.data.forEach((value) => {
if (value.text) { // 文字
result += htmlProcess.removeHtml(htmlProcess.escapeToHtml(value.text.data.text)) + '<br/>';
} else if (value.singleImage) { // 单张图
result += `<img src="${helpers.image(value.singleImage.data[0].src, 640, 640)}"/><br/>`;
} else if (value.smallPic && value.smallPic.data) { // 多张小图
value.smallPic.data.forEach((small) => {
result += `<img src="${helpers.image(small.src, 315, 420)}"/>`;
});
result += '<br/>';
}
});
} else if (value.singleImage) { // 单张图
result += `<img src="${helpers.image(value.singleImage.data[0].src, 640, 640)}"/><br/>`;
} else if (value.smallPic && value.smallPic.data) { // 多张小图
value.smallPic.data.forEach((small) => {
result += `<img src="${helpers.image(small.src, 315, 420)}"/>`;
});
result += '<br/>';
}
});
return result;
}
});
}
});
};
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}`
... ...
... ... @@ -16,15 +16,15 @@ module.exports = {
siteUrl: '//m.yohobuy.com',
assetUrl: '//localhost:5001',
domains: {
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/'
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/'
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/'
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://api.live.yoho.cn/',
singleApi: 'http://single.yoho.cn/'
},
subDomains: {
host: '.m.yohobuy.com',
... ...
... ... @@ -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() {
... ...
... ... @@ -123,7 +123,7 @@ function render(data) {
$('#limitProductCode').val(data.cartInfo.limitProductCode).removeClass(dbClass);
}
}
if (data.isCollect) {
if (data.isCollect === true) {
$('#likeBtn').addClass('liked');
}
if (data.tickets) {
... ...