其他登录方式
没有账号 var mobile=$('#mobile').val();
var password=$('#password').val();
if(mobile.trim()==''){
layer.msg("请先输入手机号/邮箱", {icon: 2});
return;
}
if(password.trim()==''){
layer.msg("请输入密码", {icon: 2});
return;
}
if (!$('#agree').is(':checked')) {
layer.msg("请先勾选同意《隐私政策》", {icon: 2});
return;
}
$.ajax({
url: "/do_login",
data: {username:mobile,password:password},
dataType: 'json',
type:"POST",
success: function (res) {
if(res.code==200){
window.location.href=res.url;
}else{
layer.msg(res.msg, {icon: 2});
}
},
error: function (data) {
layer.msg("操作失败", {icon: 5});
}
});
}
//获取短信验证码
function pushCode() {
var mobile = $.trim($("#other_mobile").val());
if (mobile == '') {
layer.msg('请输入手机号码', {icon: 2});
return false;
}
var regMobile = /^1[345678]\d{9}$/;
if (!regMobile.test(mobile)) {
layer.msg('手机号码格式不正确', {icon: 2});
return false;
}
layer.load();
$.ajax({
type: 'POST',
url: "/get_mobile_code",
data: {'mobile': mobile},
dataType: "JSON",
success: function (res) {
layer.closeAll();
if (res.code == 100) {
$("#getCodeBtn").text("重发验证码");
layer.msg(res.msg, {icon: 2, time: 1000});
return;
} else {
$('#getCodeBtn').attr('href', 'javascript:;');
var second = 60;
$('#getCodeBtn').text(second + '秒');
var interval = setInterval(function () {
second--;
$('#getCodeBtn').text(second + '秒');
if (second === -1) {
$('#getCodeBtn').attr('href', 'javascript:pushCode();');
$("#getCodeBtn").text("重发验证码");
clearInterval(interval);
}
}, 1000);
}
layer.msg(res.msg, {icon: 1, time: 1000});
},
error: function (e) {
layer.closeAll();
}
});
}
function do_mobile_login() {
var mobile = $.trim($("#other_mobile").val());
if (mobile == '') {
layer.msg('请先请输入手机号码', {icon: 2});
return false;
}
var regMobile = /^1[345678]\d{9}$/;
if (!regMobile.test(mobile)) {
layer.msg('手机号码格式不正确', {icon: 2});
return false;
}
var mobile_code = $.trim($("#other_code").val());
if (mobile_code == '') {
layer.msg('验证码不能为空', {icon: 2});
return false;
}
if (!$('#agree_checkbox2').prop('checked')) {
layer.msg('请先勾选已阅读并同意《隐私政策》', {icon: 2});
return;
}
layer.load();
$.ajax({
type: 'POST',
url: "/login_action_mobile",
data: {'mobile': mobile, 'mobile_code': mobile_code},
dataType: "JSON",
success: function (res) {
layer.closeAll();
if (res.code == 200) {
layer.msg(res.msg, {icon: 1, time: 1000}, function () {
window.location.href = '/';
});
} else {
layer.msg(res.msg, {icon: 2});
return false;
}
},
error: function (e) {
layer.closeAll();
}
});
}