Authored by 毕凯

Merge branch 'gray' of git.yoho.cn:fe/yohobuywap-node into gray

@@ -9,6 +9,9 @@ exports.category = (req, res, next) => { @@ -9,6 +9,9 @@ exports.category = (req, res, next) => {
9 let uid = req.user.uid || req.query.uid; 9 let uid = req.user.uid || req.query.uid;
10 let params = { 10 let params = {
11 uid: uid, 11 uid: uid,
  12 + port: 1,
  13 + channel: req.query.channel,
  14 + season: req.query.season,
12 isApp: req.yoho.isApp, 15 isApp: req.yoho.isApp,
13 scene: req.query.scene || 1 16 scene: req.query.scene || 1
14 }; 17 };
@@ -42,6 +45,9 @@ exports.shop = (req, res, next) => { @@ -42,6 +45,9 @@ exports.shop = (req, res, next) => {
42 let uid = req.user.uid || req.query.uid; 45 let uid = req.user.uid || req.query.uid;
43 let params = { 46 let params = {
44 uid: uid, 47 uid: uid,
  48 + port: 1,
  49 + channel: req.query.channel,
  50 + season: req.query.season,
45 isApp: req.yoho.isApp, 51 isApp: req.yoho.isApp,
46 scene: req.query.scene || 1 52 scene: req.query.scene || 1
47 }; 53 };
1 'use strict'; 1 'use strict';
  2 +const _ = require('lodash');
2 3
3 class shareModel extends global.yoho.BaseModel { 4 class shareModel extends global.yoho.BaseModel {
4 constructor(ctx) { 5 constructor(ctx) {
@@ -10,9 +11,19 @@ class shareModel extends global.yoho.BaseModel { @@ -10,9 +11,19 @@ class shareModel extends global.yoho.BaseModel {
10 * @returns {*|Promise.<TResult>} 11 * @returns {*|Promise.<TResult>}
11 */ 12 */
12 getShareContent(params) { 13 getShareContent(params) {
  14 + let shareIdInt = _.parseInt(params.shareId);
  15 +
  16 + if (shareIdInt) {
  17 + params.shareId = _.toString(shareIdInt);
  18 + } else {
  19 + return Promise.resolve({});
  20 + }
  21 +
13 return this.get({ 22 return this.get({
14 url: 'operations/api/v5/webshare/getShare', 23 url: 'operations/api/v5/webshare/getShare',
15 - data: {share_id: params.shareId}, 24 + data: {
  25 + share_id: params.shareId
  26 + },
16 api: global.yoho.ServiceAPI, 27 api: global.yoho.ServiceAPI,
17 }).then(result => { 28 }).then(result => {
18 return result; 29 return result;
@@ -78,7 +78,9 @@ class TideModel extends global.yoho.BaseModel { @@ -78,7 +78,9 @@ class TideModel extends global.yoho.BaseModel {
78 crmRecommendShop(params) { 78 crmRecommendShop(params) {
79 return this.get({ 79 return this.get({
80 data: Object.assign({ 80 data: Object.assign({
81 - method: 'app.product.crmRecommend.shop' 81 + method: 'app.product.crmRecommend.shop',
  82 + imageType: 2,
  83 + imageSize: '314*352',
82 }, params) 84 }, params)
83 }); 85 });
84 } 86 }
@@ -121,7 +123,7 @@ class TideModel extends global.yoho.BaseModel { @@ -121,7 +123,7 @@ class TideModel extends global.yoho.BaseModel {
121 }); 123 });
122 } 124 }
123 125
124 - if (shopInfo.shopId || _.get(res[1], 'data.productList', []).length) { 126 + if (shopInfo.imageUrl || _.get(res[1], 'data.productList', []).length) {
125 tide.shopInfo.push({ 127 tide.shopInfo.push({
126 title: '# 为你精选 #', 128 title: '# 为你精选 #',
127 shopInfo: shopInfo, 129 shopInfo: shopInfo,
@@ -72,7 +72,8 @@ class payModel extends global.yoho.BaseModel { @@ -72,7 +72,8 @@ class payModel extends global.yoho.BaseModel {
72 payment_amount: _.get(result, 'data.order_extInfo.payment_amount') || 72 payment_amount: _.get(result, 'data.order_extInfo.payment_amount') ||
73 _.get(result, 'data.payment_amount'), 73 _.get(result, 'data.payment_amount'),
74 pay_expire: _.get(result, 'data.order_detail_info.ext.pay_expire') || 74 pay_expire: _.get(result, 'data.order_detail_info.ext.pay_expire') ||
75 - _.get(result, 'data.pay_expire') 75 + _.get(result, 'data.pay_expire'),
  76 + order_goods: _.get(result, 'data.order_goods')
76 } 77 }
77 }; 78 };
78 } 79 }
@@ -95,21 +96,14 @@ class payModel extends global.yoho.BaseModel { @@ -95,21 +96,14 @@ class payModel extends global.yoho.BaseModel {
95 96
96 // 购买此商品的用户也购买了,要先从订单详情获取商品skn 97 // 购买此商品的用户也购买了,要先从订单详情获取商品skn
97 _getOthersBuy(param) { 98 _getOthersBuy(param) {
98 - return Promise.all([  
99 - this.getOtherDetail(param)  
100 - ]).then((result) => { 99 + this.getOtherDetail(param).then(result => {
  100 + let skn = _.get(result, 'data.order_goods.0.product_skn', '');
101 101
102 - let goodSkn = '';  
103 -  
104 - if (result && result[0] && result[0].data && result[0].data.order_goods) {  
105 - goodSkn = result[0].data.order_goods[0].product_skn; 102 + if (skn) {
  103 + return this._getOthersBuy2(Object.assign(param, { skn: skn }));
  104 + } else {
  105 + return Promise.resolve([]);
106 } 106 }
107 -  
108 - return this._getOthersBuy2(Object.assign(param, { skn: goodSkn }));  
109 -  
110 - }).then((result) => {  
111 -  
112 - return result;  
113 }); 107 });
114 } 108 }
115 109
@@ -59,11 +59,13 @@ @@ -59,11 +59,13 @@
59 </a> 59 </a>
60 {{/data}} 60 {{/data}}
61 {{/banner}} 61 {{/banner}}
  62 + {{#if othersBuy}}
62 <div class="others-buy clearfix"> 63 <div class="others-buy clearfix">
63 <p>购买此商品的用户也购买了</p> 64 <p>购买此商品的用户也购买了</p>
64 {{# othersBuy}} 65 {{# othersBuy}}
65 {{> common/goods}} 66 {{> common/goods}}
66 {{/ othersBuy}} 67 {{/ othersBuy}}
67 </div> 68 </div>
  69 + {{/if}}
68 {{> home/maybe-like}} 70 {{> home/maybe-like}}
69 </div> 71 </div>
@@ -185,13 +185,14 @@ module.exports = class extends global.yoho.BaseModel { @@ -185,13 +185,14 @@ module.exports = class extends global.yoho.BaseModel {
185 }; 185 };
186 186
187 allList[key].forEach(row => { 187 allList[key].forEach(row => {
188 -  
189 - obj.list.push({  
190 - name: row.brand_name,  
191 - isHot: row.is_hot === 'Y' ? true : false,  
192 - isNew: row.is_show_new === 'Y' ? true : false,  
193 - url: this._urlJump(parseInt(row.type, 10), row)  
194 - }); 188 + if (row) {
  189 + obj.list.push({
  190 + name: _.get(row, 'brand_name', ''),
  191 + isHot: _.get(row, 'is_hot') === 'Y' ? true : false,
  192 + isNew: _.get(row, 'is_show_new') === 'Y' ? true : false,
  193 + url: this._urlJump(parseInt(_.get(row, 'type'), 10), row)
  194 + });
  195 + }
195 }); 196 });
196 resu.brandList.push(obj); 197 resu.brandList.push(obj);
197 } 198 }
@@ -207,9 +208,9 @@ module.exports = class extends global.yoho.BaseModel { @@ -207,9 +208,9 @@ module.exports = class extends global.yoho.BaseModel {
207 }; 208 };
208 209
209 obj.list.push({ 210 obj.list.push({
210 - brandName: newList[key].brand_name,  
211 - url: this._urlJump(parseInt(newList[key].type, 10), newList[key]),  
212 - img: helpers.image(newList[key].brand_ico, 186, 115), 211 + brandName: _.get(newList, `${key}.brand_name`, ''),
  212 + url: this._urlJump(parseInt(_.get(newList, `${key}.type`), 10), _.get(newList, `${key}`)),
  213 + img: helpers.image(_.get(newList, `${key}.brand_ico`), 186, 115),
213 }); 214 });
214 resu.newBrandWall.push(obj); 215 resu.newBrandWall.push(obj);
215 } 216 }
@@ -323,7 +323,6 @@ const local = { @@ -323,7 +323,6 @@ const local = {
323 domain: 'm.yohobuy.com' 323 domain: 'm.yohobuy.com'
324 }); 324 });
325 325
326 -  
327 // 弱密码返回数据 326 // 弱密码返回数据
328 let passwordWeakReturn; 327 let passwordWeakReturn;
329 328
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 10
11 'use strict'; 11 'use strict';
12 12
  13 +const _ = require('lodash');
13 const config = global.yoho.config; 14 const config = global.yoho.config;
14 const utils = require(global.utils); 15 const utils = require(global.utils);
15 const ResetModel = require('../models/reset'); 16 const ResetModel = require('../models/reset');
@@ -48,7 +49,16 @@ const passwordResetPage = (req, res) => { @@ -48,7 +49,16 @@ const passwordResetPage = (req, res) => {
48 */ 49 */
49 const passwordReset = (req, res, next) => { 50 const passwordReset = (req, res, next) => {
50 let passwordWeakObj = req.session.passwordWeak; 51 let passwordWeakObj = req.session.passwordWeak;
51 - let uid = (req.user && req.user.uid) || (passwordWeakObj && passwordWeakObj.uid); 52 + let uid = req.user && req.user.uid;
  53 +
  54 + if (!uid && passwordWeakObj && passwordWeakObj.uid && passwordWeakObj.session_key) {
  55 + uid = {
  56 + toString: () => {
  57 + return _.parseInt(passwordWeakObj.uid);
  58 + },
  59 + sessionKey: passwordWeakObj.session_key
  60 + };
  61 + }
52 62
53 if (!uid || !passwordWeakObj || !passwordWeakObj.token) { 63 if (!uid || !passwordWeakObj || !passwordWeakObj.token) {
54 return res.json({ 64 return res.json({
@@ -300,6 +300,10 @@ module.exports = class extends global.yoho.BaseModel { @@ -300,6 +300,10 @@ module.exports = class extends global.yoho.BaseModel {
300 * 搜索店铺的商品 300 * 搜索店铺的商品
301 */ 301 */
302 getShopGoods(params) { 302 getShopGoods(params) {
  303 + if (!/^[0-9]*$/.test(params.shop_id)) {
  304 + return Promise.resolve({});
  305 + }
  306 +
303 let finalParams = { 307 let finalParams = {
304 method: 'app.search.shop', 308 method: 'app.search.shop',
305 }; 309 };
@@ -251,6 +251,14 @@ const getSearchParamsWithoutMethod = (params) => { @@ -251,6 +251,14 @@ const getSearchParamsWithoutMethod = (params) => {
251 finalParams.brand = params.brand_id || params.brand; 251 finalParams.brand = params.brand_id || params.brand;
252 } 252 }
253 if (params.shop_id && params.shop_id !== '0') { // 店铺ID 253 if (params.shop_id && params.shop_id !== '0') { // 店铺ID
  254 + let shopIdInt = _.parseInt(params.shop_id);
  255 +
  256 + if (shopIdInt) {
  257 + params.shop_id = _.toString(shopIdInt);
  258 + } else {
  259 + params.shop_id = '';
  260 + }
  261 +
254 finalParams.shop_id = params.shop_id; 262 finalParams.shop_id = params.shop_id;
255 } 263 }
256 if (params.type) { // 排序类型 264 if (params.type) { // 排序类型