Authored by 陈峰

常规bug修复

@@ -34,7 +34,7 @@ const getRssArticle = (gender) => { @@ -34,7 +34,7 @@ const getRssArticle = (gender) => {
34 break; 34 break;
35 } 35 }
36 return articlePromise.then((article) => { 36 return articlePromise.then((article) => {
37 - // 内容列表 37 + // 内容列表
38 if (article.data.list.artList) { 38 if (article.data.list.artList) {
39 let build = {}; 39 let build = {};
40 40
@@ -48,17 +48,17 @@ const getRssArticle = (gender) => { @@ -48,17 +48,17 @@ const getRssArticle = (gender) => {
48 build.intro = intro; 48 build.intro = intro;
49 result.push(build); 49 result.push(build);
50 artListFunc(++i, len, resolve); 50 artListFunc(++i, len, resolve);
51 - });  
52 - }  
53 - } else { 51 + });
  52 + }
  53 + } else {
54 resolve(result); 54 resolve(result);
55 - }  
56 - }; 55 + }
  56 + };
57 return new Promise((resolve) => { 57 return new Promise((resolve) => {
58 artListFunc(0, article.data.list.artList.length, resolve); 58 artListFunc(0, article.data.list.artList.length, resolve);
59 - }); 59 + });
60 60
61 - } 61 + }
62 }); 62 });
63 }; 63 };
64 64
@@ -75,20 +75,20 @@ const _genIntro = (id) => { @@ -75,20 +75,20 @@ const _genIntro = (id) => {
75 resData.data.forEach((value) => { 75 resData.data.forEach((value) => {
76 if (value.text) { // 文字 76 if (value.text) { // 文字
77 result += htmlProcess.removeHtml(htmlProcess.escapeToHtml(value.text.data.text)) + '<br/>'; 77 result += htmlProcess.removeHtml(htmlProcess.escapeToHtml(value.text.data.text)) + '<br/>';
78 - } else if (value.singleImage) { // 单张图  
79 - result += `<img src="${helpers.image(value.singleImage.data[0].src, 640, 640)}"/><br/>`;  
80 - } else if (value.smallPic && value.smallPic.data) { // 多张小图  
81 - value.smallPic.data.forEach((small) => {  
82 - result += `<img src="${helpers.image(small.src, 315, 420)}"/>`;  
83 - });  
84 - result += '<br/>';  
85 - }  
86 - }); 78 + } else if (value.singleImage) { // 单张图
  79 + result += `<img src="${helpers.image(value.singleImage.data[0].src, 640, 640)}"/><br/>`;
  80 + } else if (value.smallPic && value.smallPic.data) { // 多张小图
  81 + value.smallPic.data.forEach((small) => {
  82 + result += `<img src="${helpers.image(small.src, 315, 420)}"/>`;
  83 + });
  84 + result += '<br/>';
  85 + }
  86 + });
87 return result; 87 return result;
88 - }  
89 - }); 88 + }
  89 + });
90 90
91 }; 91 };
92 module.exports = { 92 module.exports = {
93 getRssArticle 93 getRssArticle
94 -}; 94 +};
@@ -11,11 +11,11 @@ const headerModel = require('../../../doraemon/models/header'); // 头部model @@ -11,11 +11,11 @@ const headerModel = require('../../../doraemon/models/header'); // 头部model
11 const _ = require('lodash'); 11 const _ = require('lodash');
12 12
13 const suggestData = (req, res, next) => { 13 const suggestData = (req, res, next) => {
  14 + let uid = req.user.uid;
14 let udid = req.sessionID || 'yoho'; 15 let udid = req.sessionID || 'yoho';
15 let page = req.query.page || 1; 16 let page = req.query.page || 1;
16 let limit = 10; 17 let limit = 10;
17 -  
18 - suggestModel.suggestData(udid, page, limit).then((result) => { 18 + suggestModel.suggestData(uid, udid, page, limit).then((result) => {
19 19
20 res.render('suggest', { 20 res.render('suggest', {
21 module: 'home', 21 module: 'home',
@@ -11,14 +11,13 @@ const serviceAPI = global.yoho.ServiceAPI; @@ -11,14 +11,13 @@ const serviceAPI = global.yoho.ServiceAPI;
11 const camelCase = global.yoho.camelCase; 11 const camelCase = global.yoho.camelCase;
12 const _ = require('lodash'); 12 const _ = require('lodash');
13 13
14 -const suggestData = (udid, page, limit) => { 14 +const suggestData = (uid, udid, page, limit) => {
15 15
16 return serviceAPI.get('suggest/api/v1/suggest/getList', { 16 return serviceAPI.get('suggest/api/v1/suggest/getList', {
17 udid: udid, 17 udid: udid,
18 page: page, 18 page: page,
19 limit: limit 19 limit: limit
20 }).then((result) => { 20 }).then((result) => {
21 -  
22 if (result && result.code === 200 && result.data) { 21 if (result && result.code === 200 && result.data) {
23 _.forEach(result.data.list, function(data) { 22 _.forEach(result.data.list, function(data) {
24 23
@@ -36,7 +35,6 @@ const suggestData = (udid, page, limit) => { @@ -36,7 +35,6 @@ const suggestData = (udid, page, limit) => {
36 }; 35 };
37 36
38 const upAndDown = (uid, udid, reliable, suggestId) => { 37 const upAndDown = (uid, udid, reliable, suggestId) => {
39 -  
40 return serviceAPI.get('suggest/api/v1/suggest/is_reliable', { 38 return serviceAPI.get('suggest/api/v1/suggest/is_reliable', {
41 uid: uid, 39 uid: uid,
42 udid: udid, 40 udid: udid,
@@ -176,12 +176,12 @@ exports.consults = (req, res, next) => { @@ -176,12 +176,12 @@ exports.consults = (req, res, next) => {
176 if (!req.query.product_id) { 176 if (!req.query.product_id) {
177 return next(); 177 return next();
178 } 178 }
179 - 179 + let uid = req.user.uid || 0;
180 let headerData = headerModel.setNav({ 180 let headerData = headerModel.setNav({
181 navTitle: '购买咨询' 181 navTitle: '购买咨询'
182 }); 182 });
183 183
184 - detailRelated.consults(req.query).then((result) => { 184 + detailRelated.consults(req.query, uid).then((result) => {
185 res.render('detail/consults', Object.assign({ 185 res.render('detail/consults', Object.assign({
186 title: '购买咨询', 186 title: '购买咨询',
187 pageHeader: headerData, 187 pageHeader: headerData,
@@ -253,8 +253,7 @@ exports.consultsubmit = (req, res, next) => { @@ -253,8 +253,7 @@ exports.consultsubmit = (req, res, next) => {
253 return res.json(data); 253 return res.json(data);
254 } 254 }
255 255
256 - detailRelated.addConsult(req.user.uid, req.body.product_id, req.body.content).then((result) => {  
257 - 256 + return detailRelated.addConsult(req.user.uid, req.body.product_id, req.body.content).then((result) => {
258 if (result) { 257 if (result) {
259 Object.assign(data, result); 258 Object.assign(data, result);
260 } 259 }
@@ -64,12 +64,13 @@ const _formatConsultsList = (data) => { @@ -64,12 +64,13 @@ const _formatConsultsList = (data) => {
64 * @limit {[number]} 每页咨询数量 64 * @limit {[number]} 每页咨询数量
65 * @return {[object]} 65 * @return {[object]}
66 */ 66 */
67 -const getConsults = (id, page, limit) => { 67 +const getConsults = (id, page, limit, uid) => {
68 let params = { 68 let params = {
69 method: 'app.consult.li', 69 method: 'app.consult.li',
70 product_id: id, 70 product_id: id,
71 page: page ? page : 1, 71 page: page ? page : 1,
72 - limit: limit ? limit : 300 72 + limit: limit ? limit : 300,
  73 + uid
73 }; 74 };
74 75
75 return api.get('', params, { 76 return api.get('', params, {
@@ -160,10 +161,10 @@ let comments = (params) => { @@ -160,10 +161,10 @@ let comments = (params) => {
160 * @params {[object]} 查询参数 161 * @params {[object]} 查询参数
161 * @return {[object]} 162 * @return {[object]}
162 */ 163 */
163 -let consults = (params) => { 164 +let consults = (params, uid) => {
164 return api.all([ 165 return api.all([
165 _getCommonConsult(), 166 _getCommonConsult(),
166 - getConsults(params.product_id, 1, 60) 167 + getConsults(params.product_id, 1, 60, uid)
167 ]).then(result => { 168 ]).then(result => {
168 let data = { 169 let data = {
169 link: `/product/detail/consultform?product_id=${params.product_id}` 170 link: `/product/detail/consultform?product_id=${params.product_id}`
@@ -16,15 +16,15 @@ module.exports = { @@ -16,15 +16,15 @@ module.exports = {
16 siteUrl: '//m.yohobuy.com', 16 siteUrl: '//m.yohobuy.com',
17 assetUrl: '//localhost:5001', 17 assetUrl: '//localhost:5001',
18 domains: { 18 domains: {
19 - api: 'http://api-test3.yohops.com:9999/',  
20 - service: 'http://service-test3.yohops.com:9999/',  
21 - liveApi: 'http://testapi.live.yohops.com:9999/',  
22 - singleApi: 'http://api-test3.yohops.com:9999/' 19 + // api: 'http://api-test3.yohops.com:9999/',
  20 + // service: 'http://service-test3.yohops.com:9999/',
  21 + // liveApi: 'http://testapi.live.yohops.com:9999/',
  22 + // singleApi: 'http://api-test3.yohops.com:9999/'
23 23
24 - // api: 'http://api.yoho.cn/',  
25 - // service: 'http://service.yoho.cn/',  
26 - // liveApi: 'http://api.live.yoho.cn/',  
27 - // singleApi: 'http://single.yoho.cn/' 24 + api: 'http://api.yoho.cn/',
  25 + service: 'http://service.yoho.cn/',
  26 + liveApi: 'http://api.live.yoho.cn/',
  27 + singleApi: 'http://single.yoho.cn/'
28 }, 28 },
29 subDomains: { 29 subDomains: {
30 host: '.m.yohobuy.com', 30 host: '.m.yohobuy.com',
@@ -76,7 +76,9 @@ if (navtabHammer) { @@ -76,7 +76,9 @@ if (navtabHammer) {
76 76
77 if (gotoConsultHammer) { 77 if (gotoConsultHammer) {
78 gotoConsultHammer.on('tap', function() { 78 gotoConsultHammer.on('tap', function() {
79 - location.href = $(gotoConsultEle).find('a').attr('href'); 79 + var link = $(gotoConsultEle).find('a').attr('href');
  80 + link += (link.indexOf('?') >=0 ? '&' : '?') + 'from=' + encodeURIComponent(location.href);
  81 + location.href = link;
80 }); 82 });
81 } 83 }
82 84
@@ -32,6 +32,11 @@ $content.on('focus', function() { @@ -32,6 +32,11 @@ $content.on('focus', function() {
32 $content.val('请输入咨询内容'); 32 $content.val('请输入咨询内容');
33 } 33 }
34 }); 34 });
  35 +var getUrlParam = function (paramName) {
  36 + var reg = "[\\?|\\&]+" + paramName + "=([^&]*)[^&]?";
  37 + var exp = (window.location.href + "").match(reg);
  38 + return exp ? exp[1] : "";
  39 +}
35 40
36 // 提交表单请求 41 // 提交表单请求
37 $consultForm.on('submit', function() { 42 $consultForm.on('submit', function() {
@@ -68,7 +73,12 @@ $consultForm.on('submit', function() { @@ -68,7 +73,12 @@ $consultForm.on('submit', function() {
68 } else { 73 } else {
69 tip.show('提交成功~'); 74 tip.show('提交成功~');
70 setTimeout(function() { 75 setTimeout(function() {
71 - window.history.go(-1); 76 + var from = getUrlParam('from');
  77 + if (from) {
  78 + window.location = decodeURIComponent(from);
  79 + } else {
  80 + window.history.go(-1);
  81 + }
72 }, 3000); 82 }, 3000);
73 } 83 }
74 }).fail(function() { 84 }).fail(function() {
@@ -123,7 +123,7 @@ function render(data) { @@ -123,7 +123,7 @@ function render(data) {
123 $('#limitProductCode').val(data.cartInfo.limitProductCode).removeClass(dbClass); 123 $('#limitProductCode').val(data.cartInfo.limitProductCode).removeClass(dbClass);
124 } 124 }
125 } 125 }
126 - if (data.isCollect) { 126 + if (data.isCollect === true) {
127 $('#likeBtn').addClass('liked'); 127 $('#likeBtn').addClass('liked');
128 } 128 }
129 if (data.tickets) { 129 if (data.tickets) {