blob: db3d7ceb0d93db17d483009e4a4bc9dca7f1229a [file] [log] [blame]
var app = {
/*
thirdapp:
closeBrowser(){
if(history.length==1){
window.open('mobile/close');
}else{
history.back();
}
}
<a href="javascript:;" onclick="closeBrowser()">Close</a>
client:
var ref = window.open(encodeURI(url), '_blank','location=no');
ref.addEventListener('loadstart', function(event) {
if (event.url.match("mobile/close")) {
ref.close();
}
});
*/
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
onDeviceReady: function() {
var uid = window.localStorage.getItem("token");
if (isEmpty(uid)) {
window.location = "login.html";
} else {
//尝试登陆
V1Infor(function(ok, ret) {
console.log(ret)
if (ok) {
if(ret.code==200){
if(!isEmpty(ret.token)){
window.localStorage.setItem("token",ret.token);
}
window.location = "main.html";
}else{
window.location = "login.html";
}
} else {
//alert('无法请求到服务器,请检查网络并稍后再试');
if (ret.status == 401) {
//need login
window.location = "login.html";
} else {
//TODO ,没有网络
window.location = "main.html";
}
}
})
}
}
};
app.initialize();