Authored by 郭成尧

Merge branch 'master' into feature/reds

@@ -73,7 +73,6 @@ app.use(global.yoho.hbs({ @@ -73,7 +73,6 @@ app.use(global.yoho.hbs({
73 helpers: _.assign(global.yoho.helpers, require('./utils/helpers')) 73 helpers: _.assign(global.yoho.helpers, require('./utils/helpers'))
74 })); 74 }));
75 75
76 -app.use(global.yoho.middleware());  
77 76
78 app.use(bodyParser.json()); 77 app.use(bodyParser.json());
79 app.use(bodyParser.urlencoded({ 78 app.use(bodyParser.urlencoded({
@@ -149,6 +148,17 @@ app.use((req, res, next) => { @@ -149,6 +148,17 @@ app.use((req, res, next) => {
149 req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等 148 req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等
150 req.app.locals.wap = app.locals.wap; // zookeper对象赋值 149 req.app.locals.wap = app.locals.wap; // zookeper对象赋值
151 150
  151 + // 临时增加错误日志记录
  152 + let sendJson = res.json;
  153 +
  154 + res.json = function(...args) {
  155 + try {
  156 + sendJson(...args);
  157 + } catch (e) {
  158 + logger.error(`res.json error data: ${JSON.stringify(args)}`);
  159 + }
  160 + };
  161 +
152 next(); 162 next();
153 }); 163 });
154 164
@@ -31,4 +31,4 @@ exports.sidebar = function(req, res, next) { @@ -31,4 +31,4 @@ exports.sidebar = function(req, res, next) {
31 layout: false 31 layout: false
32 }); 32 });
33 }).catch(next); 33 }).catch(next);
34 -}  
  34 +};
@@ -373,7 +373,7 @@ const order = (params) => { @@ -373,7 +373,7 @@ const order = (params) => {
373 code: 200 373 code: 200
374 }).then((result) => { 374 }).then((result) => {
375 375
376 - if (result.data) { 376 + if (result && result.data) {
377 Object.assign(finalResult, {cancelReason: result.data}); 377 Object.assign(finalResult, {cancelReason: result.data});
378 } 378 }
379 return finalResult; 379 return finalResult;
@@ -385,7 +385,7 @@ const order = (params) => { @@ -385,7 +385,7 @@ const order = (params) => {
385 * @param params 385 * @param params
386 */ 386 */
387 const getOrders = (params) => { 387 const getOrders = (params) => {
388 - let finalResult = Promise.resolve([]); 388 + let finalResult = [];
389 389
390 if (!params.uid) { 390 if (!params.uid) {
391 return Promise.resolve([]); 391 return Promise.resolve([]);
@@ -182,7 +182,6 @@ exports.orderSub = (req, res, next) => { @@ -182,7 +182,6 @@ exports.orderSub = (req, res, next) => {
182 let yohoCoin = req.body.yohoCoin || 0; 182 let yohoCoin = req.body.yohoCoin || 0;
183 let skuList = req.body.skuList || ''; 183 let skuList = req.body.skuList || '';
184 let orderInfo; 184 let orderInfo;
185 - let isWechat = req.yoho.isWechat;  
186 185
187 try { 186 try {
188 orderInfo = JSON.parse(req.cookies['order-info']); 187 orderInfo = JSON.parse(req.cookies['order-info']);
@@ -254,7 +253,15 @@ exports.orderSub = (req, res, next) => { @@ -254,7 +253,15 @@ exports.orderSub = (req, res, next) => {
254 253
255 return co(function* () { 254 return co(function* () {
256 let result; 255 let result;
257 - let ip = req.ip || ''; 256 +
  257 + // 接口需要的其他参数
  258 + let otherParams = {
  259 + unionKey: unionKey, // 友盟数据
  260 + userAgent: userAgent,
  261 + isWechat: req.yoho.isWechat,
  262 + ip: req.ip || '',
  263 + udid: req.cookies._yasvd || 'yoho'
  264 + };
258 265
259 /* tar modified 161206 套餐 */ 266 /* tar modified 161206 套餐 */
260 if (req.body.cartType === 'bundle') { 267 if (req.body.cartType === 'bundle') {
@@ -262,11 +269,11 @@ exports.orderSub = (req, res, next) => { @@ -262,11 +269,11 @@ exports.orderSub = (req, res, next) => {
262 269
263 result = yield cartModel.orderSub(uid, addressId, 'bundle', deliveryTimeId, 270 result = yield cartModel.orderSub(uid, addressId, 'bundle', deliveryTimeId,
264 deliveryId, invoices, paymentTypeId, paymentType, msg, couponCode, 271 deliveryId, invoices, paymentTypeId, paymentType, msg, couponCode,
265 - yohoCoin, null, unionKey, userAgent, times, activityInfo, ip, isWechat); 272 + yohoCoin, null, times, activityInfo, otherParams);
266 } else { 273 } else {
267 result = yield cartModel.orderSub(uid, addressId, cartType, deliveryTimeId, 274 result = yield cartModel.orderSub(uid, addressId, cartType, deliveryTimeId,
268 deliveryId, invoices, paymentTypeId, paymentType, msg, couponCode, 275 deliveryId, invoices, paymentTypeId, paymentType, msg, couponCode,
269 - yohoCoin, skuList, unionKey, userAgent, null, null, ip, isWechat); 276 + yohoCoin, skuList, null, null, otherParams);
270 } 277 }
271 278
272 // 提交成功清除Cookie 279 // 提交成功清除Cookie
@@ -180,23 +180,21 @@ exports.ticketsOrderCompute = (uid, productSku, buyNumber, yohoCoin) => { @@ -180,23 +180,21 @@ exports.ticketsOrderCompute = (uid, productSku, buyNumber, yohoCoin) => {
180 * @param string $couponCode 优惠券码 180 * @param string $couponCode 优惠券码
181 * @param mixed $yohoCoin 使用的有货币数量或为空 181 * @param mixed $yohoCoin 使用的有货币数量或为空
182 * @param string $skuList 购买限购商品时需要传递的参数 182 * @param string $skuList 购买限购商品时需要传递的参数
183 - * @param string $qhyUnio 友盟有关信息  
184 * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息 183 * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息
185 * @param int $times 184 * @param int $times
186 * @param null $activityInfo 套餐数据 185 * @param null $activityInfo 套餐数据
187 - * @param isWechat 是否是微信商城 186 + * @param otherParams 其他参数
188 * @return array 接口返回的数据 187 * @return array 接口返回的数据
189 */ 188 */
190 exports.orderSub = (uid, addressId, cartType, deliveryTime, 189 exports.orderSub = (uid, addressId, cartType, deliveryTime,
191 deliveryWay, invoices, paymentId, paymentType, remark, 190 deliveryWay, invoices, paymentId, paymentType, remark,
192 - couponCode, yohoCoin, skuList, qhyUnio,  
193 - userAgent, times, activityInfo, ip, isWechat) => {  
194 - if (!qhyUnio) {  
195 - qhyUnio = ''; 191 + couponCode, yohoCoin, skuList, times, activityInfo, otherParams) => {
  192 + if (!otherParams.unionKey) {
  193 + otherParams.unionKey = '';
196 } 194 }
197 195
198 - if (!userAgent) {  
199 - userAgent = null; 196 + if (!otherParams.userAgent) {
  197 + otherParams.userAgent = null;
200 } 198 }
201 199
202 if (!times) { 200 if (!times) {
@@ -221,8 +219,7 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime, @@ -221,8 +219,7 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime,
221 219
222 return shoppingAPI.orderSub(uid, addressId, cartType, deliveryTime, 220 return shoppingAPI.orderSub(uid, addressId, cartType, deliveryTime,
223 deliveryWay, invoices, paymentId, paymentType, 221 deliveryWay, invoices, paymentId, paymentType,
224 - remark, couponCode, yohoCoin, skuList, qhyUnio,  
225 - userAgent, times, activityInfo, ip, isWechat).then(orderSubRes => { 222 + remark, couponCode, yohoCoin, skuList, times, activityInfo, otherParams).then(orderSubRes => {
226 let finalResult = {}; 223 let finalResult = {};
227 224
228 if (orderSubRes && orderSubRes.data && orderSubRes.data.is_hint === 'Y') { 225 if (orderSubRes && orderSubRes.data && orderSubRes.data.is_hint === 'Y') {
@@ -149,16 +149,15 @@ exports.checkTickets = (uid, productSku, buyNumber, useYohoCoin, yohoCoinMode) = @@ -149,16 +149,15 @@ exports.checkTickets = (uid, productSku, buyNumber, useYohoCoin, yohoCoinMode) =
149 * @param string $couponCode 优惠券码 149 * @param string $couponCode 优惠券码
150 * @param mixed $yohoCoin 使用的有货币数量或为空 150 * @param mixed $yohoCoin 使用的有货币数量或为空
151 * @param string $skuList 购买限购商品时需要传递的参数 151 * @param string $skuList 购买限购商品时需要传递的参数
152 - * @param string $qhyUnion 友盟有关信息  
153 * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息 152 * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息
154 * @param $times 153 * @param $times
155 * @param null $activityInfo 套餐信息 154 * @param null $activityInfo 套餐信息
156 - * @param isWechat 是否是微信商城 155 + * @param @param otherParams 其他参数
157 * @return array 接口返回的数据 156 * @return array 接口返回的数据
158 */ 157 */
159 exports.orderSub = (uid, addressId, cartType, deliveryTime, 158 exports.orderSub = (uid, addressId, cartType, deliveryTime,
160 deliveryWay, invoices, paymentId, paymentType, remark, couponCode, 159 deliveryWay, invoices, paymentId, paymentType, remark, couponCode,
161 - yohoCoin, skuList, qhyUnion, userAgent, times, activityInfo, ip, isWechat) => { 160 + yohoCoin, skuList, times, activityInfo, otherParams) => {
162 if (!activityInfo) { 161 if (!activityInfo) {
163 activityInfo = null; 162 activityInfo = null;
164 } 163 }
@@ -173,7 +172,8 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime, @@ -173,7 +172,8 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime,
173 payment_id: paymentId, 172 payment_id: paymentId,
174 payment_type: paymentType, 173 payment_type: paymentType,
175 remark: remark, 174 remark: remark,
176 - uid: uid 175 + uid: uid,
  176 + udid: otherParams.udid
177 }; 177 };
178 178
179 /* tar add 161130 结算优化 */ 179 /* tar add 161130 结算优化 */
@@ -223,19 +223,19 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime, @@ -223,19 +223,19 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime,
223 } 223 }
224 224
225 // 友盟有关信息的传递 225 // 友盟有关信息的传递
226 - if (qhyUnion) {  
227 - params.qhy_union = qhyUnion; 226 + if (otherParams.unionKey) {
  227 + params.qhy_union = otherParams.unionKey;
228 } 228 }
229 229
230 // 是否是微信商城 230 // 是否是微信商城
231 - if (isWechat) { 231 + if (otherParams.isWechat) {
232 params.client_type = 'wechat'; 232 params.client_type = 'wechat';
233 } 233 }
234 234
235 return api.post('', params, { 235 return api.post('', params, {
236 headers: { 236 headers: {
237 - 'X-Forwarded-For': ip || '',  
238 - 'User-Agent': userAgent 237 + 'X-Forwarded-For': otherParams.ip || '',
  238 + 'User-Agent': otherParams.userAgent
239 } 239 }
240 }); 240 });
241 }; 241 };
@@ -188,6 +188,7 @@ const addressModify = (req, res, next) => { @@ -188,6 +188,7 @@ const addressModify = (req, res, next) => {
188 */ 188 */
189 const changeAddress = (req, res, next) => { 189 const changeAddress = (req, res, next) => {
190 let uid = req.user.uid; 190 let uid = req.user.uid;
  191 + let udid = req.cookies._yasvd || 'yoho';
191 192
192 if (!uid) { 193 if (!uid) {
193 return res.json({ 194 return res.json({
@@ -202,7 +203,8 @@ const changeAddress = (req, res, next) => { @@ -202,7 +203,8 @@ const changeAddress = (req, res, next) => {
202 username: req.body.username, 203 username: req.body.username,
203 areaCode: req.body.area_code, 204 areaCode: req.body.area_code,
204 address: req.body.address, 205 address: req.body.address,
205 - mobile: req.body.mobile 206 + mobile: req.body.mobile,
  207 + udid: udid
206 }).then(result => { 208 }).then(result => {
207 res.json(result); 209 res.json(result);
208 }).catch(next); 210 }).catch(next);
@@ -374,7 +374,8 @@ const changeAddress = (params) => { @@ -374,7 +374,8 @@ const changeAddress = (params) => {
374 user_name: params.username, 374 user_name: params.username,
375 area_code: params.areaCode, 375 area_code: params.areaCode,
376 address: params.address, 376 address: params.address,
377 - mobile: params.mobile 377 + mobile: params.mobile,
  378 + udid: params.udid
378 }; 379 };
379 380
380 if (params.addressId) { 381 if (params.addressId) {
@@ -90,8 +90,8 @@ router.get('/helpDetail', help.helpDetail); @@ -90,8 +90,8 @@ router.get('/helpDetail', help.helpDetail);
90 // 意见反馈 90 // 意见反馈
91 router.get('/suggest', suggest.suggestData); 91 router.get('/suggest', suggest.suggestData);
92 router.post('/upAndDown', suggest.upAndDown); 92 router.post('/upAndDown', suggest.upAndDown);
93 -router.get('/suggestSub', suggest.suggestSub);  
94 -router.post('/savesuggest', suggest.saveSuggest); 93 +router.get('/suggestSub', auth, suggest.suggestSub);
  94 +router.post('/savesuggest', auth, suggest.saveSuggest);
95 95
96 // 消息 96 // 消息
97 router.use('/message', auth, disableBFCache, message.index); 97 router.use('/message', auth, disableBFCache, message.index);
@@ -81,7 +81,9 @@ const common = { @@ -81,7 +81,9 @@ const common = {
81 let passLogin = _.get(req, 'cookies._WX_PASS_LOGIN', false); 81 let passLogin = _.get(req, 'cookies._WX_PASS_LOGIN', false);
82 82
83 if (req.yoho.isWechat && !passLogin) { 83 if (req.yoho.isWechat && !passLogin) {
84 - return res.redirect('/passport/login/wechat'); 84 + return res.redirect(helpers.urlFormat('/passport/login/wechat', {
  85 + refer: req.query.refer || req.get('Referer') || '/'
  86 + }));
85 } 87 }
86 next(); 88 next();
87 }, 89 },
@@ -128,11 +130,13 @@ const local = { @@ -128,11 +130,13 @@ const local = {
128 // 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie 130 // 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie
129 // res.cookie('LE' + md5('_LOGIN_EXPIRE'), (new Date()).getTime() / 1000 + 1800); 131 // res.cookie('LE' + md5('_LOGIN_EXPIRE'), (new Date()).getTime() / 1000 + 1800);
130 132
  133 + // 170406 账户密码方式登录可以选择是否开启验证码,默认开关是关闭状态,此时开启验证码,开关开启,无需验证
  134 + let captchaShow = _.get(req.app.locals.wap, 'close.loginValidation', false);
131 135
132 res.render('login', { 136 res.render('login', {
133 width750: true, 137 width750: true,
134 loginIndex: true, // 模板中使用JS的标识 138 loginIndex: true, // 模板中使用JS的标识
135 - captchaShow: true, // 170306 因为暴力破解密码问题,要求每次都展示验证码 139 + captchaShow: !captchaShow, // 170306 因为暴力破解密码问题,要求每次都展示验证码
136 backUrl: 'javascript:history.go(-1)', // eslint-disable-line 140 backUrl: 'javascript:history.go(-1)', // eslint-disable-line
137 showHeaderImg: true, // 控制显示头部图片 141 showHeaderImg: true, // 控制显示头部图片
138 isPassportPage: true, // 模板中模块标识 142 isPassportPage: true, // 模板中模块标识
@@ -170,13 +174,14 @@ const local = { @@ -170,13 +174,14 @@ const local = {
170 // 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie 174 // 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie
171 // res.cookie('LE' + md5('_LOGIN_EXPIRE'), (new Date()).getTime() / 1000 + 1800); 175 // res.cookie('LE' + md5('_LOGIN_EXPIRE'), (new Date()).getTime() / 1000 + 1800);
172 176
173 - 177 + // 170406 账户密码方式登录可以选择是否开启验证码,默认开关是关闭状态,此时开启验证码,开关开启,无需验证
  178 + let captchaShow = _.get(req.app.locals.wap, 'close.loginValidation', false);
174 179
175 res.render('international', { 180 res.render('international', {
176 width750: true, 181 width750: true,
177 backUrl: 'javascript:history.go(-1)', // eslint-disable-line 182 backUrl: 'javascript:history.go(-1)', // eslint-disable-line
178 loginInternational: true, // 模板中使用JS的标识 183 loginInternational: true, // 模板中使用JS的标识
179 - captchaShow: true, // 170306 因为暴力破解密码问题,要求每次都展示验证码 184 + captchaShow: !captchaShow, // 170306 因为暴力破解密码问题,要求每次都展示验证码
180 isPassportPage: true, // 模板中模块标识 185 isPassportPage: true, // 模板中模块标识
181 headerText: '登录', 186 headerText: '登录',
182 areaCode: '+86', // 默认区号 187 areaCode: '+86', // 默认区号
@@ -250,6 +255,18 @@ const local = { @@ -250,6 +255,18 @@ const local = {
250 255
251 const wechat = { 256 const wechat = {
252 login: (req, res, next) => { 257 login: (req, res, next) => {
  258 + // 微信里边已经登录的时候,不再跳转登录
  259 + if (req.user.uid) {
  260 + let refer = req.query.refer || decodeURI(req.cookies.refer) || config.siteUrl;
  261 +
  262 + if (/sign|login/.test(refer)) {
  263 + refer = `${config.siteUrl}/home`;
  264 + }
  265 +
  266 + refer = utils.refererLimit(refer);
  267 + return res.redirect(refer);
  268 + }
  269 +
253 // 设置为原链接标识originalUrl 270 // 设置为原链接标识originalUrl
254 req.session.originalUrl = 'true'; 271 req.session.originalUrl = 'true';
255 req.session.authState = uuid.v4(); 272 req.session.authState = uuid.v4();
@@ -20,6 +20,11 @@ const check = (req, res, next) => { @@ -20,6 +20,11 @@ const check = (req, res, next) => {
20 return next(); 20 return next();
21 } 21 }
22 22
  23 + // 170406 采用账号密码方式登录验证码可以配置关闭,默认开关是关闭状态,这时需要验证,开关开启,无需验证
  24 + if (_.get(req.app.locals.wap, 'close.loginValidation', false) && req.path === '/passport/login/auth') {
  25 + return next();
  26 + }
  27 +
23 // 使用极验证 28 // 使用极验证
24 let useGeetest = !_.get(req.app.locals.wap, 'geetest.validation', false); 29 let useGeetest = !_.get(req.app.locals.wap, 'geetest.validation', false);
25 30
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 const _ = require('lodash'); 2 const _ = require('lodash');
3 const aes = require('./aes-pwd'); 3 const aes = require('./aes-pwd');
4 const authcode = require('../../../utils/authcode'); 4 const authcode = require('../../../utils/authcode');
  5 +const logger = global.yoho.logger;
5 const sign = global.yoho.sign; 6 const sign = global.yoho.sign;
6 const api = global.yoho.API; 7 const api = global.yoho.API;
7 const uuid = require('uuid'); 8 const uuid = require('uuid');
@@ -35,10 +36,13 @@ class Auth { @@ -35,10 +36,13 @@ class Auth {
35 param.shopping_key = shoppingKey; 36 param.shopping_key = shoppingKey;
36 } 37 }
37 38
  39 + logger.info(`${profile}, login from ${ip}`);
  40 +
38 return api.post('', param, { 41 return api.post('', param, {
39 headers: { 42 headers: {
40 'user-agent': 'yoho/nodejs', 43 'user-agent': 'yoho/nodejs',
41 - 'X-YOHO-IP': ip 44 + 'X-YOHO-IP': ip,
  45 + 'X-Forwarded-For': ip
42 } 46 }
43 }); 47 });
44 } 48 }
@@ -27,7 +27,7 @@ const router = express.Router(); // eslint-disable-line @@ -27,7 +27,7 @@ const router = express.Router(); // eslint-disable-line
27 router.get('/passport/geetest/register', geetest.register); 27 router.get('/passport/geetest/register', geetest.register);
28 28
29 // 兼容老的路由 29 // 兼容老的路由
30 -router.get('/signin.html', validateCode.load, login.common.weixinCheck, 30 +router.get('/signin.html', login.common.weixinCheck, validateCode.load,
31 login.common.beforeLogin, login.common.clearCookie, smsLogin.loginPage); 31 login.common.beforeLogin, login.common.clearCookie, smsLogin.loginPage);
32 router.get('/reg.html', validateCode.load, disableBFCahce, reg.index); 32 router.get('/reg.html', validateCode.load, disableBFCahce, reg.index);
33 router.get('/login.html', validateCode.load, 33 router.get('/login.html', validateCode.load,
@@ -78,10 +78,6 @@ router.get('/passport/login/qq/callback', login.qq.callback); @@ -78,10 +78,6 @@ router.get('/passport/login/qq/callback', login.qq.callback);
78 router.get('/passport/login/alipay', login.common.beforeLogin, login.alipay.login); 78 router.get('/passport/login/alipay', login.common.beforeLogin, login.alipay.login);
79 router.get('/passport/login/alipay/callback', login.alipay.callback); 79 router.get('/passport/login/alipay/callback', login.alipay.callback);
80 80
81 -// alipay登录  
82 -router.get('/login/alipay', login.common.beforeLogin, login.alipay.login);  
83 -router.get('/login/alipay/callback', login.alipay.callback);  
84 -  
85 // 登录绑定 81 // 登录绑定
86 router.get('/passport/bind/index', validateCode.load, bind.indexPage); 82 router.get('/passport/bind/index', validateCode.load, bind.indexPage);
87 router.post('/passport/bind/bindCheck', validateCode.check, bind.bindCheck); 83 router.post('/passport/bind/bindCheck', validateCode.check, bind.bindCheck);
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 <input id="pwd" class="pwd input" type="password" placeholder="密码"> 10 <input id="pwd" class="pwd input" type="password" placeholder="密码">
11 </div> 11 </div>
12 {{!--图片验证--}} 12 {{!--图片验证--}}
13 - <div data-geetest="{{useGeetest}}" id="js-img-check"></div> 13 + <div data-userverify="{{captchaShow}}" data-geetest="{{useGeetest}}" id="js-img-check"></div>
14 14
15 <span id="btn-login" class="btn btn-login disble row">登录</span> 15 <span id="btn-login" class="btn btn-login disble row">登录</span>
16 </div> 16 </div>
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 <input id="pwd" class="pwd input" type="password" placeholder="密码"> 9 <input id="pwd" class="pwd input" type="password" placeholder="密码">
10 </div> 10 </div>
11 {{!--图片验证--}} 11 {{!--图片验证--}}
12 - <div data-geetest="{{useGeetest}}" id="js-img-check"></div> 12 + <div data-userverify="{{captchaShow}}" data-geetest="{{useGeetest}}" id="js-img-check"></div>
13 <span id="btn-login" class="btn btn-login disable">登录</span> 13 <span id="btn-login" class="btn btn-login disable">登录</span>
14 <p class="op-container"> 14 <p class="op-container">
15 <a class="op-item internat" href={{internationalUrl}}>海外手机</a> 15 <a class="op-item internat" href={{internationalUrl}}>海外手机</a>
@@ -231,6 +231,7 @@ const category = (req, res, next) => { @@ -231,6 +231,7 @@ const category = (req, res, next) => {
231 order: '0', 231 order: '0',
232 page: 1, 232 page: 1,
233 limit: 12, 233 limit: 12,
  234 + isApp: params.app_version
234 }, params); 235 }, params);
235 236
236 if (uid) { 237 if (uid) {
@@ -13,8 +13,8 @@ const domains = { @@ -13,8 +13,8 @@ const domains = {
13 liveApi: 'http://testapi.live.yohops.com:9999/', 13 liveApi: 'http://testapi.live.yohops.com:9999/',
14 singleApi: 'http://api-test3.yohops.com:9999/', 14 singleApi: 'http://api-test3.yohops.com:9999/',
15 15
16 - api: 'http://api-test3.yohops.com:9999/',  
17 - service: 'http://service-test3.yohops.com:9999/', 16 + api: 'http://api.yoho.cn/',
  17 + service: 'http://service.yoho.cn/',
18 18
19 // liveApi: 'http://api.live.yoho.cn/', 19 // liveApi: 'http://api.live.yoho.cn/',
20 // singleApi: 'http://single.yoho.cn/', 20 // singleApi: 'http://single.yoho.cn/',
@@ -25,7 +25,7 @@ const domains = { @@ -25,7 +25,7 @@ const domains = {
25 25
26 module.exports = { 26 module.exports = {
27 app: 'h5', 27 app: 'h5',
28 - appVersion: '5.5.1', // 调用api的版本 28 + appVersion: '5.5.2', // 调用api的版本
29 port: 6001, 29 port: 6001,
30 siteUrl: '//m.yohobuy.com', 30 siteUrl: '//m.yohobuy.com',
31 assetUrl: '//127.0.0.1:5001', 31 assetUrl: '//127.0.0.1:5001',
@@ -67,11 +67,6 @@ module.exports = { @@ -67,11 +67,6 @@ module.exports = {
67 handleExceptions: true, 67 handleExceptions: true,
68 maxFiles: 7 68 maxFiles: 7
69 }, 69 },
70 - udp: { // send by udp  
71 - measurement: 'yohobuy_wap_node_log',  
72 - level: 'error', // logger level  
73 - port: '4444' // influxdb port  
74 - },  
75 console: { 70 console: {
76 level: 'info', 71 level: 'info',
77 colorize: 'all', 72 colorize: 'all',
@@ -22,7 +22,7 @@ module.exports = (req, res, next) => { @@ -22,7 +22,7 @@ module.exports = (req, res, next) => {
22 return next(); 22 return next();
23 } 23 }
24 24
25 - if (res.statusCode == 403) { 25 + if (_.toNumber(res.statusCode) === 403) {
26 return res.end(); 26 return res.end();
27 } 27 }
28 28
@@ -21,7 +21,11 @@ const _getClientIp = req => { @@ -21,7 +21,11 @@ const _getClientIp = req => {
21 remoteIp = _.trim(arr[arr.length - 1]); 21 remoteIp = _.trim(arr[arr.length - 1]);
22 } 22 }
23 23
24 - return remoteIp; 24 + if (_.startsWith(remoteIp, '10.66.')) {
  25 + remoteIp = req.get('X-Real-IP');
  26 + }
  27 +
  28 + return _.trim(remoteIp);
25 }; 29 };
26 30
27 module.exports = () => { 31 module.exports = () => {
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "5.5.11", 3 + "version": "5.5.12",
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": {
@@ -50,13 +50,14 @@ @@ -50,13 +50,14 @@
50 "xml2js": "^0.4.17", 50 "xml2js": "^0.4.17",
51 "yoho-express-session": "^2.0.0", 51 "yoho-express-session": "^2.0.0",
52 "yoho-md5": "^2.0.0", 52 "yoho-md5": "^2.0.0",
53 - "yoho-node-lib": "=0.2.11", 53 + "yoho-node-lib": "=0.2.16",
54 "yoho-zookeeper": "^1.0.8" 54 "yoho-zookeeper": "^1.0.8"
55 }, 55 },
56 "devDependencies": { 56 "devDependencies": {
57 "autoprefixer": "^6.7.4", 57 "autoprefixer": "^6.7.4",
58 "babel-core": "^6.24.0", 58 "babel-core": "^6.24.0",
59 "babel-loader": "^6.4.1", 59 "babel-loader": "^6.4.1",
  60 + "babel-polyfill": "^6.23.0",
60 "babel-preset-env": "^1.2.2", 61 "babel-preset-env": "^1.2.2",
61 "css-loader": "^0.27.3", 62 "css-loader": "^0.27.3",
62 "cssnano": "^3.10.0", 63 "cssnano": "^3.10.0",
@@ -66,7 +66,7 @@ const cssLoader = (env, type) => { @@ -66,7 +66,7 @@ const cssLoader = (env, type) => {
66 66
67 const getEntries = () => { 67 const getEntries = () => {
68 const entries = { 68 const entries = {
69 - libs: ['yoho-jquery'], 69 + libs: ['babel-polyfill', 'yoho-jquery'],
70 index: path.join(__dirname, '../scss/index.css'), 70 index: path.join(__dirname, '../scss/index.css'),
71 common: path.join(__dirname, '../scss/common.css'), 71 common: path.join(__dirname, '../scss/common.css'),
72 feature: path.join(__dirname, '../scss/feature.css') 72 feature: path.join(__dirname, '../scss/feature.css')
@@ -13,6 +13,7 @@ let $phoneNum = $('#phone-num'), @@ -13,6 +13,7 @@ let $phoneNum = $('#phone-num'),
13 $loginBtn = $('#btn-login'), 13 $loginBtn = $('#btn-login'),
14 14
15 $captcha = $('#js-img-check'), 15 $captcha = $('#js-img-check'),
  16 + useVerify = $captcha.data('userverify'), // 170406 是否使用验证
16 17
17 pnPass = false, 18 pnPass = false,
18 pwdPass = false; 19 pwdPass = false;
@@ -23,15 +24,18 @@ let tip = require('plugin/tip'); @@ -23,15 +24,18 @@ let tip = require('plugin/tip');
23 let trim = $.trim; 24 let trim = $.trim;
24 let showErrTip = tip.show; 25 let showErrTip = tip.show;
25 26
26 -let validate = new Validate($captcha, {  
27 - useREM: {  
28 - rootFontSize: 40,  
29 - picWidth: 150  
30 - }  
31 -}); 27 +let validate = {};
32 28
33 -validate.init(); 29 +if (useVerify) {
  30 + validate = new Validate($captcha, {
  31 + useREM: {
  32 + rootFontSize: 40,
  33 + picWidth: 150
  34 + }
  35 + });
34 36
  37 + validate.init();
  38 +}
35 39
36 // 登录按钮状态切换 40 // 登录按钮状态切换
37 function switchLoginBtnStatus() { 41 function switchLoginBtnStatus() {
@@ -45,6 +49,47 @@ function resetForm() { @@ -45,6 +49,47 @@ function resetForm() {
45 $loginBtn.text('登录').addClass('disable'); 49 $loginBtn.text('登录').addClass('disable');
46 } 50 }
47 51
  52 +/**
  53 + * 登录校验
  54 + */
  55 +function loginAuth(params) {
  56 + $.ajax({
  57 + type: 'POST',
  58 + url: '/passport/login/auth',
  59 + data: params,
  60 + success: function(data) {
  61 + let res;
  62 +
  63 + validate && validate.type === 2 && validate.refresh();
  64 + if (data.code === 200) {
  65 + res = data.data;
  66 + showErrTip('登录成功');
  67 +
  68 + // 3秒后强制跳转
  69 + setTimeout(() => {
  70 + location.href = res.href;
  71 + }, 1500);
  72 +
  73 + $loginBtn.text('登录成功');
  74 + showErrTip('登录成功');
  75 + } else {
  76 + if (useVerify && data.captchaShow) {
  77 + ((data.changeCaptcha && validate.type !== 2) && validate.refresh());
  78 + }
  79 +
  80 + showErrTip(data.message);
  81 + resetForm();
  82 + }
  83 + },
  84 + error: function() {
  85 + showErrTip('网络断开连接啦~');
  86 + $loginBtn.text('登录');
  87 +
  88 + validate && validate.refresh();
  89 + }
  90 + });
  91 +}
  92 +
48 // Android-UC下显示select的direction:rtl无效的临时解决办法 93 // Android-UC下显示select的direction:rtl无效的临时解决办法
49 api.selectCssHack($countrySelect); 94 api.selectCssHack($countrySelect);
50 95
@@ -90,52 +135,21 @@ $loginBtn.on('touchstart', function() { @@ -90,52 +135,21 @@ $loginBtn.on('touchstart', function() {
90 } 135 }
91 136
92 if ((api.phoneRegx[areaCode].test(pn) || areaCode !== '+86') && api.pwdValidate(pwd)) { 137 if ((api.phoneRegx[areaCode].test(pn) || areaCode !== '+86') && api.pwdValidate(pwd)) {
93 - validate.getResults().then((result) => {  
94 - $loginBtn.text('正在登录...').addClass('disable');  
95 - let params = {  
96 - areaCode: areaCode.replace('+', ''),  
97 - account: pn,  
98 - password: pwd  
99 - };  
100 -  
101 - $.extend(params, result);  
102 -  
103 - $.ajax({  
104 - type: 'POST',  
105 - url: '/passport/login/auth',  
106 - data: params,  
107 - success: function(data) {  
108 - let res;  
109 -  
110 - validate.type === 2 && validate.refresh();  
111 - if (data.code === 200) {  
112 - res = data.data;  
113 - showErrTip('登录成功');  
114 -  
115 - // 3秒后强制跳转  
116 - setTimeout(() => {  
117 - location.href = res.href;  
118 - }, 1500);  
119 -  
120 - $loginBtn.text('登录成功');  
121 - showErrTip('登录成功');  
122 - } else {  
123 - if (data.captchaShow) {  
124 - ((data.changeCaptcha && validate.type !== 2) && validate.refresh());  
125 - }  
126 -  
127 - showErrTip(data.message);  
128 - resetForm();  
129 - }  
130 - },  
131 - error: function() {  
132 - showErrTip('网络断开连接啦~');  
133 - $loginBtn.text('登录');  
134 -  
135 - validate.refresh();  
136 - } 138 + let params = {
  139 + areaCode: areaCode.replace('+', ''),
  140 + account: pn,
  141 + password: pwd
  142 + };
  143 +
  144 + if (useVerify) {
  145 + validate.getResults().then((result) => {
  146 + $loginBtn.text('正在登录...').addClass('disable');
  147 + $.extend(params, result);
  148 + loginAuth(params);
137 }); 149 });
138 - }); 150 + } else {
  151 + loginAuth(params);
  152 + }
139 } else { 153 } else {
140 showErrTip('账号或密码有错误,请重新输入'); 154 showErrTip('账号或密码有错误,请重新输入');
141 $loginBtn.text('登录').addClass('disable'); 155 $loginBtn.text('登录').addClass('disable');
@@ -14,6 +14,7 @@ let $account = $('#account'), @@ -14,6 +14,7 @@ let $account = $('#account'),
14 $ways = $('#retrive-pwd-ways'), 14 $ways = $('#retrive-pwd-ways'),
15 15
16 $captcha = $('#js-img-check'), 16 $captcha = $('#js-img-check'),
  17 + useVerify = $captcha.data('userverify'), // 170406 是否使用验证
17 18
18 accPass = false, 19 accPass = false,
19 pwdPass = false; 20 pwdPass = false;
@@ -25,14 +26,18 @@ let trim = $.trim; @@ -25,14 +26,18 @@ let trim = $.trim;
25 let showErrTip = tip.show; 26 let showErrTip = tip.show;
26 27
27 28
28 -let validate = new Validate($captcha, {  
29 - useREM: {  
30 - rootFontSize: 40,  
31 - picWidth: 150  
32 - }  
33 -}); 29 +let validate = {};
  30 +
  31 +if (useVerify) {
  32 + validate = new Validate($captcha, {
  33 + useREM: {
  34 + rootFontSize: 40,
  35 + picWidth: 150
  36 + }
  37 + });
34 38
35 -validate.init(); 39 + validate.init();
  40 +}
36 41
37 // 登录按钮状态切换 42 // 登录按钮状态切换
38 function switchLoginBtnStatus() { 43 function switchLoginBtnStatus() {
@@ -60,6 +65,62 @@ function hideRetrivePanel() { @@ -60,6 +65,62 @@ function hideRetrivePanel() {
60 $ways.hide(); 65 $ways.hide();
61 } 66 }
62 67
  68 +/**
  69 + * 登录校验
  70 + */
  71 +function loginAuth(params, acc) {
  72 + $.ajax({
  73 + type: 'POST',
  74 + url: '/passport/login/auth',
  75 + data: params,
  76 + success: function(data) {
  77 + let res,
  78 + LOGI_TYPE;
  79 +
  80 + if (acc.indexOf('@') > 0) {
  81 + LOGI_TYPE = 8;
  82 + } else {
  83 + LOGI_TYPE = 5;
  84 + }
  85 +
  86 + if (window._yas && window._yas.sendCustomInfo) {
  87 + window._yas.sendCustomInfo({
  88 + op: 'YB_MY_LOGIN_C',
  89 + param: JSON.stringify({
  90 + C_ID: window._ChannelVary[window.cookie('_Channel')],
  91 + LOGI_TYPE: LOGI_TYPE
  92 + })
  93 + }, true);
  94 + }
  95 + validate && validate.type === 2 && validate.refresh();
  96 + if (data.code === 200) {
  97 + res = data.data;
  98 +
  99 + showErrTip('登录成功');
  100 + location.href = res.href;
  101 + $loginBtn.text('登录成功');
  102 + } else {
  103 + if (useVerify && data.captchaShow) {
  104 + ((data.changeCaptcha && validate.type !== 2) && validate.refresh());
  105 + }
  106 +
  107 + showErrTip(data.message);
  108 + resetForm();
  109 + }
  110 +
  111 + return data;
  112 + },
  113 + error: function() {
  114 + showErrTip('网络断开连接啦~');
  115 +
  116 + validate && validate.refresh();
  117 + },
  118 + complete: function() {
  119 + $loginBtn.text('登录').removeClass('disable');
  120 + }
  121 + });
  122 +}
  123 +
63 // 密码显示与隐藏 124 // 密码显示与隐藏
64 api.bindEyesEvt(); 125 api.bindEyesEvt();
65 126
@@ -95,67 +156,23 @@ $loginBtn.on('touchstart', function() { @@ -95,67 +156,23 @@ $loginBtn.on('touchstart', function() {
95 156
96 // 验证账号(数字或者邮箱)和密码合理性 157 // 验证账号(数字或者邮箱)和密码合理性
97 if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) { 158 if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
98 - validate.getResults().then((result) => {  
99 - $loginBtn.text('正在登录...').addClass('disable');  
100 -  
101 - let params = {  
102 - account: acc,  
103 - password: pwd  
104 - };  
105 -  
106 - $.extend(params, result);  
107 -  
108 - $.ajax({  
109 - type: 'POST',  
110 - url: '/passport/login/auth',  
111 - data: params,  
112 - success: function(data) {  
113 - let res,  
114 - LOGI_TYPE;  
115 -  
116 - if (acc.indexOf('@') > 0) {  
117 - LOGI_TYPE = 8;  
118 - } else {  
119 - LOGI_TYPE = 5;  
120 - }  
121 -  
122 - if (window._yas && window._yas.sendCustomInfo) {  
123 - window._yas.sendCustomInfo({  
124 - op: 'YB_MY_LOGIN_C',  
125 - param: JSON.stringify({  
126 - C_ID: window._ChannelVary[window.cookie('_Channel')],  
127 - LOGI_TYPE: LOGI_TYPE  
128 - })  
129 - }, true);  
130 - }  
131 - validate.type === 2 && validate.refresh();  
132 - if (data.code === 200) {  
133 - res = data.data;  
134 -  
135 - showErrTip('登录成功');  
136 - location.href = res.href;  
137 - $loginBtn.text('登录成功');  
138 - } else {  
139 - if (data.captchaShow) {  
140 - ((data.changeCaptcha && validate.type !== 2) && validate.refresh());  
141 - }  
142 -  
143 - showErrTip(data.message);  
144 - resetForm();  
145 - }  
146 -  
147 - return data;  
148 - },  
149 - error: function() {  
150 - showErrTip('网络断开连接啦~');  
151 -  
152 - validate.refresh();  
153 - },  
154 - complete: function() {  
155 - $loginBtn.text('登录').removeClass('disable');  
156 - }  
157 - });  
158 - }, () => {}); 159 + let params = {
  160 + account: acc,
  161 + password: pwd
  162 + };
  163 +
  164 + if (useVerify) {
  165 + validate.getResults().then((result) => {
  166 + $loginBtn.text('正在登录...').addClass('disable');
  167 +
  168 + $.extend(params, result);
  169 +
  170 + // auth
  171 + loginAuth(params, acc);
  172 + }, () => {});
  173 + } else {
  174 + loginAuth(params, acc);
  175 + }
159 } else { 176 } else {
160 showErrTip('账号或密码有错误,请重新输入'); 177 showErrTip('账号或密码有错误,请重新输入');
161 $loginBtn.text('登录').removeClass('disable'); 178 $loginBtn.text('登录').removeClass('disable');
@@ -102,6 +102,11 @@ exports.processProductList = (list, options) => { @@ -102,6 +102,11 @@ exports.processProductList = (list, options) => {
102 return; 102 return;
103 } 103 }
104 104
  105 + // H5 暂时不支持全球购商品,先过滤掉 2017.04.09
  106 + if (product.is_global === 'Y') {
  107 + return;
  108 + }
  109 +
105 // 商品信息有问题,则不显示 110 // 商品信息有问题,则不显示
106 if (!( 111 if (!(
107 (product.product_id && _.get(product, 'goods_list.length', 0)) || product.recommend_type 112 (product.product_id && _.get(product, 'goods_list.length', 0)) || product.recommend_type