You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.4 KiB

function show(id){
//removeClass
var t = document.getElementById('account');//選取id為test的div元素
t.style.display = 'none';// 隱藏選擇的元素
t.style.display = 'block';// 以塊級樣式顯示
}
function login(){
var account = $('.account').val();
var password = $('.password').val();
var url = "loginapi.php";
$.ajax({
method: 'post',
url: url,
data: {
account:account,
password:password
},
success: function (data) {
console.log('返回的結果');
res=eval("("+data+")");
console.log(res);
console.log(window.location.host);
console.log(res.code);
if(res.code=='200'){
var token=res.token;
console.log(token);
var token=res.token;
var name=res.name;
var account=res.account;
window.localStorage.setItem("name",name);
window.localStorage.setItem("token",token);
window.localStorage.setItem("account",account);
window.location.href='faultreview-index.php?account='+account;
}else{
window.location.href='login.php?errno=1';
}
}
});
}
function settoken(v){
window.localStorage.setItem("token",v);
}
function gettoken(v){
window.localStorage.getItem("token");
}