34 lines
846 B
JavaScript
34 lines
846 B
JavaScript
|
|
$(".submitLogin").click(function() {
|
|
|
|
var userName = $("input[type='text']").val()
|
|
var userPassword = $("input[type='password']").val()
|
|
|
|
if(userName.length == 0 || userPassword.length ==0) {
|
|
alert("账户密码为空")
|
|
} else {
|
|
$.ajax({
|
|
url: 'http://127.0.0.1:3000/admin/api/login',
|
|
type: 'POST',
|
|
headers: {
|
|
token: '645e8c56a66e32792f224730fd238711'
|
|
},
|
|
data: {
|
|
name: userName,
|
|
pwd: userPassword
|
|
},
|
|
success: function(res) {
|
|
if (res.status == 200) {
|
|
location.href = "/admin/home"
|
|
} else {
|
|
alert(res.message)
|
|
}
|
|
},
|
|
error: function(err) {
|
|
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
}); |