Merge branch 'master' of http://119.23.72.7/q578953158/yunxin

parents 44551066 385e3d0f
;!function () {
window.loginController = {
'code': "#code",//验证码
'submit': "#submit",//提交按钮
init: function () {
this.handleBind(this);
},
......@@ -24,7 +26,7 @@
}
return false;
},
getData: function (params,callback) {
getData: function (params, callback) {
$.ajax({
url: _URL_ + '/api/ApiLogin',
type: 'post',
......@@ -33,13 +35,14 @@
dataType: 'json',
timeout: 10000,
success: function (res) {
typeof callback == 'function' && callback(res);
/* if (resp.code > 0) {
alert(resp.msg)
if (resp.code > 0) {
layer.msg(resp.msg);
} else {
setCookie('yunxin_token', resp.data)
window.location.href = "/web/orderList"
}*/
typeof callback == 'function' && callback(res);
}
},
error: function (res) {
layer.msg('网络出现问题,请重试!')
}
})
},
......@@ -64,80 +67,35 @@
return true;
},
handleBind: function (opt) {
//验证码
$(opt.code).on('click', function () {
$(this).find('img').attr('src', '/helper/captcha?' + new Date().getTime())
});
//提交
$("#submit").on('click', function () {
$(opt.submit).on('click', function () {
if (opt.calcForm(opt)) {
opt.getData(function (res) {
console.log(res)
});
opt.getData(function (res) {
setCookie('yunxin_token', resp.data)
window.location.href = "/web/orderList"
});
}
});
$("input[name='username']").on('blur', function () {
opt.calcForm(opt);
});
$("input[name='pwd']").on('blur', function () {
opt.calcForm(opt);
});
$("input[name='code']").on('blur', function () {
opt.calcForm(opt);
});
return this;
},
}, $(function () {
loginController.init();
})
}();
/**
* Created by hcy on 2019/2/19.
*/
function login() {
$.ajax({
url:_URL_+'/api/ApiLogin',
type:'post',
data:{
'mobile':$("#mobile").val(),
'password':$.md5($("#password").val()),
'code': $("#code").val()
},
async: false,
dataType:'json',
timeout:10000,
success:function (resp) {
if(resp.code > 0 ){
alert(resp.msg)
}else{
delCookie('yunxin_token') //先删除cookie
setCookie('yunxin_token',resp.data)
window.location.href = "/web/orderList"
}
}
})
}
function setCookie(name,value){
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*30);
document.cookie = name + "="+ escape (value) + ";path=/;expires=" + exp.toGMTString()+";domain=."+_DOMAIN_;
}
function getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
function delCookie(key) {
var date = new Date();
date.setTime(date.getTime() - 1);
var delValue = getCookie(key);
if (!!delValue) {
document.cookie = key+'='+delValue+';expires='+date.toGMTString();
}
}
\ No newline at end of file
}();
\ No newline at end of file
......@@ -103,5 +103,3 @@
})(window);
var _URL_ = "http://yunxin.liexin.com";
......@@ -55,7 +55,7 @@
<div class="code-inp fl">
<input type="text" placeholder="请输入验证码" name="code">
</div>
<div class="code-img fr">
<div class="code-img fr" id="code">
<img src="/helper/captcha" alt="">
<a href="javascript:;">换一张</a>
</div>
......@@ -180,7 +180,8 @@
</div>
<!--footer end-->
<script type="text/javascript" src="/pc/js/jquery.min.js"></script>
<script type="text/javascript" src="/pc/js/layui/layui.js"></script>
<script type="text/javascript" src="/pc/js/global.js"></script>
<script type="text/javascript" src="/pc/js/layui/layui.all.js"></script>
<script type="text/javascript" src="/pc/js/md5/jquery.md5.js"></script>
<script type="text/javascript" src="/pc/js/controller/Login.js"></script>
</body>
......
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