Authored by 毕凯

Merge remote-tracking branch 'origin/hotfix/app' into feature/openapp

@@ -349,7 +349,7 @@ exports.receiveCoupon = (receiveData, uid) => { @@ -349,7 +349,7 @@ exports.receiveCoupon = (receiveData, uid) => {
349 break; 349 break;
350 default: 350 default:
351 returnData = { 351 returnData = {
352 - msg: '领券失败!', 352 + msg: result.message || '领券失败!',
353 status: false 353 status: false
354 }; 354 };
355 break; 355 break;
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 {{#content.floors}} 14 {{#content.floors}}
15 {{#isEqualOr type 'sidebar'}} 15 {{#isEqualOr type 'sidebar'}}
16 {{! 侧悬浮}} 16 {{! 侧悬浮}}
17 - <div id="sidebar" pageid="{{param.sidebarPageId}}"></div> 17 + <div id="sidebar" pageid="{{param.sidebarPageId}}"></div>
18 {{/isEqualOr}} 18 {{/isEqualOr}}
19 {{#isEqualOr type '' 'common_floor' 'fix'}} 19 {{#isEqualOr type '' 'common_floor' 'fix'}}
20 {{! 普通楼层 顶悬浮}} 20 {{! 普通楼层 顶悬浮}}
@@ -84,12 +84,12 @@ @@ -84,12 +84,12 @@
84 {{/repeat}} 84 {{/repeat}}
85 </div> 85 </div>
86 {{/isEqualOr}} 86 {{/isEqualOr}}
87 - 87 +
88 {{#isEqualOr type 'productGroup'}} 88 {{#isEqualOr type 'productGroup'}}
89 {{! 商品池}} 89 {{! 商品池}}
90 - <div class="product-container item{{numOfOneRow}}" {{#if proBgImg}}style="background:url({{image2 proBgImg q=60}})repeat;"{{/if}}> 90 + <div class="product-container item{{numOfOneRow}}" {{#if proBgImg}}style="background:url({{image2 proBgImg q=60}}) repeat;background-size:100%;"{{/if}}>
91 <div class="product-source" condition='{{stringify searchCondition}}' fp="{{getAnalysis ../this @index}}" 91 <div class="product-source" condition='{{stringify searchCondition}}' fp="{{getAnalysis ../this @index}}"
92 - {{#unless defaultPros.length}} 92 + {{#unless defaultPros.length}}
93 {{#if searchCondition.item}} 93 {{#if searchCondition.item}}
94 cloneitem="{{searchCondition.item}}" 94 cloneitem="{{searchCondition.item}}"
95 {{else}} 95 {{else}}
@@ -130,7 +130,7 @@ @@ -130,7 +130,7 @@
130 <img class="brand-img lazy" data-original="{{image2 ../brandImg q=60}}"> 130 <img class="brand-img lazy" data-original="{{image2 ../brandImg q=60}}">
131 </a> 131 </a>
132 {{/if}} 132 {{/if}}
133 - </div> 133 + </div>
134 {{/defaultPros}} 134 {{/defaultPros}}
135 {{else}} 135 {{else}}
136 <div class="feature-product-info novisible"> 136 <div class="feature-product-info novisible">
@@ -158,7 +158,7 @@ @@ -158,7 +158,7 @@
158 {{#if brandImg}} 158 {{#if brandImg}}
159 <a class="second-part {{#isEqualOr showBrandUrl '1'}}product-brand{{else}}product-detail{{/isEqualOr}}" href=''> 159 <a class="second-part {{#isEqualOr showBrandUrl '1'}}product-brand{{else}}product-detail{{/isEqualOr}}" href=''>
160 <div class="brand-div"> 160 <div class="brand-div">
161 - <span class="brand-name" {{#if fontColor}}style="color:{{fontColor}};"{{/if}}></span> 161 + <span class="brand-name" {{#if fontColor}}style="color:{{fontColor}};"{{/if}}></span>
162 </div> 162 </div>
163 <img class="brand-img" src="{{image2 brandImg q=60}}"> 163 <img class="brand-img" src="{{image2 brandImg q=60}}">
164 </a> 164 </a>
@@ -171,6 +171,6 @@ @@ -171,6 +171,6 @@
171 {{/component}} 171 {{/component}}
172 </div> 172 </div>
173 {{/isEqualOr}} 173 {{/isEqualOr}}
174 - {{/content.floors}} 174 + {{/content.floors}}
175 {{/unless}} 175 {{/unless}}
176 -</div>  
  176 +</div>
@@ -159,7 +159,8 @@ const add = (req, res, next) => { @@ -159,7 +159,8 @@ const add = (req, res, next) => {
159 return indexModel.addToCart(productSku, buyNumber, goodsType, isEdit, promotionId, uid, shoppingKey).then(data => { 159 return indexModel.addToCart(productSku, buyNumber, goodsType, isEdit, promotionId, uid, shoppingKey).then(data => {
160 if (!shoppingKey && _.has(data, 'data.shopping_key')) { 160 if (!shoppingKey && _.has(data, 'data.shopping_key')) {
161 res.cookie('_SPK', data.data.shopping_key, { 161 res.cookie('_SPK', data.data.shopping_key, {
162 - expires: new Date(Date.now() + 86400 * 360) 162 + expires: new Date(Date.now() + 86400 * 360),
  163 + domain: '.m.yohobuy.com'
163 }); 164 });
164 } 165 }
165 data ? res.json(data) : res.status(400).json({ 166 data ? res.json(data) : res.status(400).json({
@@ -70,23 +70,26 @@ exports.orderEnsure = (req, res, next) => { @@ -70,23 +70,26 @@ exports.orderEnsure = (req, res, next) => {
70 addressModel.addressData(uid) 70 addressModel.addressData(uid)
71 ]; 71 ];
72 72
73 - if (_.isUndefined(req.cookies._isNewUser)) {  
74 - allPromise.push(orderModel.isNewUser(uid));  
75 - } 73 + /* tar note 170426 品众去除 */
  74 + // if (_.isUndefined(req.cookies._isNewUser)) {
  75 + // allPromise.push(orderModel.isNewUser(uid));
  76 + // }
76 77
77 return Promise.all(allPromise).then(result => { 78 return Promise.all(allPromise).then(result => {
78 let order = result[0]; 79 let order = result[0];
79 let userProfile = result[1]; 80 let userProfile = result[1];
80 let address = result[2]; 81 let address = result[2];
81 - let isNewUser = result[3];  
82 82
83 - if (!_.isUndefined(isNewUser)) {  
84 - if (isNewUser) {  
85 - res.cookie('_isNewUser', true, actCkOpthn);  
86 - } else {  
87 - res.cookie('_isNewUser', false, actCkOpthn);  
88 - }  
89 - } 83 + /* tar note 170426 品众去除 */
  84 + // let isNewUser = result[3];
  85 +
  86 + // if (!_.isUndefined(isNewUser)) {
  87 + // if (isNewUser) {
  88 + // res.cookie('_isNewUser', true, actCkOpthn);
  89 + // } else {
  90 + // res.cookie('_isNewUser', false, actCkOpthn);
  91 + // }
  92 + // }
90 93
91 if (order.cartUrl) { 94 if (order.cartUrl) {
92 logger.info(`orderEnsure: order cartUrl has value:${order.cartUrl}, order data is null`); 95 logger.info(`orderEnsure: order cartUrl has value:${order.cartUrl}, order data is null`);
@@ -3,12 +3,27 @@ @@ -3,12 +3,27 @@
3 const api = global.yoho.API; 3 const api = global.yoho.API;
4 4
5 const cartCount = (uid, shoppingKey) => { 5 const cartCount = (uid, shoppingKey) => {
  6 + let params = {
  7 + method: 'app.Shopping.count'
  8 + };
6 9
7 - return api.get('', {  
8 - method: 'app.Shopping.count',  
9 - uid: uid,  
10 - shopping_key: shoppingKey  
11 - }).then((result) => { 10 + if (!uid && !shoppingKey) {
  11 + return Promise.resolve({});
  12 + }
  13 +
  14 + if (uid) {
  15 + Object.assign(params, {
  16 + uid: uid
  17 + });
  18 + }
  19 +
  20 + if (shoppingKey) {
  21 + Object.assign(params, {
  22 + shopping_key: shoppingKey
  23 + });
  24 + }
  25 +
  26 + return api.get('', params).then((result) => {
12 return result; 27 return result;
13 }); 28 });
14 }; 29 };
@@ -17,6 +17,7 @@ const helpers = global.yoho.helpers; @@ -17,6 +17,7 @@ const helpers = global.yoho.helpers;
17 const _ = require('lodash'); 17 const _ = require('lodash');
18 const co = require('bluebird').coroutine; 18 const co = require('bluebird').coroutine;
19 const logger = global.yoho.logger; 19 const logger = global.yoho.logger;
  20 +const stringProcess = require(`${global.utils}/string-process`);
20 21
21 // 支付方式 22 // 支付方式
22 const payments = { 23 const payments = {
@@ -55,7 +56,7 @@ const _getOthersBuy2 = (param) => { @@ -55,7 +56,7 @@ const _getOthersBuy2 = (param) => {
55 56
56 // 订单信息 57 // 订单信息
57 const _getOtherDetail = (param) => { 58 const _getOtherDetail = (param) => {
58 - if (!param.uid || !param.orderCode) { 59 + if (!param.uid || !param.orderCode || !stringProcess.isNumeric(param.orderCode)) {
59 return Promise.resolve({}); 60 return Promise.resolve({});
60 } 61 }
61 62
@@ -8,12 +8,14 @@ @@ -8,12 +8,14 @@
8 const installmentModel = require('../models/installment'); 8 const installmentModel = require('../models/installment');
9 const _ = require('lodash'); 9 const _ = require('lodash');
10 const helpers = global.yoho.helpers; 10 const helpers = global.yoho.helpers;
  11 +const logger = global.yoho.logger;
11 12
12 // 服务器报错页面 13 // 服务器报错页面
13 const _serverCrash = (res, params, err, next) => { 14 const _serverCrash = (res, params, err, next) => {
14 if (err && err.code === 401) { 15 if (err && err.code === 401) {
15 return next(err); 16 return next(err);
16 } 17 }
  18 + logger.error(err);
17 params.title = params.title || '有货分期'; 19 params.title = params.title || '有货分期';
18 res.render('installment/server-crash', params); 20 res.render('installment/server-crash', params);
19 }; 21 };
@@ -54,6 +56,7 @@ const _repaymentList = (req, res, next, opt, params) => { @@ -54,6 +56,7 @@ const _repaymentList = (req, res, next, opt, params) => {
54 const index = (req, res, next) => { 56 const index = (req, res, next) => {
55 let uid = req.user.uid; 57 let uid = req.user.uid;
56 58
  59 + logger.info(`installment index info: client_type=${req.query.client_type},req.user.uid=${req.user.uid},req.query.uid=${req.query.uid},cookies=${JSON.stringify(req.cookies)}`); // eslint-disable-line
57 Promise.all([ 60 Promise.all([
58 installmentModel.getStauts(uid), 61 installmentModel.getStauts(uid),
59 installmentModel.getSearchIntallment({ 62 installmentModel.getSearchIntallment({
@@ -145,8 +145,7 @@ const addressModify = (req, res, next) => { @@ -145,8 +145,7 @@ const addressModify = (req, res, next) => {
145 145
146 addressModel.getAddressData({uid: uid}).then(result => { 146 addressModel.getAddressData({uid: uid}).then(result => {
147 let userAddressList = result; 147 let userAddressList = result;
148 - let addressData = addressProcess.getAddressByAreaCode(areaCode,  
149 - _.get(userAddressList, 'data', [])) || {}; 148 + let addressData = addressProcess.getAddressByAreaCode(areaCode, _.get(userAddressList, 'data', [])) || {};
150 149
151 Object.assign(addressData, { 150 Object.assign(addressData, {
152 orderCode: orderCode, 151 orderCode: orderCode,
@@ -154,7 +153,7 @@ const addressModify = (req, res, next) => { @@ -154,7 +153,7 @@ const addressModify = (req, res, next) => {
154 153
155 if (provinceAreaCode) { 154 if (provinceAreaCode) {
156 // 不允许修改省份,字符串拆分 155 // 不允许修改省份,字符串拆分
157 - let areaArray = addressData.area.split(' '); 156 + let areaArray = addressData.area ? addressData.area.split(' ') : [];
158 let area = _.slice(areaArray, 1); 157 let area = _.slice(areaArray, 1);
159 158
160 Object.assign(addressData, { 159 Object.assign(addressData, {
@@ -28,7 +28,7 @@ const _userData = (params) => { @@ -28,7 +28,7 @@ const _userData = (params) => {
28 code: 200 28 code: 200
29 }); 29 });
30 } else { 30 } else {
31 - return false; 31 + return Promise.resolve({});
32 } 32 }
33 }; 33 };
34 34
@@ -12,6 +12,7 @@ const helpers = global.yoho.helpers; @@ -12,6 +12,7 @@ const helpers = global.yoho.helpers;
12 const api = global.yoho.API; 12 const api = global.yoho.API;
13 const serviceAPI = global.yoho.ServiceAPI; 13 const serviceAPI = global.yoho.ServiceAPI;
14 const logger = global.yoho.logger; 14 const logger = global.yoho.logger;
  15 +const stringProcess = require(`${global.utils}/string-process`);
15 const API_TIMEOUT = 10000; 16 const API_TIMEOUT = 10000;
16 const codeContent = { 17 const codeContent = {
17 openN: '0876085ff46bed27f1a1eb6ee8b68987', 18 openN: '0876085ff46bed27f1a1eb6ee8b68987',
@@ -207,7 +208,7 @@ const getStauts = (uid) => { @@ -207,7 +208,7 @@ const getStauts = (uid) => {
207 if (result && result.code === 200) { 208 if (result && result.code === 200) {
208 return result.data.status; 209 return result.data.status;
209 } else { 210 } else {
210 - logger.error('get installment open status return code is not 200'); 211 + logger.error(`get installment open status return code is not 200,uid:${uid},result=${JSON.stringify(result)}`); // eslint-disable-line
211 return Promise.reject(result); 212 return Promise.reject(result);
212 } 213 }
213 }); 214 });
@@ -423,6 +424,10 @@ const getBankCards = (uid) => { @@ -423,6 +424,10 @@ const getBankCards = (uid) => {
423 const getInstallmentOrderDetail = (params) => { 424 const getInstallmentOrderDetail = (params) => {
424 const method = 'app.SpaceOrders.installDetail'; 425 const method = 'app.SpaceOrders.installDetail';
425 426
  427 + if (!params.uid || !params.orderCode || !stringProcess.isNumeric(params.orderCode)) {
  428 + return Promise.resolve({});
  429 + }
  430 +
426 return api.get('', { 431 return api.get('', {
427 method: method, 432 method: method,
428 uid: params.uid, 433 uid: params.uid,
@@ -10,6 +10,7 @@ const _ = require('lodash'); @@ -10,6 +10,7 @@ const _ = require('lodash');
10 const helpers = global.yoho.helpers; 10 const helpers = global.yoho.helpers;
11 const camelCase = global.yoho.camelCase; 11 const camelCase = global.yoho.camelCase;
12 const logger = global.yoho.logger; 12 const logger = global.yoho.logger;
  13 +const stringProcess = require(`${global.utils}/string-process`);
13 14
14 const CODE_LOGISTIC_BANNER = '1fc9b2484fcd559049f2f7e0db313f20'; // 物流详情banner资源码 15 const CODE_LOGISTIC_BANNER = '1fc9b2484fcd559049f2f7e0db313f20'; // 物流详情banner资源码
15 16
@@ -143,6 +144,10 @@ const _getOrderStatus = (order, showLogistics) => { @@ -143,6 +144,10 @@ const _getOrderStatus = (order, showLogistics) => {
143 144
144 const orderDetailData = (uid, orderCode) => { 145 const orderDetailData = (uid, orderCode) => {
145 146
  147 + if (!uid || !orderCode || !stringProcess.isNumeric(orderCode)) {
  148 + return Promise.resolve({});
  149 + }
  150 +
146 return api.get('', { 151 return api.get('', {
147 method: 'app.SpaceOrders.detail', 152 method: 'app.SpaceOrders.detail',
148 uid: uid, 153 uid: uid,
@@ -237,6 +237,8 @@ const sendCodeToMobileAPI = (req, res, next) => { @@ -237,6 +237,8 @@ const sendCodeToMobileAPI = (req, res, next) => {
237 _.set(req.session, 'backupCaptch.timeout', Date.now() + 5 * 60 * 1000); 237 _.set(req.session, 'backupCaptch.timeout', Date.now() + 5 * 60 * 1000);
238 } 238 }
239 239
  240 + req.session.backupCaptchStep2 = true; // 允许跳到第二步
  241 +
240 return res.json({ 242 return res.json({
241 code: 200, 243 code: 200,
242 data: helpers.urlFormat('/passport/back/mobilecode', { 244 data: helpers.urlFormat('/passport/back/mobilecode', {
@@ -286,14 +288,17 @@ const verifyCodeByMobileAPI = (req, res, next) => { @@ -286,14 +288,17 @@ const verifyCodeByMobileAPI = (req, res, next) => {
286 288
287 service.validateMobileCodeAsync(phoneNum, code, areaCode) 289 service.validateMobileCodeAsync(phoneNum, code, areaCode)
288 .then(result => { 290 .then(result => {
289 - if (result.code === 200) { 291 + if (result.code === 200 && result.data) {
  292 + req.session.backcode = {
  293 + phoneNum: phoneNum,
  294 + token: result.data.token,
  295 + areaCode: areaCode,
  296 + code: code
  297 + };
  298 +
290 res.json({ 299 res.json({
291 code: 200, 300 code: 200,
292 - data: helpers.urlFormat('/passport/back/backcode', {  
293 - phoneNum: phoneNum,  
294 - token: result.data.token,  
295 - areaCode: areaCode  
296 - }) 301 + data: helpers.urlFormat('/passport/back/backcode')
297 }); 302 });
298 } else { 303 } else {
299 res.json({ 304 res.json({
@@ -309,16 +314,15 @@ const verifyCodeByMobileAPI = (req, res, next) => { @@ -309,16 +314,15 @@ const verifyCodeByMobileAPI = (req, res, next) => {
309 * 找回密码页面,设置新密码页面-手机 314 * 找回密码页面,设置新密码页面-手机
310 */ 315 */
311 const setNewPasswordByMobilePage = (req, res) => { 316 const setNewPasswordByMobilePage = (req, res) => {
312 - let phoneNum = req.query.phoneNum || '';  
313 - let token = req.query.token || '';  
314 - let areaCode = req.query.areaCode || '86';  
315 - let code = req.query.code || ''; 317 + let backcode = req.session.backcode;
316 318
317 - if (!(code || (token && helpers.verifyMobile(phoneNum)))) { 319 + if (!backcode || !(backcode.code || (backcode.token && helpers.verifyMobile(backcode.phoneNum)))) {
318 res.redirect(400); 320 res.redirect(400);
319 return; 321 return;
320 } 322 }
321 323
  324 + req.session.backcode = null;
  325 +
322 res.render('back/new-password', Object.assign({ 326 res.render('back/new-password', Object.assign({
323 module: 'passport', 327 module: 'passport',
324 page: 'back-new-password', 328 page: 'back-new-password',
@@ -328,10 +332,10 @@ const setNewPasswordByMobilePage = (req, res) => { @@ -328,10 +332,10 @@ const setNewPasswordByMobilePage = (req, res) => {
328 headerText: '找回密码', 332 headerText: '找回密码',
329 isPassportPage: true, 333 isPassportPage: true,
330 backNewPwd: true, 334 backNewPwd: true,
331 - phoneNum: phoneNum,  
332 - token: token,  
333 - areaCode: areaCode,  
334 - code: code 335 + phoneNum: backcode.phoneNum,
  336 + token: backcode.token,
  337 + areaCode: backcode.areaCode,
  338 + code: backcode.code
335 })); 339 }));
336 }; 340 };
337 341
@@ -361,6 +365,20 @@ const setNewPasswordByMobileAPI = (req, res, next) => { @@ -361,6 +365,20 @@ const setNewPasswordByMobileAPI = (req, res, next) => {
361 .catch(next); 365 .catch(next);
362 }; 366 };
363 367
  368 +/**
  369 + * 直接调用发短信接口的情况
  370 + */
  371 +const verifySmsAllow = (req, res, next) => {
  372 + if (_.get(req, 'session.backupCaptch.verifyResult')) {
  373 + return next();
  374 + } else {
  375 + return res.json({
  376 + code: 400,
  377 + message: '非法请求'
  378 + });
  379 + }
  380 +};
  381 +
364 module.exports = { 382 module.exports = {
365 indexEmailPage, 383 indexEmailPage,
366 sendCodeToEmailAPI, 384 sendCodeToEmailAPI,
@@ -373,5 +391,6 @@ module.exports = { @@ -373,5 +391,6 @@ module.exports = {
373 verifyCodeByMobileAPI, 391 verifyCodeByMobileAPI,
374 setNewPasswordByMobilePage, 392 setNewPasswordByMobilePage,
375 setNewPasswordByMobileAPI, 393 setNewPasswordByMobileAPI,
376 - generateCodeImg 394 + generateCodeImg,
  395 + verifySmsAllow
377 }; 396 };
@@ -38,6 +38,7 @@ exports.imgCheck = (req, res, next) => { @@ -38,6 +38,7 @@ exports.imgCheck = (req, res, next) => {
38 }, ''); 38 }, '');
39 39
40 req.session.captcha = codeStr; 40 req.session.captcha = codeStr;
  41 + req.session.captchaTimeout = new Date().getTime() + 1000 * 60;
41 req.session.captchaSrc = result.data.verifiedGraphicCode; 42 req.session.captchaSrc = result.data.verifiedGraphicCode;
42 43
43 return request(`${result.data.verifiedGraphicCode}?imageView2/0/format/jpg/q/70|watermark/2/text/${uuid.v4()}/fontsize/120/dissolve/10`).pipe(res); // eslint-disable-line 44 return request(`${result.data.verifiedGraphicCode}?imageView2/0/format/jpg/q/70|watermark/2/text/${uuid.v4()}/fontsize/120/dissolve/10`).pipe(res); // eslint-disable-line
@@ -52,6 +53,18 @@ exports.imgCheck = (req, res, next) => { @@ -52,6 +53,18 @@ exports.imgCheck = (req, res, next) => {
52 exports.validate = (req, res, next) => { 53 exports.validate = (req, res, next) => {
53 let captchaInput = req.body.captcha; 54 let captchaInput = req.body.captcha;
54 let captchaCode = _.get(req.session, 'captcha'); 55 let captchaCode = _.get(req.session, 'captcha');
  56 + let captchaTimeout = _.get(req.session, 'captchaTimeout');
  57 +
  58 + if (new Date().getTime() > captchaTimeout) {
  59 + _.set(req.session, 'captchaValidCount', 5);
  60 + req.session.captcha = null;
  61 + return res.json({
  62 + code: 400,
  63 + message: '验证码超时,请重试',
  64 + changeCaptcha: true,
  65 + captchaShow: true
  66 + });
  67 + }
55 68
56 let errorCount = _.get(req.session, 'captchaValidCount'); // 初始1次 + 后续4次, 同一个验证码 共5次 69 let errorCount = _.get(req.session, 'captchaValidCount'); // 初始1次 + 后续4次, 同一个验证码 共5次
57 70
@@ -117,8 +117,29 @@ const common = { @@ -117,8 +117,29 @@ const common = {
117 return next(); 117 return next();
118 }); 118 });
119 } 119 }
120 - } 120 + },
  121 + isLoginUser: (req, res, next) => {
  122 + // 微信里边已经登录的时候,不再跳转登录
  123 + if (req.user.uid) {
  124 + AuthHelper.profile(req.user.uid).then(function(result) {
  125 + if (result.code !== 200) {
  126 + return next();
  127 + }
  128 + let refer = req.query.refer || decodeURI(req.cookies.refer) || config.siteUrl;
121 129
  130 + if (/sign|login/.test(refer)) {
  131 + refer = `${config.siteUrl}/home`;
  132 + }
  133 +
  134 + refer = utils.refererLimit(refer);
  135 + return res.redirect(refer);
  136 + }).catch(() => {
  137 + return next();
  138 + });
  139 + } else {
  140 + return next();
  141 + }
  142 + }
122 }; 143 };
123 144
124 145
@@ -280,19 +301,6 @@ const local = { @@ -280,19 +301,6 @@ const local = {
280 301
281 const wechat = { 302 const wechat = {
282 login: (req, res, next) => { 303 login: (req, res, next) => {
283 - // 微信里边已经登录的时候,不再跳转登录  
284 - // 与 5.6 的 session 有冲突  
285 - // if (req.user.uid) {  
286 - // let refer = req.query.refer || decodeURI(req.cookies.refer) || config.siteUrl;  
287 -  
288 - // if (/sign|login/.test(refer)) {  
289 - // refer = `${config.siteUrl}/home`;  
290 - // }  
291 -  
292 - // refer = utils.refererLimit(refer);  
293 - // return res.redirect(refer);  
294 - // }  
295 -  
296 // 设置为原链接标识originalUrl 304 // 设置为原链接标识originalUrl
297 req.session.originalUrl = 'true'; 305 req.session.originalUrl = 'true';
298 req.session.authState = uuid.v4(); 306 req.session.authState = uuid.v4();
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-04-13 10:21:07 3 * @Date: 2017-04-13 10:21:07
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-04-20 18:33:48 5 + * @Last Modified time: 2017-04-24 10:52:08
6 */ 6 */
7 7
8 /* ******************** 8 /* ********************
@@ -49,9 +49,9 @@ const passwordResetPage = (req, res) => { @@ -49,9 +49,9 @@ const passwordResetPage = (req, res) => {
49 */ 49 */
50 const passwordReset = (req, res, next) => { 50 const passwordReset = (req, res, next) => {
51 let passwordWeakObj = req.session.passwordWeak; 51 let passwordWeakObj = req.session.passwordWeak;
52 - let uid = req.user && req.user.uid || passwordWeakObj.uid; 52 + let uid = (req.user && req.user.uid) || (passwordWeakObj && passwordWeakObj.uid);
53 53
54 - if (!uid || !passwordWeakObj.token) { 54 + if (!uid || !passwordWeakObj || !passwordWeakObj.token) {
55 return res.json({ 55 return res.json({
56 code: 400, 56 code: 400,
57 massage: '非法请求' 57 massage: '非法请求'
@@ -75,7 +75,7 @@ router.post('/passport/sms_login/password.json', smsLogin.password); @@ -75,7 +75,7 @@ router.post('/passport/sms_login/password.json', smsLogin.password);
75 router.get('/passport/login/user', login.user); 75 router.get('/passport/login/user', login.user);
76 76
77 // 微信登录 77 // 微信登录
78 -router.get('/passport/login/wechat', login.common.beforeLogin, login.wechat.login); 78 +router.get('/passport/login/wechat', login.common.beforeLogin, login.common.isLoginUser, login.wechat.login);
79 router.get('/passport/login/wechat/callback', login.wechat.callback); 79 router.get('/passport/login/wechat/callback', login.wechat.callback);
80 80
81 // sina登录 81 // sina登录
@@ -134,6 +134,7 @@ router.get('/passport/back/mobile', validateCode.load, back.indexMobilePage);// @@ -134,6 +134,7 @@ router.get('/passport/back/mobile', validateCode.load, back.indexMobilePage);//
134 router.get('/passport/back/mobilecode', back.verifyCodeByMobilePage);// 输入手机验证码页面 134 router.get('/passport/back/mobilecode', back.verifyCodeByMobilePage);// 输入手机验证码页面
135 router.get('/passport/back/generatecodeimg.png', back.generateCodeImg);// 生成图片验证码 135 router.get('/passport/back/generatecodeimg.png', back.generateCodeImg);// 生成图片验证码
136 router.post('/passport/back/sendcode', validateCode.check, back.sendCodeToMobileAPI);// 发送手机验证码 136 router.post('/passport/back/sendcode', validateCode.check, back.sendCodeToMobileAPI);// 发送手机验证码
  137 +router.post('/passport/back/sendcodeagain', back.verifySmsAllow, back.sendCodeToMobileAPI);// 重新发送手机验证码
137 router.post('/passport/back/verifycode', back.verifyCodeByMobileAPI);// 校验手机验证码 138 router.post('/passport/back/verifycode', back.verifyCodeByMobileAPI);// 校验手机验证码
138 139
139 router.get('/passport/back/backcode', back.setNewPasswordByMobilePage);// 设置新密码页面 140 router.get('/passport/back/backcode', back.setNewPasswordByMobilePage);// 设置新密码页面
@@ -224,7 +224,7 @@ const shop = { @@ -224,7 +224,7 @@ const shop = {
224 } 224 }
225 225
226 /* 红人店铺直接跳转 */ 226 /* 红人店铺直接跳转 */
227 - if (shopInfoResult.is_red_shop) { 227 + if (shopInfoResult && shopInfoResult.is_red_shop) {
228 shop.redShop(req, res, next); 228 shop.redShop(req, res, next);
229 return false; 229 return false;
230 } 230 }
@@ -439,6 +439,8 @@ const shop = { @@ -439,6 +439,8 @@ const shop = {
439 shop_id: shopId, 439 shop_id: shopId,
440 title: '全部商品' 440 title: '全部商品'
441 }, 'list'), 441 }, 'list'),
  442 + appPath: 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.shop","params":{"shop_template_type":"1","is_red_shop":"1","shop_id":"' +
  443 + shopId + '","shop_name":"' + shopInfo.shop_name + '"}}',
442 shopHeadHide: true, 444 shopHeadHide: true,
443 shopPage: true, 445 shopPage: true,
444 width750: true, 446 width750: true,
@@ -7,11 +7,17 @@ @@ -7,11 +7,17 @@
7 7
8 const newsaleModel = require('../models/newsale'); 8 const newsaleModel = require('../models/newsale');
9 const headerModel = require('../../../doraemon/models/header'); 9 const headerModel = require('../../../doraemon/models/header');
  10 +
  11 +let yhchannels = {
  12 + '1,3': 1,
  13 + '2,3': 2
  14 +};
  15 +
10 let channels = { 16 let channels = {
11 - boys: '1,3',  
12 - girl: '2,3',  
13 - kids: '1,2,3',  
14 - lifestyle: '1,2,3' 17 + boys: 1,
  18 + girls: 2,
  19 + kids: 3,
  20 + lifestyle: 4
15 }; 21 };
16 22
17 const index = (req, res, next) => { 23 const index = (req, res, next) => {
@@ -56,10 +62,10 @@ const selectHotrank = (req, res, next) => { @@ -56,10 +62,10 @@ const selectHotrank = (req, res, next) => {
56 let limit = 50; 62 let limit = 50;
57 let page = req.query.page || 1; 63 let page = req.query.page || 1;
58 let notab = req.query.notab || 0; 64 let notab = req.query.notab || 0;
59 - let yhChannel = req.query.yh_channel || 1;  
60 - let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3'; 65 + let yhChannel = (req.query.gender && yhchannels[req.query.gender]) ||
  66 + (req.cookies._Channel && channels[req.cookies._Channel]) || 1;
61 67
62 - newsaleModel.selectHotrank(yhChannel, gender, sort, tab_id, limit, page, notab).then((result) => { 68 + newsaleModel.selectHotrank(yhChannel, sort, tab_id, limit, page, notab).then((result) => {
63 69
64 res.render('newsale/hotlist', { 70 res.render('newsale/hotlist', {
65 layout: false, 71 layout: false,
@@ -33,6 +33,11 @@ const _getUserProfile = (uid) => { @@ -33,6 +33,11 @@ const _getUserProfile = (uid) => {
33 uid: uid 33 uid: uid
34 }, { 34 }, {
35 cache: true 35 cache: true
  36 + }).catch(function() {
  37 + return {
  38 + code: 200,
  39 + data: {}
  40 + };
36 }); 41 });
37 }; 42 };
38 43
@@ -11,6 +11,7 @@ const helpers = global.yoho.helpers; @@ -11,6 +11,7 @@ const helpers = global.yoho.helpers;
11 const api = global.yoho.API; 11 const api = global.yoho.API;
12 const searchModel = require('./search'); 12 const searchModel = require('./search');
13 const productProcess = require(`${utils}/product-process`); 13 const productProcess = require(`${utils}/product-process`);
  14 +const stringProcess = require(`${global.utils}/string-process`);
14 15
15 /** 16 /**
16 * 频道 17 * 频道
@@ -122,14 +123,22 @@ const _getShopDecorator = (shopId) => { @@ -122,14 +123,22 @@ const _getShopDecorator = (shopId) => {
122 * @return array 123 * @return array
123 */ 124 */
124 const _getShopInfo = (shopId, uid) => { 125 const _getShopInfo = (shopId, uid) => {
125 - if (uid === 'undefined') {  
126 - uid = 0;  
127 - }  
128 - return api.get('', { 126 + let finalParams = {
129 method: 'app.shops.getIntro', 127 method: 'app.shops.getIntro',
130 shop_id: shopId, 128 shop_id: shopId,
131 - uid: uid || 0  
132 - }, {code: 200}).then((result) => { 129 + };
  130 +
  131 + if (!shopId || !stringProcess.isNumeric(shopId)) {
  132 + return Promise.resolve({});
  133 + }
  134 +
  135 + if (uid && uid !== 'undefined') {
  136 + Object.assign(finalParams, {
  137 + uid: uid
  138 + });
  139 + }
  140 +
  141 + return api.get('', finalParams, {code: 200}).then((result) => {
133 return result && result.data; 142 return result && result.data;
134 }); 143 });
135 }; 144 };
@@ -144,6 +153,10 @@ const getShopIntro = (shopId, uid) => { @@ -144,6 +153,10 @@ const getShopIntro = (shopId, uid) => {
144 shop_id: shopId 153 shop_id: shopId
145 }; 154 };
146 155
  156 + if (!shopId || !stringProcess.isNumeric(shopId)) {
  157 + return Promise.resolve({});
  158 + }
  159 +
147 if (uid && uid !== 'undefined') { 160 if (uid && uid !== 'undefined') {
148 params.uid = uid; 161 params.uid = uid;
149 } 162 }
@@ -40,10 +40,9 @@ const getHotRank = (codeKey) => { @@ -40,10 +40,9 @@ const getHotRank = (codeKey) => {
40 }); 40 });
41 }; 41 };
42 42
43 -const selectHotrank = (yhChannel, gender, sort, tabId, limit, page, notab) => { 43 +const selectHotrank = (yhChannel, sort, tabId, limit, page, notab) => {
44 let param = { 44 let param = {
45 method: 'app.search.top', 45 method: 'app.search.top',
46 - gender: gender,  
47 yh_channel: yhChannel, 46 yh_channel: yhChannel,
48 page: page, 47 page: page,
49 limit: limit 48 limit: limit
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 5
6 const api = global.yoho.API; 6 const api = global.yoho.API;
7 const singleAPI = global.yoho.SingleAPI; 7 const singleAPI = global.yoho.SingleAPI;
  8 +const stringProcess = require(`${global.utils}/string-process`);
8 9
9 /** 10 /**
10 * 频道 11 * 频道
@@ -41,6 +42,10 @@ exports.getIntro = shopId => { @@ -41,6 +42,10 @@ exports.getIntro = shopId => {
41 shop_id: shopId 42 shop_id: shopId
42 }; 43 };
43 44
  45 + if (!shopId || !stringProcess.isNumeric(shopId)) {
  46 + return Promise.resolve({});
  47 + }
  48 +
44 return api.get('', params, {cache: true, code: 200}); 49 return api.get('', params, {cache: true, code: 200});
45 }; 50 };
46 51
@@ -77,12 +82,19 @@ exports.getShopCategory = (shopId, channel) => { @@ -77,12 +82,19 @@ exports.getShopCategory = (shopId, channel) => {
77 * 店铺收藏数量 82 * 店铺收藏数量
78 */ 83 */
79 exports.favCount = (shopId, uid, channel, udid) => { 84 exports.favCount = (shopId, uid, channel, udid) => {
80 - return singleAPI.get('favorite', { 85 + let finalParams = {
81 method: 'app.favorite.queryFavoriteCountByShopIds', 86 method: 'app.favorite.queryFavoriteCountByShopIds',
82 favIds: shopId, 87 favIds: shopId,
83 type: 'shop', 88 type: 'shop',
84 udid: udid, 89 udid: udid,
85 - uid: uid,  
86 physical_channel: yhChannel[channel], 90 physical_channel: yhChannel[channel],
87 - }); 91 + };
  92 +
  93 + if (uid) {
  94 + Object.assign(finalParams, {
  95 + uid: uid
  96 + });
  97 + }
  98 +
  99 + return singleAPI.get('favorite', finalParams);
88 }; 100 };
@@ -224,6 +224,11 @@ const _getUserProfile = (uid, params) => { @@ -224,6 +224,11 @@ const _getUserProfile = (uid, params) => {
224 uid: uid 224 uid: uid
225 }, { 225 }, {
226 cache: true 226 cache: true
  227 + }).catch(function() {
  228 + return {
  229 + code: 200,
  230 + data: {}
  231 + };
227 }); 232 });
228 }; 233 };
229 234
@@ -43,6 +43,9 @@ @@ -43,6 +43,9 @@
43 <div id="red-index" class="tab-panel red-shop-index active"> 43 <div id="red-index" class="tab-panel red-shop-index active">
44 <div class="shop-coupon coupon-group"></div> 44 <div class="shop-coupon coupon-group"></div>
45 {{> reds-shop/modules}} 45 {{> reds-shop/modules}}
  46 + <div id="indexGoodsContainer" class="goods-container">
  47 + <div class="default-goods container clearfix"></div>
  48 + </div>
46 <div class="all-goods"> 49 <div class="all-goods">
47 <a href="{{allGoodsUrl}}">点击查看全部商品</a> 50 <a href="{{allGoodsUrl}}">点击查看全部商品</a>
48 </div> 51 </div>
1 <div class="item"> 1 <div class="item">
2 <a {{#if link}}href="{{link}}"{{/if}}> 2 <a {{#if link}}href="{{link}}"{{/if}}>
3 {{#if isGood}} 3 {{#if isGood}}
4 - {{#ifor triple double}}  
5 - <img class="item-pic" src="{{image2 src w=235 h=314}}" alt=""> 4 + {{#ifor triple double single}}
  5 + {{#within index 3}}
  6 + <img class="item-pic" src="{{image2 src w=235 h=314}}">
  7 + {{^}}
  8 + <img class="item-pic lazy" data-original="{{image2 src w=235 h=314}}">
  9 + {{/within}}
6 {{/ifor}} 10 {{/ifor}}
7 {{^}} 11 {{^}}
8 - <img class="item-pic" src="{{image2 src}}" alt=""> 12 + {{#within index 3}}
  13 + <img class="item-pic" src="{{image2 src}}" alt="">
  14 + {{^}}
  15 + <img class="item-pic lazy" data-original="{{image2 src}}">
  16 + {{/within}}
9 {{/if}} 17 {{/if}}
10 </a> 18 </a>
11 19
@@ -15,13 +15,13 @@ @@ -15,13 +15,13 @@
15 <ul class="swiper-wrapper"> 15 <ul class="swiper-wrapper">
16 {{#each ../pics}} 16 {{#each ../pics}}
17 <li class="swiper-slide"> 17 <li class="swiper-slide">
18 - {{#if link}}  
19 - <a href="{{link}}"> 18 + <a{{#if link}} href="{{link}}"{{/if}}>
  19 + {{#within @../index 3}}
20 <img src="{{image2 src}}" alt=""> 20 <img src="{{image2 src}}" alt="">
21 - </a>  
22 - {{^}}  
23 - <img src="{{image2 src}}" alt="">  
24 - {{/if}} 21 + {{^}}
  22 + <img class="lazy" data-original="{{image2 src}}" alt="">
  23 + {{/within}}
  24 + </a>
25 </li> 25 </li>
26 {{/each}} 26 {{/each}}
27 </ul> 27 </ul>
@@ -51,7 +51,7 @@ @@ -51,7 +51,7 @@
51 {{#isEqual module_type 'SingleImage'}} 51 {{#isEqual module_type 'SingleImage'}}
52 <div class="items-s1 clearfix"> 52 <div class="items-s1 clearfix">
53 {{#each ../pics}} 53 {{#each ../pics}}
54 - {{> reds-shop/item}} 54 + {{> reds-shop/item index=@../index single=true}}
55 {{/each}} 55 {{/each}}
56 </div> 56 </div>
57 {{#if ../isModuleMargin}} 57 {{#if ../isModuleMargin}}
@@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
61 {{#isEqual module_type 'DoubleImage'}} 61 {{#isEqual module_type 'DoubleImage'}}
62 <div class="items-s2 clearfix"> 62 <div class="items-s2 clearfix">
63 {{#each ../pics}} 63 {{#each ../pics}}
64 - {{> reds-shop/item double=true}} 64 + {{> reds-shop/item index=@../index double=true}}
65 {{/each}} 65 {{/each}}
66 </div> 66 </div>
67 {{#if ../isModuleMargin}} 67 {{#if ../isModuleMargin}}
@@ -71,7 +71,7 @@ @@ -71,7 +71,7 @@
71 {{#isEqual module_type 'TripleImage'}} 71 {{#isEqual module_type 'TripleImage'}}
72 <div class="{{#isEqual ../displayType 1}}items-3-3{{/isEqual}}{{#isEqual ../displayType 2}}items-3-3 items-small{{/isEqual}}{{#isEqual ../displayType 3}}items-3-2 items-3-2-right{{/isEqual}}{{#isEqual ../displayType 4}}items-3-2 items-3-2-left{{/isEqual}} clearfix"> 72 <div class="{{#isEqual ../displayType 1}}items-3-3{{/isEqual}}{{#isEqual ../displayType 2}}items-3-3 items-small{{/isEqual}}{{#isEqual ../displayType 3}}items-3-2 items-3-2-right{{/isEqual}}{{#isEqual ../displayType 4}}items-3-2 items-3-2-left{{/isEqual}} clearfix">
73 {{#each ../pics}} 73 {{#each ../pics}}
74 - {{> reds-shop/item triple=true}} 74 + {{> reds-shop/item index=@../index triple=true}}
75 {{/each}} 75 {{/each}}
76 </div> 76 </div>
77 {{#if ../isModuleMargin}} 77 {{#if ../isModuleMargin}}
@@ -81,14 +81,14 @@ @@ -81,14 +81,14 @@
81 {{#isEqual module_type 'FourImage'}} 81 {{#isEqual module_type 'FourImage'}}
82 <div class="items-s4 clearfix"> 82 <div class="items-s4 clearfix">
83 {{#each ../pics}} 83 {{#each ../pics}}
84 - {{> reds-shop/item four=true}} 84 + {{> reds-shop/item index=@../index four=true}}
85 {{/each}} 85 {{/each}}
86 </div> 86 </div>
87 {{#if ../isModuleMargin}} 87 {{#if ../isModuleMargin}}
88 <div class="margin-bottom"></div> 88 <div class="margin-bottom"></div>
89 {{/if}} 89 {{/if}}
90 {{/isEqual}} 90 {{/isEqual}}
91 - {{#isEqual module_type 'RecommentProduct'}} 91 + {{#isEqual module_type 'AppRecommendProduct'}}
92 <div class="index-goods-container" data-type="{{../type}}" data-skns="{{../skns}}" data-order="{{../order}}"></div> 92 <div class="index-goods-container" data-type="{{../type}}" data-skns="{{../skns}}" data-order="{{../order}}"></div>
93 {{#if ../isModuleMargin}} 93 {{#if ../isModuleMargin}}
94 <div class="margin-bottom"></div> 94 <div class="margin-bottom"></div>
@@ -56,12 +56,12 @@ const qaDetail = (params) => { @@ -56,12 +56,12 @@ const qaDetail = (params) => {
56 56
57 // 根据子id,父id,关键字,匹配问题详情 57 // 根据子id,父id,关键字,匹配问题详情
58 if (params.keyword) { 58 if (params.keyword) {
59 - // 从搜索列表进入,有关键字 59 + // 从搜索列表进入,有关键字
60 if (result && result[1] && result[1].data) { 60 if (result && result[1] && result[1].data) {
61 let keyList = result[1].data.helper_list; 61 let keyList = result[1].data.helper_list;
62 62
63 _.forEach(keyList, function(val) { 63 _.forEach(keyList, function(val) {
64 - if (val.id === params.sonId) { 64 + if (parseInt(val.id, 10) === parseInt(params.sonId, 10)) {
65 resu = { 65 resu = {
66 caption: val.caption, 66 caption: val.caption,
67 content: val.content 67 content: val.content
@@ -70,11 +70,11 @@ const qaDetail = (params) => { @@ -70,11 +70,11 @@ const qaDetail = (params) => {
70 }); 70 });
71 } 71 }
72 } else { 72 } else {
73 - // 常见问题没有parentId 73 + // 常见问题没有parentId
74 if (result && result[0] && result[0].data) { 74 if (result && result[0] && result[0].data) {
75 if (!params.parentId) { 75 if (!params.parentId) {
76 _.forEach(result[0].data.faqs, function(val) { 76 _.forEach(result[0].data.faqs, function(val) {
77 - if (val.id === params.sonId) { 77 + if (parseInt(val.id, 10) === parseInt(params.sonId, 10)) {
78 resu = { 78 resu = {
79 caption: val.caption, 79 caption: val.caption,
80 content: val.content 80 content: val.content
@@ -83,10 +83,10 @@ const qaDetail = (params) => { @@ -83,10 +83,10 @@ const qaDetail = (params) => {
83 }); 83 });
84 } else { 84 } else {
85 _.forEach(result[0].data.categorys, function(val) { 85 _.forEach(result[0].data.categorys, function(val) {
86 - if (val.id === params.parentId) { 86 + if (parseInt(val.id, 10) === parseInt(params.parentId, 10)) {
87 _.forEach(val.contentItems, function(item) { 87 _.forEach(val.contentItems, function(item) {
88 88
89 - if (item.id === params.sonId) { 89 + if (parseInt(item.id, 10) === parseInt(params.sonId, 10)) {
90 resu = { 90 resu = {
91 caption: item.caption, 91 caption: item.caption,
92 content: item.content 92 content: item.content
@@ -14,8 +14,8 @@ const domains = { @@ -14,8 +14,8 @@ const domains = {
14 liveApi: 'http://testapi.live.yohops.com:9999/', 14 liveApi: 'http://testapi.live.yohops.com:9999/',
15 singleApi: 'http://api-test3.yohops.com:9999/', 15 singleApi: 'http://api-test3.yohops.com:9999/',
16 16
17 - api: 'http://api.yoho.cn/',  
18 - service: 'http://service.yoho.cn/', 17 + api: 'http://api-test3.yohops.com:9999/',
  18 + service: 'http://service-test3.yohops.com:9999/',
19 global: 'http://api-global.yohobuy.com', 19 global: 'http://api-global.yohobuy.com',
20 20
21 // liveApi: 'http://api.live.yoho.cn/', 21 // liveApi: 'http://api.live.yoho.cn/',
@@ -51,6 +51,8 @@ exports.serverError = () => { @@ -51,6 +51,8 @@ exports.serverError = () => {
51 forceNoCache(res); 51 forceNoCache(res);
52 52
53 if (err && err.code === 401) { 53 if (err && err.code === 401) {
  54 + logger.error(`401 error info:client_type=${req.query.client_type},req.user=${JSON.stringify(req.user)},req.query=${JSON.stringify(req.query)},cookies=${JSON.stringify(req.cookies)}`); // eslint-disable-line
  55 +
54 if (req.xhr) { 56 if (req.xhr) {
55 return res.status(401).json(err); 57 return res.status(401).json(err);
56 } else if (req.yoho.isApp) { 58 } else if (req.yoho.isApp) {
@@ -48,7 +48,9 @@ module.exports = () => { @@ -48,7 +48,9 @@ module.exports = () => {
48 yoho.channel = channel; 48 yoho.channel = channel;
49 49
50 // 判断请求是否来自app 50 // 判断请求是否来自app
51 - yoho.isApp = req.query.app_version || req.query.appVersion || req.cookies.app_version; 51 + yoho.isApp = (req.query.app_version && req.query.app_version !== 'false') ||
  52 + (req.query.appVersion && req.query.appVersion !== 'false') ||
  53 + req.cookies.app_version;
52 yoho.isWechat = /micromessenger/i.test(req.get('User-Agent') || ''); 54 yoho.isWechat = /micromessenger/i.test(req.get('User-Agent') || '');
53 yoho.isWeibo = ua.indexOf('weibo') !== -1; 55 yoho.isWeibo = ua.indexOf('weibo') !== -1;
54 yoho.isqq = /MQQBrowser/i.test(req.get('User-Agent') || ''); 56 yoho.isqq = /MQQBrowser/i.test(req.get('User-Agent') || '');
@@ -6,33 +6,36 @@ const authcode = require('../../utils/authcode'); @@ -6,33 +6,36 @@ const authcode = require('../../utils/authcode');
6 6
7 module.exports = () => { 7 module.exports = () => {
8 return (req, res, next) => { 8 return (req, res, next) => {
9 - // 从 SESSION 中获取到当前登录用户的 UID  
10 - if (req.session && _.isNumber(req.session.LOGIN_UID)) {  
11 - // 调用接口传参时切勿使用toString获得字符串  
12 - req.user.uid = {  
13 - toString: () => {  
14 - return req.session.LOGIN_UID;  
15 - },  
16 - sessionKey: req.session.SESSION_KEY  
17 - };  
18 - let userData = _.get(req.session, 'USER', {});  
19 9
20 - _.merge(req.user, userData);  
21 - } 10 + if (!req.yoho.isApp) {
  11 + // 从 SESSION 中获取到当前登录用户的 UID
  12 + if (req.session && _.isNumber(req.session.LOGIN_UID)) {
  13 + // 调用接口传参时切勿使用toString获得字符串
  14 + req.user.uid = {
  15 + toString: () => {
  16 + return _.parseInt(req.session.LOGIN_UID);
  17 + },
  18 + sessionKey: req.session.SESSION_KEY
  19 + };
  20 + let userData = _.get(req.session, 'USER', {});
22 21
23 - // session 没有读取到的时候,从 cookie 读取 UID  
24 - if (!req.user.uid && req.cookies._UID) {  
25 - let sessionKey = req.cookies._SESSION_KEY && authcode(req.cookies._SESSION_KEY, '_SESSION_KEY', 2592000000); 22 + _.merge(req.user, userData);
  23 + }
26 24
27 - // 调用接口传参时切勿使用toString获得字符串  
28 - req.user.uid = {  
29 - toString: () => {  
30 - return cookie.getUid(req);  
31 - },  
32 - sessionKey  
33 - };  
34 - } 25 + // session 没有读取到的时候,从 cookie 读取 UID
  26 + if (!req.user.uid && req.cookies._UID) {
  27 + let sessionKey = req.cookies._SESSION_KEY &&
  28 + authcode(req.cookies._SESSION_KEY, '_SESSION_KEY', 2592000000);
35 29
  30 + // 调用接口传参时切勿使用toString获得字符串
  31 + req.user.uid = {
  32 + toString: () => {
  33 + return _.parseInt(cookie.getUid(req));
  34 + },
  35 + sessionKey
  36 + };
  37 + }
  38 + }
36 if (!req.user.uid && 39 if (!req.user.uid &&
37 req.cookies.app_uid && 40 req.cookies.app_uid &&
38 req.cookies.app_uid !== '0' && 41 req.cookies.app_uid !== '0' &&
@@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
57 <link rel="apple-touch-startup-image" sizes="320x460" href="http://static.yohobuy.com/m/v1/img/startup/startup.png" media="screen and (max-device-width: 320)"> 57 <link rel="apple-touch-startup-image" sizes="320x460" href="http://static.yohobuy.com/m/v1/img/startup/startup.png" media="screen and (max-device-width: 320)">
58 </head> 58 </head>
59 <body class="{{pageStyle}} {{#if isWechat}}wechat-body{{/if}} {{#if width750}}width750{{/if}} {{#if isPassportPage}}passport-body{{/if}} {{#if isStarIndexPage}}star-index-bg{{/if}} {{#if isStarDetailPage}}star-class-body{{/if}} {{#if isInstallmentPage}}installment-body{{/if}}"> 59 <body class="{{pageStyle}} {{#if isWechat}}wechat-body{{/if}} {{#if width750}}width750{{/if}} {{#if isPassportPage}}passport-body{{/if}} {{#if isStarIndexPage}}star-index-bg{{/if}} {{#if isStarDetailPage}}star-class-body{{/if}} {{#if isInstallmentPage}}installment-body{{/if}}">
60 - <div class="main-wrap" id="main-wrap" {{#if appPath}}data-apppath='{{appPath}}'{{/if}}> 60 + <div class="main-wrap" id="main-wrap" {{#if appPath}}data-apppath='{{{appPath}}}'{{/if}}>
61 {{#if systemUpdate}} 61 {{#if systemUpdate}}
62 {{> updata}} 62 {{> updata}}
63 {{/if}} 63 {{/if}}
@@ -75,8 +75,8 @@ @@ -75,8 +75,8 @@
75 }, 1000); 75 }, 1000);
76 }()); 76 }());
77 77
78 - /* tar add 190222 */  
79 - window._fxcmd = window._fxcmd || []; 78 + /* tar add 170426 品众代码去除 */
  79 + {{!--window._fxcmd = window._fxcmd || [];
80 _fxcmd.sid = 'bb3b16fa1106a6ab8619da0095755f32'; 80 _fxcmd.sid = 'bb3b16fa1106a6ab8619da0095755f32';
81 _fxcmd.trackAll = false; 81 _fxcmd.trackAll = false;
82 // 参数配置(可选)... 82 // 参数配置(可选)...
@@ -89,7 +89,7 @@ @@ -89,7 +89,7 @@
89 _pzfx.src = '//static.w3t.cn/fx/1/1/fx.js'; 89 _pzfx.src = '//static.w3t.cn/fx/1/1/fx.js';
90 var sc = document.getElementsByTagName('script')[0]; 90 var sc = document.getElementsByTagName('script')[0];
91 sc.parentNode.insertBefore(_pzfx,sc); 91 sc.parentNode.insertBefore(_pzfx,sc);
92 - }, 1000); 92 + }, 1000);--}}
93 93
94 94
95 </script> 95 </script>
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "5.6.2", 3 + "version": "5.6.4",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -323,15 +323,15 @@ function submitOrder() { @@ -323,15 +323,15 @@ function submitOrder() {
323 }, true); 323 }, true);
324 } 324 }
325 325
326 - /* tar add 190222 */  
327 - if (window._fxcmd) {  
328 - window._fxcmd.push(['trackOrder', {  
329 - oid: res.data.order_code,  
330 - otp: res.data.order_amount,  
331 - u_info: cookie.get('_UID'),  
332 - u_type: cookie.get('_isNewUser') ? 1 : 0  
333 - }, []]);  
334 - } 326 + /* tar add 170426 品众代码去除 */
  327 + // if (window._fxcmd) {
  328 + // window._fxcmd.push(['trackOrder', {
  329 + // oid: res.data.order_code,
  330 + // otp: res.data.order_amount,
  331 + // u_info: cookie.get('_UID'),
  332 + // u_type: cookie.get('_isNewUser') ? 1 : 0
  333 + // }, []]);
  334 + // }
335 335
336 cookie.remove(['order-info', 'activity-info']); 336 cookie.remove(['order-info', 'activity-info']);
337 window.location.href = url; 337 window.location.href = url;
@@ -118,7 +118,7 @@ module.exports = function(useInRegister, useForBind, useForRelate) { @@ -118,7 +118,7 @@ module.exports = function(useInRegister, useForBind, useForRelate) {
118 118
119 $.ajax({ 119 $.ajax({
120 type: 'POST', 120 type: 'POST',
121 - url: (useForBind || useForRelate) ? '/passport/bind/sendBindMsg' : '/passport/' + urlMid + '/sendcode', 121 + url: (useForBind || useForRelate) ? '/passport/bind/sendBindMsg' : '/passport/' + urlMid + '/sendcodeagain',
122 data: { 122 data: {
123 phoneNum: phoneNum, 123 phoneNum: phoneNum,
124 areaCode: areaCode 124 areaCode: areaCode
@@ -6,6 +6,9 @@ @@ -6,6 +6,9 @@
6 let $ = require('yoho-jquery'), 6 let $ = require('yoho-jquery'),
7 ImgCheck = require('plugin/img-check'), 7 ImgCheck = require('plugin/img-check'),
8 tip = require('plugin/tip'); 8 tip = require('plugin/tip');
  9 +
  10 +let loading = require('plugin/loading');
  11 +
9 const validType = { 12 const validType = {
10 IMG_CHECK: 1, 13 IMG_CHECK: 1,
11 GEETEST: 2 14 GEETEST: 2
@@ -94,7 +97,9 @@ class Validate { @@ -94,7 +97,9 @@ class Validate {
94 } 97 }
95 return Promise.resolve({captcha}); 98 return Promise.resolve({captcha});
96 } else { 99 } else {
  100 + loading.showLoadingMask();
97 return new Promise((resolve) => { 101 return new Promise((resolve) => {
  102 + loading.hideLoadingMask();
98 this.$container.removeClass('hide'); 103 this.$container.removeClass('hide');
99 this.captchaObj.onSuccess(() => { 104 this.captchaObj.onSuccess(() => {
100 resolve(this.captchaObj.getValidate()); 105 resolve(this.captchaObj.getValidate());
1 let $ = require('yoho-jquery'), 1 let $ = require('yoho-jquery'),
2 Swiper = require('yoho-swiper'), 2 Swiper = require('yoho-swiper'),
3 lazyLoad = require('yoho-jquery-lazyload'), 3 lazyLoad = require('yoho-jquery-lazyload'),
4 - loading = require('plugin/loading'); 4 + loading = require('plugin/loading'),
  5 + qs = require('yoho-qs');
5 6
6 let page = 1, 7 let page = 1,
7 winH, 8 winH,
@@ -34,7 +35,8 @@ function hotrank(pageIndex, sortIndex, tabId, noTab) { @@ -34,7 +35,8 @@ function hotrank(pageIndex, sortIndex, tabId, noTab) {
34 data: { 35 data: {
35 page: pageIndex, 36 page: pageIndex,
36 tab_id: tabId, 37 tab_id: tabId,
37 - notab: noTab 38 + notab: noTab,
  39 + gender: qs.gender
38 }, 40 },
39 success: function(data) { 41 success: function(data) {
40 if (data === ' ') { 42 if (data === ' ') {
@@ -2,19 +2,64 @@ @@ -2,19 +2,64 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-03-23 11:31:51 3 * @Date: 2017-03-23 11:31:51
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-04-14 11:17:55 5 + * @Last Modified time: 2017-05-02 11:17:31
6 */ 6 */
7 7
8 /** ***************** 8 /** *****************
9 * 红人店铺首页 9 * 红人店铺首页
10 ********************/ 10 ********************/
11 const Swiper2 = require('yoho-swiper2'); 11 const Swiper2 = require('yoho-swiper2');
  12 +const lazyLoad = require('yoho-jquery-lazyload');
12 let tip = require('../../plugin/tip'); 13 let tip = require('../../plugin/tip');
13 let $goodsContainer = $('.index-goods-container'); 14 let $goodsContainer = $('.index-goods-container');
  15 +let $indexGoodsContaniner = $('#indexGoodsContainer');
14 let $collect = $('#collect'); 16 let $collect = $('#collect');
15 17
16 const shopId = $('#shopId').val(); 18 const shopId = $('#shopId').val();
17 19
  20 +lazyLoad($('.lazy'));
  21 +
  22 +/**
  23 + * 异步检测是否已经收藏
  24 + */
  25 +$.ajax({
  26 + type: 'GET',
  27 + url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
  28 + xhrFields: {
  29 + withCredentials: true
  30 + },
  31 + data: {
  32 + shopId: shopId
  33 + },
  34 + success: function(data) {
  35 + if (data.collect) {
  36 + $collect.attr('class', 'already-collect pull-left');
  37 + }
  38 + },
  39 + error: function() {
  40 + tip.show('网络断开连接了~');
  41 + }
  42 +});
  43 +
  44 +/**
  45 + * 店铺轮播图
  46 + */
  47 +if ($('.shop-swiper')) {
  48 + let num = $('.shop-swiper').length;
  49 +
  50 + for (let i = 1; i <= num; i++) {
  51 + new Swiper2('.shop-swiper-' + i, {
  52 + lazyLoading: true,
  53 + lazyLoadingInPrevNext: true,
  54 + loop: true,
  55 + autoplay: 3000,
  56 + slideElement: 'li',
  57 + paginationClickable: true,
  58 + pagination: $(this).closest('.shop-swiper-' + i).find('.pagination-inner').get(0)
  59 + });
  60 + }
  61 +}
  62 +
18 /** 63 /**
19 * 异步加载推荐商品 64 * 异步加载推荐商品
20 */ 65 */
@@ -47,51 +92,33 @@ $.each($goodsContainer, function(index, elem) { @@ -47,51 +92,33 @@ $.each($goodsContainer, function(index, elem) {
47 }, 92 },
48 data: data, 93 data: data,
49 success: function(result) { 94 success: function(result) {
50 - $(elem).html(result); 95 + let $result = $(result);
  96 +
  97 + lazyLoad($result.find('img[class=lazy]'));
  98 + $(elem).html($result);
51 } 99 }
52 }); 100 });
53 }); 101 });
54 102
55 /** 103 /**
56 - * 异步检测是否已经收藏 104 + * 异步加载首页全部商品
57 */ 105 */
58 $.ajax({ 106 $.ajax({
59 type: 'GET', 107 type: 'GET',
60 - url: location.protocol + '//m.yohobuy.com/product/index/shopFav', 108 + url: '/product/search/search',
61 xhrFields: { 109 xhrFields: {
62 withCredentials: true 110 withCredentials: true
63 }, 111 },
64 data: { 112 data: {
65 - shopId: shopId 113 + shop_id: shopId
66 }, 114 },
67 - success: function(data) {  
68 - if (data.collect) {  
69 - $collect.attr('class', 'already-collect pull-left');  
70 - }  
71 - },  
72 - error: function() {  
73 - tip.show('网络断开连接了~');  
74 - }  
75 -}); 115 + success: function(result) {
  116 + let $result = $(result);
76 117
77 -/**  
78 - * 店铺轮播图  
79 - */  
80 -if ($('.shop-swiper')) {  
81 - let num = $('.shop-swiper').length;  
82 -  
83 - for (let i = 1; i <= num; i++) {  
84 - new Swiper2('.shop-swiper-' + i, {  
85 - lazyLoading: true,  
86 - lazyLoadingInPrevNext: true,  
87 - loop: true,  
88 - autoplay: 3000,  
89 - slideElement: 'li',  
90 - paginationClickable: true,  
91 - pagination: $(this).closest('.shop-swiper-' + i).find('.pagination-inner').get(0)  
92 - }); 118 + lazyLoad($result.find('img[class=lazy]'));
  119 + $indexGoodsContaniner.find('.container').html($result);
93 } 120 }
94 -} 121 +});
95 122
96 /** 123 /**
97 * 店铺收藏取消收藏操作 124 * 店铺收藏取消收藏操作
@@ -53,6 +53,8 @@ body { @@ -53,6 +53,8 @@ body {
53 53
54 .goods-container { 54 .goods-container {
55 overflow: hidden; 55 overflow: hidden;
  56 + background-color: #fff;
  57 + padding-left: 15px;
56 58
57 .goods-box { 59 .goods-box {
58 .no-result { 60 .no-result {
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-03-23 17:12:53 3 * @Date: 2017-03-23 17:12:53
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-04-20 10:19:41 5 + * @Last Modified time: 2017-04-25 15:54:23
6 */ 6 */
7 // 红人店铺首页 7 // 红人店铺首页
8 8
@@ -230,16 +230,29 @@ @@ -230,16 +230,29 @@
230 230
231 /* 四张小图 */ 231 /* 四张小图 */
232 .items-s4 { 232 .items-s4 {
  233 + border-bottom: 1px solid #e0e0e0;
  234 +
233 .item { 235 .item {
234 float: left; 236 float: left;
235 width: 25%; 237 width: 25%;
  238 + border-top: 1px solid #e0e0e0;
  239 + border-right: 1px solid #e0e0e0;
  240 + }
  241 +
  242 + .item:last-child {
  243 + border-right: none;
236 } 244 }
237 245
238 .item-info { 246 .item-info {
239 text-align: center; 247 text-align: center;
  248 + background-color: #f5f7f6;
240 color: #000; 249 color: #000;
241 position: relative; 250 position: relative;
242 251
  252 + .text {
  253 + line-height: 36px;
  254 + }
  255 +
243 .name, 256 .name,
244 .price { 257 .price {
245 display: none; 258 display: none;
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-03-23 11:02:31 3 * @Date: 2017-03-23 11:02:31
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-04-20 15:41:44 5 + * @Last Modified time: 2017-05-02 11:09:37
6 */ 6 */
7 /* 红人店铺数据处理 */ 7 /* 红人店铺数据处理 */
8 8
@@ -174,14 +174,14 @@ const _tools = { @@ -174,14 +174,14 @@ const _tools = {
174 }, 174 },
175 175
176 /** 176 /**
177 - * 商品列表 177 + * 推荐商品列表
178 * @param {*} moduleData 178 * @param {*} moduleData
179 */ 179 */
180 - recommentProduct(moduleData) { 180 + appRecommendProduct(moduleData) {
181 let displayType = _.parseInt(_.get(moduleData, 'properties.displayType', 0)); 181 let displayType = _.parseInt(_.get(moduleData, 'properties.displayType', 0));
182 182
183 let result = { 183 let result = {
184 - module_type: 'RecommentProduct', 184 + module_type: 'AppRecommendProduct',
185 type: displayType 185 type: displayType
186 }; 186 };
187 187
@@ -206,10 +206,7 @@ const _tools = { @@ -206,10 +206,7 @@ const _tools = {
206 break; 206 break;
207 } 207 }
208 208
209 - return {  
210 - module_type: 'RecommentProduct',  
211 - skns: skns,  
212 - }; 209 + return result;
213 } 210 }
214 }; 211 };
215 212
@@ -256,8 +253,8 @@ const floor = (decoratorsData) => { @@ -256,8 +253,8 @@ const floor = (decoratorsData) => {
256 case 'SknList': 253 case 'SknList':
257 skns = _.get(value, 'module_data.data').join(','); 254 skns = _.get(value, 'module_data.data').join(',');
258 break; 255 break;
259 - case 'RecommentProduct':  
260 - decorators.push(_tools.recommentProduct(value.module_data)); 256 + case 'AppRecommendProduct':
  257 + decorators.push(_tools.appRecommendProduct(value.module_data));
261 break; 258 break;
262 default: 259 default:
263 break; 260 break;
@@ -339,8 +336,11 @@ const pushGoodsInfo = (decorators, goodsList) => { @@ -339,8 +336,11 @@ const pushGoodsInfo = (decorators, goodsList) => {
339 decorators[key].pics[subKey].marketPrice = marketPrice ? '¥' + marketPrice : ''; 336 decorators[key].pics[subKey].marketPrice = marketPrice ? '¥' + marketPrice : '';
340 decorators[key].pics[subKey].isGood = true; 337 decorators[key].pics[subKey].isGood = true;
341 338
342 - if (value.module_type === 'TripleImage' || value.module_type === 'DoubleImage') {  
343 - decorators[key].pics[subKey].src = imageSrc; 339 + if (value.module_type === 'TripleImage' ||
  340 + value.module_type === 'DoubleImage' ||
  341 + value.module_type === 'SingleImage') {
  342 +
  343 + // decorators[key].pics[subKey].src = imageSrc; // 为了和 APP 统一,图暂时不取商品图
344 } else if (value.module_type === 'FourImage') { 344 } else if (value.module_type === 'FourImage') {
345 decorators[key].pics[subKey].isGood = false; 345 decorators[key].pics[subKey].isGood = false;
346 } else { 346 } else {