Authored by 毕凯

Merge branch 'feature/delcode' into 'release/6.5'

del-code



See merge request !1260
/**
* Created by TaoHuang on 2016/6/15.
*/
require('./back/mobile');
/**
* 找回密码-邮箱找回成功
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/8
*/
let $ = require('yoho-jquery');
let $resend = $('#resend');
let tip = require('plugin/tip');
let showTip = tip.show;
$resend.on('touchstart', function(e) {
e.preventDefault();
$.ajax({
url: $resend.data('url'),
type: 'GET',
success: function(data) {
showTip(data.message);
}
});
});
/**
* 找回密码-邮箱找回
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/8
*/
let $ = require('yoho-jquery');
let $email = $('#email'),
$btnSure = $('#btn-sure');
let api = require('../api');
let tip = require('plugin/tip');
let trim = $.trim;
let showErrTip = tip.show;
api.bindClearEvt();
$email.bind('input', function() {
if (trim($email.val()) === '') {
$btnSure.addClass('disable');
} else {
$btnSure.removeClass('disable');
}
});
$btnSure.on('touchstart', function() {
let email = trim($email.val());
if ($btnSure.hasClass('disable')) {
return;
}
if (api.emailRegx.test(email)) {
$.ajax({
url: '/passport/back/sendemail',
type: 'POST',
data: {
email: email
},
success: function(data) {
console.log(data);
if (data.code === 200) {
location.href = data.data;
} else {
showErrTip(data.message);
}
}
});
} else {
showErrTip('邮箱格式不正确,请重新输入');
}
});
/**
* 找回密码-手机
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/8
*/
let $ = require('yoho-jquery');
let $phoneNum = $('#phone-num'),
$countrySelect = $('#country-select'),
$areaCode = $('#area-code'),
$verifyCode = $('#verify-code'),
$verifyCodeImg = $('#verify-code-img'),
$btnNext = $('#btn-next');
let api = require('../api');
let tip = require('plugin/tip');
let trim = $.trim;
let showErrTip = tip.show;
// 图片验证码
let Validate = require('plugin/validata');
let validate = new Validate('#js-img-check', {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
validate.init();
api.selectCssHack($('#country-select'));
api.bindClearEvt();
$phoneNum.bind('input', function() {
if (trim($phoneNum.val()) === '') {
$btnNext.addClass('disable');
} else {
$btnNext.removeClass('disable');
}
});
$countrySelect.change(function() {
$areaCode.text($countrySelect.val());
});
$verifyCodeImg.on('touchstart', function() {
let oldSrc = $verifyCodeImg.attr('src').split('=');
$verifyCodeImg.attr('src', oldSrc[0] + '=' + Date.now());
$verifyCode.val('');
});
$btnNext.on('touchstart', function() {
let pn = trim($phoneNum.val()),
area = trim($countrySelect.val());
if ($btnNext.hasClass('disable')) {
return;
}
if (area && pn && api.phoneRegx[area].test(pn)) {
validate.getResults().then((result) => {
let params = {
areaCode: area.replace('+', ''),
phoneNum: pn
};
$.extend(params, result);
$.ajax({
url: '/passport/back/sendcode',
type: 'POST',
data: params,
success: function(data) {
validate.type === 2 && validate.refresh();
if (data.code === 200 && data.data) {
location.href = data.data.href;
return;
} else if (data.code === 409) {
showErrTip(data.message);
location.href = data.refer;
} else {
showErrTip(data.message);
}
(data.changeCaptcha && validate.type !== 2) && validate.refresh();
},
error: function() {
showErrTip('出错了,请重试');
validate.refresh();
}
});
});
} else if (!area) {
showErrTip('出错了,请重新刷新页面');
} else {
showErrTip('手机号格式不正确,请重新输入');
}
});
require('./login/international');
require('common');
require('./login/qr-check');
require('./login/login');
(function() {
let channel = window.cookie('_Channel');
let channelMap = {
boys: 1,
girls: 2,
kids: 3,
lifestyle: 4
};
let param;
channel = channelMap[channel] || 1;
param = JSON.stringify({C_ID: channel});
// when js run
setTimeout(function() {
let yas = window._yas;
yas && yas.sendCustomInfo && yas.sendCustomInfo({
op: 'YB_LOGIN_L',
param: param
});
}, 3000);
$(function() {
let $smsLogin = $('.sms-login');
// when jump sms-login
$smsLogin.on('click', function() {
let yas = window._yas;
yas && yas.sendCustomInfo && yas.sendCustomInfo({
op: 'YB_MOBILE_QUICK_LOGIN_C',
param: param
});
});
});
}());
/**
* 国际账号登录
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/8
*/
let $ = require('yoho-jquery');
let Validate = require('plugin/validata');
let $phoneNum = $('#phone-num'),
$countrySelect = $('#country-select'),
$areaCode = $('#area-code'),
$pwd = $('#pwd'),
$loginBtn = $('#btn-login'),
$captcha = $('#js-img-check'),
useVerify = $captcha.data('userverify'), // 170406 是否使用验证
pnPass = false,
pwdPass = false;
let api = require('../api');
let tip = require('plugin/tip');
let trim = $.trim;
let showErrTip = tip.show;
let validate = {};
if (useVerify) {
validate = new Validate($captcha, {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
validate.init();
}
// 登录按钮状态切换
function switchLoginBtnStatus() {
let bool = !(pnPass && pwdPass);
$loginBtn.toggleClass('disable', bool);
}
function resetForm() {
$pwd.val('').focus();
$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);
// 显示隐藏密码
api.bindEyesEvt();
// 清空手机号码
api.bindClearEvt();
$phoneNum.bind('input', function() {
if (trim($phoneNum.val()) === '') {
pnPass = false;
} else {
pnPass = true;
}
switchLoginBtnStatus();
});
$pwd.bind('input', function() {
let pwd = trim($pwd.val());
if (pwd === '') {
pwdPass = false;
} else {
pwdPass = true;
}
switchLoginBtnStatus();
});
$countrySelect.change(function() {
$areaCode.text($countrySelect.val());
});
$loginBtn.on('touchstart', function() {
let pn = trim($phoneNum.val()),
areaCode = $countrySelect.val(),
pwd = trim($pwd.val());
if ($loginBtn.hasClass('disable')) {
return;
}
if ((api.phoneRegx[areaCode].test(pn) || areaCode !== '+86') && api.pwdValidate(pwd)) {
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');
}
});
// 对初始有默认值的情况去初始化登录按钮状态
$phoneNum.trigger('input');
$pwd.trigger('input');
/**
* 登录
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/9/30
*/
let $ = require('yoho-jquery');
let Validate = require('plugin/validata');
let $account = $('#account'),
$pwd = $('#pwd'),
$loginBtn = $('#btn-login'),
$mask = $('#retrive-pwd-mask'),
$ways = $('#retrive-pwd-ways'),
$captcha = $('#js-img-check'),
accPass = false,
pwdPass = false;
let api = require('../api');
let tip = require('plugin/tip');
let cookie = require('yoho-cookie');
let trim = $.trim;
let showErrTip = tip.show;
let validate = new Validate($captcha, {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
if ($captcha.data('userverify')) {
validate.init();
}
// 登录按钮状态切换
function switchLoginBtnStatus() {
let bool = true;
bool = !(accPass && pwdPass);
$loginBtn.toggleClass('disable', bool);
}
function resetForm() {
// $pwd.val('').focus();
$loginBtn.text('登录').addClass('disable');
}
// 显示找回密码面板
function showRetrivePanel() {
$mask.show();
$ways.show();
}
// 隐藏找回密码面板
function hideRetrivePanel() {
$mask.hide();
$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 if (data.code === 4189) {
cookie.set('_loginJumpUrl', $('input[name=username]').val());
showErrTip('您的账号存在安全隐患需要进行身份验证');
setTimeout(() => {
location.href = data.url;
}, 2500);
} else if (data.code === 510 || data.code === 50004) {
location.href = data.url;
} 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();
// 清空账号输入框
api.bindClearEvt();
$account.bind('input', function() {
if (trim($account.val()) !== '') {
accPass = true;
} else {
accPass = false;
}
switchLoginBtnStatus();
});
$pwd.bind('input', function() {
if (trim($pwd.val()) === '') {
pwdPass = false;
} else {
pwdPass = true;
}
switchLoginBtnStatus();
});
// Login
$loginBtn.on('touchstart', function() {
if ($loginBtn.hasClass('disable')) {
return;
}
let acc = trim($account.val()),
pwd = trim($pwd.val());
// 验证账号(数字或者邮箱)和密码合理性
if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
let params = {
account: acc,
password: pwd,
isskip: window.queryString.isskip
};
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');
}
});
$('#forget-pwd').on('touchstart', function() {
showRetrivePanel();
});
$mask.on('touchstart', function() {
hideRetrivePanel();
});
$('#cancel-retrive').on('touchstart', function(e) {
e.preventDefault();
hideRetrivePanel();
});
// 对初始有默认值的情况去初始化登录按钮状态
$account.trigger('input');
$pwd.trigger('input');
function getTypeName(name) {
return {
qq: 1,
wechat: 4,
weibo: 2,
alipay: 3
}[name];
}
$('.tp-link a').on('touchstart', function() {
let logType = getTypeName($(this).prop('className'));
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: logType
})
}, true);
}
});
require('./register/password');
require('./register/register');
/**
* 注册-密码
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/8
*/
let $ = require('yoho-jquery');
let $pwd = $('#pwd'),
$pwdLint = $('.pwd-lint'),
$pwdLintTxt = $pwdLint.find('.pwd-lint-txt'),
$btnSure = $('#btn-sure');
let api = require('../api');
let tip = require('plugin/tip');
let validatePWD = require('../password-check');
let trim = $.trim;
let showErrTip = tip.show;
let qs;
require('common');
api.bindEyesEvt({
status: 'open' // 默认眼睛打开
});
$pwd.bind('input', function() {
let val = $.trim(this.value);
let bool = validatePWD(val, function(res) {
$pwdLint.css({visibility: res.valid ? 'hidden' : 'visible'});
if (!res.valid) {
$pwdLintTxt.text(res.msg);
}
});
$btnSure.toggleClass('disable', !bool);
});
qs = window.queryString;
if (qs.selected && qs.selected === 'N') {
$('.pitch').removeClass('select').html('&#xe647;');
}
if (qs.pwd) {
$pwd.val(qs.pwd);
if (trim($pwd.val()) === '') {
$btnSure.addClass('disable');
} else {
$btnSure.removeClass('disable');
}
}
$('.pitch').on('click', function() {
if ($('.pitch').hasClass('select')) {
$(this).removeClass('select');
$(this).html('&#xe647;');
} else {
$(this).addClass('select');
$(this).html('&#xe60a;');
}
});
function setPassword() {
$btnSure.addClass('disable');
return $.ajax({
type: 'POST',
url: '/passport/reg/setpassword',
data: {
password: trim($pwd.val()),
phoneNum: $('#phone-num').val(),
areaCode: $('#area-code').val(),
smsCode: $('#sms-code').val(),
token: $('#token').val(),
inviteCode: $('#invite-code').val()
},
success: function(data) {
let res = data.data;
if (data.code === 200) {
showErrTip('注册成功');
window.setCookie('refer', res.session);
window.setCookie('msgDelivery', res.msgDelivery, {expires: 1, path: '/' });
// 统计代码:用于统计从哪个渠道注册成功的
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_REGISTER_SUCCESS_L',
ud: window.getUid(),
param: JSON.stringify({
C_ID: window._ChannelVary[window.cookie('_Channel')] || 1,
UNION_TYPE: window.queryString.union_type || window.cookie('unionTypeYas') || false
})
}, true);
}
setTimeout(function() {
location.href = res.href;
}, 1500);
} else {
$btnSure.removeClass('disable');
showErrTip(data.message);
}
},
error: function(data) {
$btnSure.removeClass('disable');
if (data && data.responseJSON && data.responseJSON.message) {
showErrTip(data.message);
}
}
});
}
$btnSure.on('touchstart', function() {
let pwd = trim($pwd.val());
if ($btnSure.hasClass('disable')) {
return;
}
if (!validatePWD(pwd)) {
showErrTip('密码6-20位,请重新输入');
} else {
if ($('.pitch').hasClass('select')) {
setPassword();
} else {
$('.prompt').show();
$('.ensure').on('click', function() {
$('.prompt').hide();
$('.pitch').addClass('select');
$('.pitch').html('&#xe60a;');
setPassword();
});
$('.deny').on('click', function() {
location.href = '//m.yohobuy.com/passport/agreement' + window.location.search + '&pwd=' + pwd;
});
}
}
});
$('.agreement-detail').on('click', function() {
$(this).attr('href', '//m.yohobuy.com/passport/agreement' + window.location.search);
});
// 如果有值, 立刻校验
if ($pwd.val()) {
$pwd.triggerHandler('input');
}
/**
* 注册
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/8
*/
let $ = require('yoho-jquery');
let $phoneNum = $('#phone-num'),
$countrySelect = $('#country-select'),
$areaCode = $('#area-code'),
$btnNext = $('#btn-next');
let api = require('../api');
let tip = require('plugin/tip');
let trim = $.trim;
let showErrTip = tip.show;
let requested = false;
require('common');
api.selectCssHack($('#country-select'));
api.bindClearEvt();
// 图片验证码
let Validate = require('plugin/validata');
let validate = new Validate('#js-img-check', {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
validate.init();
/**
* 必填校验
*/
function checkEnableNext() {
let phone = trim($phoneNum.val());
let area = trim($countrySelect.val());
let ret = true;
$.each([phone, area], function(i, val) {
if (!val) {
ret = false;
return ret;
}
});
return ret;
}
/*
Event bind
*/
$('.reg-page')
.on('input', '.phone-num', function() {
$btnNext.toggleClass('disable', !checkEnableNext());
});
$countrySelect.change(function() {
$areaCode.text($countrySelect.val());
});
$btnNext.on('touchstart', function() {
let pn = trim($phoneNum.val()),
areaCode = $countrySelect.val();
if ($btnNext.hasClass('disable')) {
return;
}
if (requested) {
return false;
}
if (api.phoneRegx[areaCode].test(pn) || areaCode !== '+86') {
validate.getResults().then((result) => {
requested = true;
let params = {
areaCode: areaCode.replace('+', ''),
phoneNum: pn,
inviteCode: $('#invite-code').val()
};
$.extend(params, result);
$.ajax({
url: '/passport/reg/verifymobile',
type: 'POST',
data: params,
success: function(data) {
validate.type === 2 && validate.refresh();
if (data.code === 200) {
location.href = data.data.href;
} else {
(data.changeCaptcha && validate.type !== 2) && validate.refresh();
showErrTip(data.message);
requested = false;
}
},
error: function() {
showErrTip('出错了,请重试');
validate.refresh();
requested = false;
}
});
});
} else {
showErrTip('手机号格式不正确,请重新输入');
}
});
$(function() {
if (window.queryString.inviteCode) {
$.ajax({
type: 'GET',
url: '/activity/invite-uesr-info',
data: {
inviteCode: window.queryString.inviteCode
},
success: function(result) {
$('#invite-code').val(result.data.trendWord ? result.data.trendWord : result.data.inviteCode);
}
});
}
});
'use strict';
let tip, api, checkPoint;
let $countrySelect,
$areaCode,
$nextBtn,
$resetBtn,
$phoneNum,
$mask = $('#retrive-pwd-mask'),
$ways = $('#retrive-pwd-ways');
let page;
require('common');
tip = require('plugin/tip');
api = require('./api');
checkPoint = require('./smslogin/check-point');
let cookie = require('yoho-cookie');
// 图片验证码
let Validate = require('plugin/validata');
let validate = new Validate('#js-img-check', {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
validate.init();
require('./login/qr-check');
page = {
init: function() {
this.domInit();
this.bindEvent();
this.toggleNextBtn();
},
domInit: function() {
$countrySelect = $('#country-select');
$areaCode = $('#area-code');
$nextBtn = $('#btn-next');
$phoneNum = $('#phone-num');
$resetBtn = $('.clear-input');
},
bindEvent: function() {
let self = this;
$countrySelect.on('change', function() {
$areaCode.text(this.value);
});
$phoneNum.on('input', function() {
self.toggleNextBtn();
});
$nextBtn.on('click', function() {
self.goNext();
});
$resetBtn.on('click', function() {
$phoneNum.val('');
$nextBtn
.prop('disabled', true)
.toggleClass('disable', true);
$resetBtn.hide();
});
$('#forget-pwd').on('touchstart', () => {
this.showRetrivePanel();
});
$mask.on('touchstart', () => {
this.hideRetrivePanel();
});
$('#cancel-retrive').on('touchstart', (e) => {
e.preventDefault();
this.hideRetrivePanel();
});
},
showRetrivePanel: () => {
$mask.show();
$ways.show();
},
hideRetrivePanel: () => {
$mask.hide();
$ways.hide();
},
// 切换$nextBtn disable状态
toggleNextBtn: function() {
let bool = Boolean($.trim($phoneNum.val()));
$nextBtn
.toggleClass('disable', !bool)
.prop('disabled', !bool);
$resetBtn.toggle(bool);
},
// 提交按钮
goNext: function() {
let areaCode = $countrySelect.val();
let phone = $.trim($phoneNum.val());
if ($nextBtn.prop('disabled')) {
return;
}
if (!api.phoneRegx[areaCode].test(phone)) {
tip.show('手机号码格式不正确, 请重新输入');
return;
}
validate.getResults().then((result) => {
$nextBtn.prop('disabled', true);
let params = {
area: areaCode.replace('+', ''),
mobile: phone
};
$.extend(params, result);
$.post('/passport/sms_login/step1_check', params).done(function(data) {
validate.type === 2 && validate.refresh();
if (data.code === 200) {
checkPoint('YB_MOBILE_NEXT_C'); // 埋点
// $nextBtn.off();
location.href = data.redirect;
} else {
(data.changeCaptcha && validate.type !== 2) && validate.refresh();
tip.show(data.message);
}
})
.fail(function() {
validate.refresh();
tip.show('出错了, 请重试');
})
.always(function() {
$nextBtn.prop('disabled', false);
});
});
}
};
$(function() {
page.init();
});
// 多次登录失败跳短信认证填充手机号
$('#phone-num').val(cookie.get('_loginJumpUrl'));
cookie.remove('_loginJumpUrl');