Commit d24f6ec8 by 梁建民

微信登录

parent 709a96db
...@@ -16,36 +16,45 @@ ...@@ -16,36 +16,45 @@
<p class="t2">让询报价更轻松、便捷</p> <p class="t2">让询报价更轻松、便捷</p>
</div> </div>
<!--微信绑定--> <!--微信绑定-->
<div class="wechat" style="display: none"> <div class="wechat">
<a href="javascript:;" class="btn"> <a href="authapi/v1/weixin/web/login" class="btn">
<i class="iconfont iconjuxing22 va-m"></i> <i class="iconfont iconjuxing22 va-m"></i>
<span class="va-m">微信登录</span> <span class="va-m">微信登录</span>
</a> </a>
<p class="tab-sel"> <p class="tab-sel">
<a href="javascript:;">验证码登录</a> <a href="passporticsales?flag=verify">验证码登录</a>
<a href="javascript:;">密码登录</a> <a href="passporticsales?flag=password">密码登录</a>
</p> </p>
</div> </div>
<!--绑定手机号--> <!--绑定手机号-->
<div class="bind-mobile layui-form" style="display: none"> <form class="bind-mobile layui-form" style="display: none" onsubmit="return false">
<input type="hidden" name="code_type" value="2">
<div class="input-wrap"> <div class="input-wrap">
<i class="iconfont iconjuxing23 va-m"></i> <i class="iconfont iconjuxing23 va-m"></i>
<input type="text" class="w w1 va-m" placeholder="请输入手机号"> <input type="text" class="w w1 va-m" placeholder="请输入手机号" name="mobile">
<div class="sel lineBlock va-m"> <div class="sel lineBlock va-m">
<select name="interest"> <select>
<option value="0">大陆 +86</option> <option value="0">大陆 +86</option>
</select> </select>
</div> </div>
</div> </div>
<!--验证码-->
<div class="input-wrap" id="verifiCode" style="display: none">
<i class="iconfont iconjuxing26 va-m"></i>
<input type="text" class="w w1 va-m" name="captcha" placeholder="请输入图形验证码"/>
<input type="hidden" class="w w1 va-m" name="captchaUuid" value=""/>
<img src="" alt="" width="100" height="30" class="lineBlock va-m codepic"/>
</div>
<div class="input-wrap"> <div class="input-wrap">
<i class="iconfont iconjuxing26 va-m"></i> <i class="iconfont iconjuxing26 va-m"></i>
<input type="text" class="w w1 va-m" placeholder="请输入手机"> <input type="text" class="w w1 va-m" placeholder="请输入手机验证码" name="smsCode">
<span class="lineBlock text va-m">发送验证码</span> <input type="button" name="codetext" class="lineBlock text va-m" value="发送验证码" style="background: none;"/>
</div> </div>
<div class="btn-wrap"> <div class="btn-wrap">
<a href="javascript:;" class="btn">绑定手机号</a> <a href="javascript:;" class="btn" lay-submit lay-filter="bindMobile">绑定手机号</a>
</div>
</div> </div>
</form>
<!--验证码登录--> <!--验证码登录-->
<form class="verify-code layui-form" style="display: none" onsubmit="return false"> <form class="verify-code layui-form" style="display: none" onsubmit="return false">
<input type="hidden" name="code_type" value="2"> <input type="hidden" name="code_type" value="2">
...@@ -83,7 +92,7 @@ ...@@ -83,7 +92,7 @@
</div> </div>
</form> </form>
<!--密码登录--> <!--密码登录-->
<form class="login layui-form" onsubmit="return false"> <form class="login layui-form" style="display: none" onsubmit="return false">
<div class="input-wrap"> <div class="input-wrap">
<i class="iconfont iconjuxing23 va-m"></i> <i class="iconfont iconjuxing23 va-m"></i>
<input type="text" class="w w1 va-m" placeholder="请输入手机号" name="mobile"> <input type="text" class="w w1 va-m" placeholder="请输入手机号" name="mobile">
......
...@@ -14,8 +14,31 @@ ...@@ -14,8 +14,31 @@
$(".verify-code").show(); $(".verify-code").show();
$(".wechat").hide();
$(".login").hide(); $(".login").hide();
break;
case 'password':
$(".verify-code").hide();
$(".wechat").hide();
$(".login").show();
break;
case 'bindmobile':
$(".verify-code").hide();
$(".wechat").hide();
$(".login").hide();
$(".bind-mobile").show();
break;
} }
...@@ -26,12 +49,12 @@ ...@@ -26,12 +49,12 @@
return this; return this;
}, },
getCode: function (opt, type, params) { getCode: function (opt, type, params, element) {
var $verifiCode = $("#verifiCode"), var $verifiCode = element.parents('.layui-form').find("#verifiCode"),
$code = $('input[name="code"]'), $code = element.parents('.layui-form').find('input[name="code"]'),
$codetext = $('input[name="codetext"]'), $codetext = element.parents('.layui-form').find('input[name="codetext"]'),
$codepic = $('.codepic'); $codepic = element.parents('.layui-form').find('.codepic');
if (type == 'captchaInfo') { if (type == 'captchaInfo') {
...@@ -101,6 +124,7 @@ ...@@ -101,6 +124,7 @@
calcForm: function (ele, type) { calcForm: function (ele, type) {
var $mobile = $(ele).find('input[name="mobile"]'), var $mobile = $(ele).find('input[name="mobile"]'),
$password = $(ele).find('input[name="password"]'), $password = $(ele).find('input[name="password"]'),
$smsCode = $(ele).find('input[name="smsCode"]'),
$code = $(ele).find('input[name="code"]'); $code = $(ele).find('input[name="code"]');
...@@ -145,6 +169,13 @@ ...@@ -145,6 +169,13 @@
} }
if (!$smsCode.val() && type === 3) {
$smsCode.parent('.input-wrap').addClass('error');
return false;
}
$('.error').removeClass('error'); $('.error').removeClass('error');
...@@ -156,15 +187,15 @@ ...@@ -156,15 +187,15 @@
//发送验证码 //发送验证码
$(document).on('click', 'input[name="codetext"]', function () { $(document).on('click', 'input[name="codetext"]', function () {
var $verifiCode = $("#verifiCode"), var $verifiCode = $(this).parents('.layui-form').find("#verifiCode"),
captchaUuid = $verifiCode.find('input[name="captchaUuid"]').val(), captchaUuid = $verifiCode.find('input[name="captchaUuid"]').val(),
captcha = $verifiCode.find('input[name="captcha"]').val(), captcha = $verifiCode.find('input[name="captcha"]').val(),
mobile = $('input[name="mobile"]').val(); mobile = $(this).parents('.layui-form').find('input[name="mobile"]').val();
//判断是否有图形验证码id //判断是否有图形验证码id
if (!captchaUuid) { if (!captchaUuid) {
opt.getCode(opt, 'captchaInfo'); opt.getCode(opt, 'captchaInfo', null, $(this));
} else { } else {
...@@ -177,7 +208,7 @@ ...@@ -177,7 +208,7 @@
code_type: 2 code_type: 2
}; };
opt.getCode(opt, 'mobile', params); opt.getCode(opt, 'mobile', params, $(this));
} }
...@@ -368,6 +399,62 @@ ...@@ -368,6 +399,62 @@
} }
}); });
//微信提交
layui.form.on('submit(bindMobile)', function (data) {
if (opt.calcForm(data.form, 3)) {
$(data.elem).addClass("layui-btn-disabled");
if (!opt.isClick) {
opt.isClick = true;
var code = Util.getRequest('code');
var params = $.extend({}, data.field, {code: code});
IcController.getData(apis.mobileBind, 'GET', params, function (res) {
if (res.errcode === 0) {
//注入token
Util.setCookie('token', res.data.access_token, 1, cookieHostname);
Util.setCookie('user_id', res.data.user_id, 1, cookieHostname);
window.location.href = home_url;
} else if (res.errcode === 505) {
$(".error-text").hide();
layer.confirm('账户被禁用,请联系0755-23940717,进行解禁', {
btn: ['取消', '联系客服']
}, function () {
layer.closeAll();
}, function () {
layer.msg('0755-23940717', {
time: 8000
});
});
opt.isClick = false;
$(data.elem).removeClass("layui-btn-disabled");
} else {
layer.msg(res.errmsg);
opt.isClick = false;
$(data.elem).removeClass("layui-btn-disabled");
}
});
}
}
});
$("body").keydown(function () { $("body").keydown(function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment