Authored by 郭成尧

merge-master

... ... @@ -73,7 +73,6 @@ app.use(global.yoho.hbs({
helpers: _.assign(global.yoho.helpers, require('./utils/helpers'))
}));
app.use(global.yoho.middleware());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
... ...
... ... @@ -31,4 +31,4 @@ exports.sidebar = function(req, res, next) {
layout: false
});
}).catch(next);
}
\ No newline at end of file
};
... ...
... ... @@ -373,7 +373,7 @@ const order = (params) => {
code: 200
}).then((result) => {
if (result.data) {
if (result && result.data) {
Object.assign(finalResult, {cancelReason: result.data});
}
return finalResult;
... ... @@ -385,7 +385,7 @@ const order = (params) => {
* @param params
*/
const getOrders = (params) => {
let finalResult = Promise.resolve([]);
let finalResult = [];
if (!params.uid) {
return Promise.resolve([]);
... ...
... ... @@ -182,7 +182,6 @@ exports.orderSub = (req, res, next) => {
let yohoCoin = req.body.yohoCoin || 0;
let skuList = req.body.skuList || '';
let orderInfo;
let isWechat = req.yoho.isWechat;
try {
orderInfo = JSON.parse(req.cookies['order-info']);
... ... @@ -254,7 +253,15 @@ exports.orderSub = (req, res, next) => {
return co(function* () {
let result;
let ip = req.ip || '';
// 接口需要的其他参数
let otherParams = {
unionKey: unionKey, // 友盟数据
userAgent: userAgent,
isWechat: req.yoho.isWechat,
ip: req.ip || '',
udid: req.cookies._yasvd || 'yoho'
};
/* tar modified 161206 套餐 */
if (req.body.cartType === 'bundle') {
... ... @@ -262,11 +269,11 @@ exports.orderSub = (req, res, next) => {
result = yield cartModel.orderSub(uid, addressId, 'bundle', deliveryTimeId,
deliveryId, invoices, paymentTypeId, paymentType, msg, couponCode,
yohoCoin, null, unionKey, userAgent, times, activityInfo, ip, isWechat);
yohoCoin, null, times, activityInfo, otherParams);
} else {
result = yield cartModel.orderSub(uid, addressId, cartType, deliveryTimeId,
deliveryId, invoices, paymentTypeId, paymentType, msg, couponCode,
yohoCoin, skuList, unionKey, userAgent, null, null, ip, isWechat);
yohoCoin, skuList, null, null, otherParams);
}
// 提交成功清除Cookie
... ...
... ... @@ -180,23 +180,21 @@ exports.ticketsOrderCompute = (uid, productSku, buyNumber, yohoCoin) => {
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的有货币数量或为空
* @param string $skuList 购买限购商品时需要传递的参数
* @param string $qhyUnio 友盟有关信息
* @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息
* @param int $times
* @param null $activityInfo 套餐数据
* @param isWechat 是否是微信商城
* @param otherParams 其他参数
* @return array 接口返回的数据
*/
exports.orderSub = (uid, addressId, cartType, deliveryTime,
deliveryWay, invoices, paymentId, paymentType, remark,
couponCode, yohoCoin, skuList, qhyUnio,
userAgent, times, activityInfo, ip, isWechat) => {
if (!qhyUnio) {
qhyUnio = '';
couponCode, yohoCoin, skuList, times, activityInfo, otherParams) => {
if (!otherParams.unionKey) {
otherParams.unionKey = '';
}
if (!userAgent) {
userAgent = null;
if (!otherParams.userAgent) {
otherParams.userAgent = null;
}
if (!times) {
... ... @@ -221,8 +219,7 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime,
return shoppingAPI.orderSub(uid, addressId, cartType, deliveryTime,
deliveryWay, invoices, paymentId, paymentType,
remark, couponCode, yohoCoin, skuList, qhyUnio,
userAgent, times, activityInfo, ip, isWechat).then(orderSubRes => {
remark, couponCode, yohoCoin, skuList, times, activityInfo, otherParams).then(orderSubRes => {
let finalResult = {};
if (orderSubRes && orderSubRes.data && orderSubRes.data.is_hint === 'Y') {
... ...
... ... @@ -241,7 +241,7 @@ const getPriceGiftList = (promotionIds, promotionType) => {
method: 'app.Shopping.queryPromotionGifts',
promotion_ids: promotionIds
}).then((data) => {
return data.code === 200 ? cartProcess.procPriceGiftData(data.data, promotionType) : void 0;
return data.code === 200 ? cartProcess.procPriceGiftData(data.data, promotionType) : {};
});
};
... ...
... ... @@ -149,16 +149,15 @@ exports.checkTickets = (uid, productSku, buyNumber, useYohoCoin, yohoCoinMode) =
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的有货币数量或为空
* @param string $skuList 购买限购商品时需要传递的参数
* @param string $qhyUnion 友盟有关信息
* @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息
* @param $times
* @param null $activityInfo 套餐信息
* @param isWechat 是否是微信商城
* @param @param otherParams 其他参数
* @return array 接口返回的数据
*/
exports.orderSub = (uid, addressId, cartType, deliveryTime,
deliveryWay, invoices, paymentId, paymentType, remark, couponCode,
yohoCoin, skuList, qhyUnion, userAgent, times, activityInfo, ip, isWechat) => {
yohoCoin, skuList, times, activityInfo, otherParams) => {
if (!activityInfo) {
activityInfo = null;
}
... ... @@ -173,7 +172,8 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime,
payment_id: paymentId,
payment_type: paymentType,
remark: remark,
uid: uid
uid: uid,
udid: otherParams.udid
};
/* tar add 161130 结算优化 */
... ... @@ -223,19 +223,19 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime,
}
// 友盟有关信息的传递
if (qhyUnion) {
params.qhy_union = qhyUnion;
if (otherParams.unionKey) {
params.qhy_union = otherParams.unionKey;
}
// 是否是微信商城
if (isWechat) {
if (otherParams.isWechat) {
params.client_type = 'wechat';
}
return api.post('', params, {
headers: {
'X-Forwarded-For': ip || '',
'User-Agent': userAgent
'X-Forwarded-For': otherParams.ip || '',
'User-Agent': otherParams.userAgent
}
});
};
... ...
... ... @@ -201,7 +201,7 @@ const packageData = (id, isApp, isWeixin, channel, isShare) => {
return Promise.all(promises).then(datas => {
let getArticleContent = {};
let getArticleContent = [];
if (datas) {
if (datas[1]) {
... ...
... ... @@ -188,6 +188,7 @@ const addressModify = (req, res, next) => {
*/
const changeAddress = (req, res, next) => {
let uid = req.user.uid;
let udid = req.cookies._yasvd || 'yoho';
if (!uid) {
return res.json({
... ... @@ -202,7 +203,8 @@ const changeAddress = (req, res, next) => {
username: req.body.username,
areaCode: req.body.area_code,
address: req.body.address,
mobile: req.body.mobile
mobile: req.body.mobile,
udid: udid
}).then(result => {
res.json(result);
}).catch(next);
... ...
... ... @@ -374,7 +374,8 @@ const changeAddress = (params) => {
user_name: params.username,
area_code: params.areaCode,
address: params.address,
mobile: params.mobile
mobile: params.mobile,
udid: params.udid
};
if (params.addressId) {
... ...
... ... @@ -90,8 +90,8 @@ router.get('/helpDetail', help.helpDetail);
// 意见反馈
router.get('/suggest', suggest.suggestData);
router.post('/upAndDown', suggest.upAndDown);
router.get('/suggestSub', suggest.suggestSub);
router.post('/savesuggest', suggest.saveSuggest);
router.get('/suggestSub', auth, suggest.suggestSub);
router.post('/savesuggest', auth, suggest.saveSuggest);
// 消息
router.use('/message', auth, disableBFCache, message.index);
... ...
... ... @@ -10,10 +10,12 @@ const passport = require('passport');
// const md5 = require('yoho-md5');
const uuid = require('uuid');
const co = Promise.coroutine;
const cookie = global.yoho.cookie;
const helpers = global.yoho.helpers;
const log = global.yoho.logger;
const config = global.yoho.config;
const cache = global.yoho.cache;
const utils = require(global.utils);
const RegService = require('../models/reg-service');
const AuthHelper = require('../models/auth-helper');
... ... @@ -81,7 +83,9 @@ const common = {
let passLogin = _.get(req, 'cookies._WX_PASS_LOGIN', false);
if (req.yoho.isWechat && !passLogin) {
return res.redirect('/passport/login/wechat');
return res.redirect(helpers.urlFormat('/passport/login/wechat', {
refer: req.query.refer || req.get('Referer') || '/'
}));
}
next();
},
... ... @@ -120,19 +124,10 @@ const local = {
req.session.captchaValidCount = 5;
}
// 先清除cookie
// res.clearCookie('LE' + md5('_LOGIN_EXPIRE'), {
// domain: 'yohobuy.com'
// });
// 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie
// res.cookie('LE' + md5('_LOGIN_EXPIRE'), (new Date()).getTime() / 1000 + 1800);
res.render('login', {
width750: true,
loginIndex: true, // 模板中使用JS的标识
captchaShow: true, // 170306 因为暴力破解密码问题,要求每次都展示验证码
captchaShow: req.yoho.captchaShow,
backUrl: 'javascript:history.go(-1)', // eslint-disable-line
showHeaderImg: true, // 控制显示头部图片
isPassportPage: true, // 模板中模块标识
... ... @@ -162,21 +157,11 @@ const local = {
req.session.captchaValidCount = 5;
}
// 先清除cookie
// res.clearCookie('LE' + md5('_LOGIN_EXPIRE'), {
// domain: 'yohobuy.com'
// });
// 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie
// res.cookie('LE' + md5('_LOGIN_EXPIRE'), (new Date()).getTime() / 1000 + 1800);
res.render('international', {
width750: true,
backUrl: 'javascript:history.go(-1)', // eslint-disable-line
loginInternational: true, // 模板中使用JS的标识
captchaShow: true, // 170306 因为暴力破解密码问题,要求每次都展示验证码
captchaShow: req.yoho.captchaShow,
isPassportPage: true, // 模板中模块标识
headerText: '登录',
areaCode: '+86', // 默认区号
... ... @@ -206,6 +191,8 @@ const local = {
captchaShow: true
};
cache.set(`loginErrorIp:${req.yoho.clientIp}`, true, 3600).catch(log.error);
res.json(obj);
} else {
let refer = req.cookies.refer;
... ... @@ -250,6 +237,18 @@ const local = {
const wechat = {
login: (req, res, next) => {
// 微信里边已经登录的时候,不再跳转登录
if (req.user.uid) {
let refer = req.query.refer || decodeURI(req.cookies.refer) || config.siteUrl;
if (/sign|login/.test(refer)) {
refer = `${config.siteUrl}/home`;
}
refer = utils.refererLimit(refer);
return res.redirect(refer);
}
// 设置为原链接标识originalUrl
req.session.originalUrl = 'true';
req.session.authState = uuid.v4();
... ... @@ -389,6 +388,36 @@ exports.user = function(req, res, next) {
res.jsonp(result);
};
/**
* 中间件
* 根据用户登录是否成功决定是否展示验证码
*/
exports.loginShowCaptchaByIp = function(req, res, next) {
// 总开关状态
req.yoho.captchaShow = !_.get(req.app.locals.wap, 'close.loginValidation', false);
// 开关打开,不走任何验证逻辑
if (!req.yoho.captchaShow) {
return next();
} else {
req.yoho.captchaShow = false;
}
co(function*() {
let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`);
log.info(`Pagerender clientip ${req.yoho.clientIp} status is ` + hasErrorLog);
if (hasErrorLog) {
req.yoho.captchaShow = true;
}
next();
})().catch(function(e) {
req.yoho.captchaShow = true;
next();
});
};
exports.common = common;
exports.local = local;
exports.wechat = wechat;
... ...
... ... @@ -7,6 +7,9 @@
'use strict';
const _ = require('lodash');
const config = global.yoho.config;
const co = Promise.coroutine;
const cache = global.yoho.cache;
const log = global.yoho.logger;
const geetest = require('./geetest');
const captcha = require('./captcha');
... ... @@ -20,15 +23,44 @@ const check = (req, res, next) => {
return next();
}
// 使用极验证
let useGeetest = !_.get(req.app.locals.wap, 'geetest.validation', false);
// 默认取配置总开关来决定是否展示验证码
req.yoho.captchaShow = !_.get(req.app.locals.wap, 'close.loginValidation', false);
// 某次请求极验证调用注册失败,强制使用自有图形验证码
if (req.session.useYohoCaptcha) {
useGeetest = false;
}
co(function* () {
// 如果是账号密码登录,那么需要检查是否登录失败过,登录失败过展示验证码
if (req.path === '/passport/login/auth') {
let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`);
log.info(`Check clientip ${req.yoho.clientIp} status is ` + hasErrorLog);
if (hasErrorLog) {
req.yoho.captchaShow = true;
} else {
req.yoho.captchaShow = false;
}
}
return req.yoho.captchaShow;
})().catch(function() {
// memcache 不可用,展示验证码
req.yoho.captchaShow = true;
return req.yoho.captchaShow;
}).then(function() {
// 不是账号密码登录,直接根据配置总开关决定是否需要展示验证码
if (!req.yoho.captchaShow) {
return next();
}
// 使用极验证
let useGeetest = !_.get(req.app.locals.wap, 'geetest.validation', false);
// 某次请求极验证调用注册失败,强制使用自有图形验证码
if (req.session.useYohoCaptcha) {
useGeetest = false;
}
return (useGeetest ? geetest : captcha).validate(req, res, next);
return (useGeetest ? geetest : captcha).validate(req, res, next);
});
};
/**
... ...
... ... @@ -2,6 +2,7 @@
const _ = require('lodash');
const aes = require('./aes-pwd');
const authcode = require('../../../utils/authcode');
const logger = global.yoho.logger;
const sign = global.yoho.sign;
const api = global.yoho.API;
const uuid = require('uuid');
... ... @@ -35,10 +36,13 @@ class Auth {
param.shopping_key = shoppingKey;
}
logger.info(`${profile}, login from ${ip}`);
return api.post('', param, {
headers: {
'user-agent': 'yoho/nodejs',
'X-YOHO-IP': ip
'X-YOHO-IP': ip,
'X-Forwarded-For': ip
}
});
}
... ...
... ... @@ -27,7 +27,7 @@ const router = express.Router(); // eslint-disable-line
router.get('/passport/geetest/register', geetest.register);
// 兼容老的路由
router.get('/signin.html', validateCode.load, login.common.weixinCheck,
router.get('/signin.html', login.common.weixinCheck, validateCode.load,
login.common.beforeLogin, login.common.clearCookie, smsLogin.loginPage);
router.get('/reg.html', validateCode.load, disableBFCahce, reg.index);
router.get('/login.html', validateCode.load,
... ... @@ -39,10 +39,21 @@ router.get('/emailback.html', back.indexEmailPage);
router.get('/passport/signout/index', login.common.clearCookie, login.local.logout);
// 登录页面
router.get('/passport/login', validateCode.load,
login.common.beforeLogin, login.common.clearCookie, login.local.loginPage);
router.get('/passport/international', validateCode.load,
login.common.beforeLogin, login.common.clearCookie, login.local.international);
router.get('/passport/login',
validateCode.load,
login.common.beforeLogin,
login.common.clearCookie,
login.loginShowCaptchaByIp,
login.local.loginPage
);
router.get('/passport/international',
validateCode.load,
login.common.beforeLogin,
login.common.clearCookie,
login.loginShowCaptchaByIp,
login.local.international
);
// 本地登录
router.post('/passport/login/auth', validateCode.check, login.local.login);
... ... @@ -78,10 +89,6 @@ router.get('/passport/login/qq/callback', login.qq.callback);
router.get('/passport/login/alipay', login.common.beforeLogin, login.alipay.login);
router.get('/passport/login/alipay/callback', login.alipay.callback);
// alipay登录
router.get('/login/alipay', login.common.beforeLogin, login.alipay.login);
router.get('/login/alipay/callback', login.alipay.callback);
// 登录绑定
router.get('/passport/bind/index', validateCode.load, bind.indexPage);
router.post('/passport/bind/bindCheck', validateCode.check, bind.bindCheck);
... ...
... ... @@ -10,7 +10,7 @@
<input id="pwd" class="pwd input" type="password" placeholder="密码">
</div>
{{!--图片验证--}}
<div data-geetest="{{useGeetest}}" id="js-img-check"></div>
<div data-userverify="{{captchaShow}}" data-geetest="{{useGeetest}}" id="js-img-check"></div>
<span id="btn-login" class="btn btn-login disble row">登录</span>
</div>
... ...
... ... @@ -9,7 +9,7 @@
<input id="pwd" class="pwd input" type="password" placeholder="密码">
</div>
{{!--图片验证--}}
<div data-geetest="{{useGeetest}}" id="js-img-check"></div>
<div data-userverify="{{captchaShow}}" data-geetest="{{useGeetest}}" id="js-img-check"></div>
<span id="btn-login" class="btn btn-login disable">登录</span>
<p class="op-container">
<a class="op-item internat" href={{internationalUrl}}>海外手机</a>
... ...
... ... @@ -231,6 +231,7 @@ const category = (req, res, next) => {
order: '0',
page: 1,
limit: 12,
isApp: params.app_version
}, params);
if (uid) {
... ...
... ... @@ -881,7 +881,7 @@ const getLimitProductData = (uid, limitProductCode) => {
if (obj.attaches.length > 1) {
obj.attaches.sort((v1, v2) => {
return v1.orderBy - v2.orderBy;
return v2.orderBy - v1.orderBy;
});
}
... ...
... ... @@ -123,6 +123,8 @@ const selectHotrank = (yhChannel, gender, sort, tabId, limit, page, notab) => {
}
return formData;
} else {
return {};
}
});
... ...
... ... @@ -25,7 +25,7 @@ const domains = {
module.exports = {
app: 'h5',
appVersion: '5.5.1', // 调用api的版本
appVersion: '5.5.2', // 调用api的版本
port: 6001,
siteUrl: '//m.yohobuy.com',
assetUrl: '//127.0.0.1:5001',
... ... @@ -67,11 +67,6 @@ module.exports = {
handleExceptions: true,
maxFiles: 7
},
udp: { // send by udp
measurement: 'yohobuy_wap_node_log',
level: 'error', // logger level
port: '4444' // influxdb port
},
console: {
level: 'info',
colorize: 'all',
... ...
... ... @@ -22,7 +22,7 @@ module.exports = (req, res, next) => {
return next();
}
if (res.statusCode == 403) {
if (_.toNumber(res.statusCode) === 403) {
return res.end();
}
... ...
... ... @@ -21,7 +21,11 @@ const _getClientIp = req => {
remoteIp = _.trim(arr[arr.length - 1]);
}
return remoteIp;
if (_.startsWith(remoteIp, '10.66.')) {
remoteIp = req.get('X-Real-IP');
}
return _.trim(remoteIp);
};
module.exports = () => {
... ...
{
"name": "m-yohobuy-node",
"version": "5.5.11",
"version": "5.5.20",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -50,7 +50,7 @@
"xml2js": "^0.4.17",
"yoho-express-session": "^2.0.0",
"yoho-md5": "^2.0.0",
"yoho-node-lib": "=0.2.11",
"yoho-node-lib": "=0.2.17",
"yoho-zookeeper": "^1.0.8"
},
"devDependencies": {
... ...
... ... @@ -13,6 +13,7 @@ let $phoneNum = $('#phone-num'),
$loginBtn = $('#btn-login'),
$captcha = $('#js-img-check'),
useVerify = $captcha.data('userverify'), // 170406 是否使用验证
pnPass = false,
pwdPass = false;
... ... @@ -23,15 +24,18 @@ let tip = require('plugin/tip');
let trim = $.trim;
let showErrTip = tip.show;
let validate = new Validate($captcha, {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
let validate = {};
validate.init();
if (useVerify) {
validate = new Validate($captcha, {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
validate.init();
}
// 登录按钮状态切换
function switchLoginBtnStatus() {
... ... @@ -45,6 +49,47 @@ function resetForm() {
$loginBtn.text('登录').addClass('disable');
}
/**
* 登录校验
*/
function loginAuth(params) {
$.ajax({
type: 'POST',
url: '/passport/login/auth',
data: params,
success: function(data) {
let res;
validate && validate.type === 2 && validate.refresh();
if (data.code === 200) {
res = data.data;
showErrTip('登录成功');
// 3秒后强制跳转
setTimeout(() => {
location.href = res.href;
}, 1500);
$loginBtn.text('登录成功');
showErrTip('登录成功');
} else {
if (useVerify && data.captchaShow) {
((data.changeCaptcha && validate.type !== 2) && validate.refresh());
}
showErrTip(data.message);
resetForm();
}
},
error: function() {
showErrTip('网络断开连接啦~');
$loginBtn.text('登录');
validate && validate.refresh();
}
});
}
// Android-UC下显示select的direction:rtl无效的临时解决办法
api.selectCssHack($countrySelect);
... ... @@ -90,52 +135,21 @@ $loginBtn.on('touchstart', function() {
}
if ((api.phoneRegx[areaCode].test(pn) || areaCode !== '+86') && api.pwdValidate(pwd)) {
validate.getResults().then((result) => {
$loginBtn.text('正在登录...').addClass('disable');
let params = {
areaCode: areaCode.replace('+', ''),
account: pn,
password: pwd
};
$.extend(params, result);
$.ajax({
type: 'POST',
url: '/passport/login/auth',
data: params,
success: function(data) {
let res;
validate.type === 2 && validate.refresh();
if (data.code === 200) {
res = data.data;
showErrTip('登录成功');
// 3秒后强制跳转
setTimeout(() => {
location.href = res.href;
}, 1500);
$loginBtn.text('登录成功');
showErrTip('登录成功');
} else {
if (data.captchaShow) {
((data.changeCaptcha && validate.type !== 2) && validate.refresh());
}
showErrTip(data.message);
resetForm();
}
},
error: function() {
showErrTip('网络断开连接啦~');
$loginBtn.text('登录');
validate.refresh();
}
let params = {
areaCode: areaCode.replace('+', ''),
account: pn,
password: pwd
};
if (useVerify) {
validate.getResults().then((result) => {
$loginBtn.text('正在登录...').addClass('disable');
$.extend(params, result);
loginAuth(params);
});
});
} else {
loginAuth(params);
}
} else {
showErrTip('账号或密码有错误,请重新输入');
$loginBtn.text('登录').addClass('disable');
... ...
... ... @@ -32,7 +32,9 @@ let validate = new Validate($captcha, {
}
});
validate.init();
if ($captcha.data('userverify')) {
validate.init();
}
// 登录按钮状态切换
function switchLoginBtnStatus() {
... ... @@ -60,6 +62,67 @@ function hideRetrivePanel() {
$ways.hide();
}
/**
* 登录校验
*/
function loginAuth(params, acc) {
$.ajax({
type: 'POST',
url: '/passport/login/auth',
data: params,
success: function(data) {
let res,
LOGI_TYPE;
if (acc.indexOf('@') > 0) {
LOGI_TYPE = 8;
} else {
LOGI_TYPE = 5;
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_MY_LOGIN_C',
param: JSON.stringify({
C_ID: window._ChannelVary[window.cookie('_Channel')],
LOGI_TYPE: LOGI_TYPE
})
}, true);
}
validate && validate.type === 2 && validate.refresh();
if (data.code === 200) {
res = data.data;
showErrTip('登录成功');
location.href = res.href;
$loginBtn.text('登录成功');
} else {
$captcha.data('userverify', data.captchaShow);
if (data.captchaShow) {
if (validate.atWorking) {
((data.changeCaptcha && validate.type !== 2) && validate.refresh());
} else {
validate.init();
}
}
showErrTip(data.message);
resetForm();
}
return data;
},
error: function() {
showErrTip('网络断开连接啦~');
validate && validate.refresh();
},
complete: function() {
$loginBtn.text('登录').removeClass('disable');
}
});
}
// 密码显示与隐藏
api.bindEyesEvt();
... ... @@ -95,67 +158,23 @@ $loginBtn.on('touchstart', function() {
// 验证账号(数字或者邮箱)和密码合理性
if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
validate.getResults().then((result) => {
$loginBtn.text('正在登录...').addClass('disable');
let params = {
account: acc,
password: pwd
};
$.extend(params, result);
$.ajax({
type: 'POST',
url: '/passport/login/auth',
data: params,
success: function(data) {
let res,
LOGI_TYPE;
if (acc.indexOf('@') > 0) {
LOGI_TYPE = 8;
} else {
LOGI_TYPE = 5;
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_MY_LOGIN_C',
param: JSON.stringify({
C_ID: window._ChannelVary[window.cookie('_Channel')],
LOGI_TYPE: LOGI_TYPE
})
}, true);
}
validate.type === 2 && validate.refresh();
if (data.code === 200) {
res = data.data;
showErrTip('登录成功');
location.href = res.href;
$loginBtn.text('登录成功');
} else {
if (data.captchaShow) {
((data.changeCaptcha && validate.type !== 2) && validate.refresh());
}
showErrTip(data.message);
resetForm();
}
return data;
},
error: function() {
showErrTip('网络断开连接啦~');
validate.refresh();
},
complete: function() {
$loginBtn.text('登录').removeClass('disable');
}
});
}, () => {});
let params = {
account: acc,
password: pwd
};
if ($captcha.data('userverify')) {
validate.getResults().then((result) => {
$loginBtn.text('正在登录...').addClass('disable');
$.extend(params, result);
// auth
loginAuth(params, acc);
}, () => {});
} else {
loginAuth(params, acc);
}
} else {
showErrTip('账号或密码有错误,请重新输入');
$loginBtn.text('登录').removeClass('disable');
... ...
... ... @@ -102,6 +102,11 @@ exports.processProductList = (list, options) => {
return;
}
// H5 暂时不支持全球购商品,先过滤掉 2017.04.09
if (product.is_global === 'Y') {
return;
}
// 商品信息有问题,则不显示
if (!(
(product.product_id && _.get(product, 'goods_list.length', 0)) || product.recommend_type
... ...