附上登录页和main页面
<!DOCTYPE html>
<html class="ui-page-login">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<link href="css/mui.min.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet" />
<style>
.area {
margin: 20px auto 0px auto;
}
.mui-input-group {
margin-top: 10px;
}
.mui-input-group:first-child {
margin-top: 20px;
}
.mui-input-group label {
width: 22%;
}
.mui-input-row label~input,
.mui-input-row label~select,
.mui-input-row label~textarea {
width: 78%;
}
.mui-checkbox input[type=checkbox],
.mui-radio input[type=radio] {
top: 6px;
}
.mui-content-padded {
margin-top: 25px;
}
.mui-btn {
padding: 10px;
}
.link-area {
display: block;
margin-top: 25px;
text-align: center;
}
.spliter {
color: #bbb;
padding: 0px 8px;
}
.oauth-area {
position: absolute;
bottom: 20px;
left: 0px;
text-align: center;
width: 100%;
padding: 0px;
margin: 0px;
}
.oauth-area .oauth-btn {
display: inline-block;
width: 50px;
height: 50px;
background-size: 30px 30px;
background-position: center center;
background-repeat: no-repeat;
margin: 0px 20px;
/*-webkit-filter: grayscale(100%); */
border: solid 1px #ddd;
border-radius: 25px;
}
.oauth-area .oauth-btn:active {
border: solid 1px #aaa;
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<h1 class="mui-title">登录</h1>
</header>
<div class="mui-content">
<form id='login-form' class="mui-input-group">
<div class="mui-input-row">
<label>账号</label>
<input id='account' type="text" class="mui-input-clear mui-input" placeholder="请输入账号">
</div>
<div class="mui-input-row">
<label>密码</label>
<input id='password' type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
</div>
</form>
<form class="mui-input-group">
<ul class="mui-table-view mui-table-view-chevron">
<li class="mui-table-view-cell">
自动登录
<div id="autoLogin" class="mui-switch">
<div class="mui-switch-handle"></div>
</div>
</li>
</ul>
</form>
<div class="mui-content-padded">
<button id='login' class="mui-btn mui-btn-block mui-btn-primary">登录</button>
<div class="link-area">
<a id='ipConfig'>IP配置</a>
<!--<span class="spliter">|</span>
<a id='forgetPassword'>忘记密码</a>-->
</div>
</div>
<div class="mui-content-padded oauth-area">
</div>
</div>
<script src="js/layer.m.js"></script>
<script src="js/jquery-1.10.1.min.js"></script>
<script src="js/mui.min.js"></script>
<script src="js/mui.enterfocus.js"></script>
<script src="js/app.js"></script>
<script>
(function(doc) {
mui.init({
statusBarBackground: '#f7f7f7'
});
mui.plusReady(function() {
plus.screen.lockOrientation("portrait-primary");
var settings = app.getSettings();
var state = app.getState();
//获取记录的IP
var value = plus.storage.getItem('ipconfig');
if (value) {} else {
value = 'http://192.168.1.1';
}
var toMain = function() {
var mainPage = mui.preload({
"id": 'main',
"url": value + '/main.html'
});
mui.fire(mainPage, 'show', null);
setTimeout(function() {
mui.openWindow({
id: 'main',
url: value + '/main.html',
show: {
aniShow: 'pop-in'
},
waiting: {
autoShow: false
}
});
}, 0);
};
//检查用户名和密码是否储存
var default_username = plus.storage.getItem("username");
var default_password = plus.storage.getItem("password");
// close splash
setTimeout(function() {
//关闭 splash
plus.navigator.closeSplashscreen();
}, 600);
//检查 "登录状态/锁屏状态" 结束
var loginButton = doc.getElementById('login');
var accountBox = doc.getElementById('account');
var passwordBox = doc.getElementById('password');
var autoLoginButton = doc.getElementById("autoLogin");
var ipButton = doc.getElementById("ipConfig");
//赋予默认的用户名和密码
accountBox.value = default_username;
passwordBox.value = default_password;
//判断是否自动登录
if (settings.autoLogin) {
var loginInfo = {
account: accountBox.value,
password: passwordBox.value
};
//检查令牌有效期
mui.ajax(value + '/mobile_new/linkurl.ashx?token=' + plus.storage.getItem("token"), {
type: 'post',
timeout: 15000,
success: function(data) {
if (data == "1") {
toMain();
} else {
mui.ajax(value + '/mobile_new/linkurl.ashx', {
data: loginInfo,
type: 'post',
timeout: 15000,
success: function(data) {
if (data != 'Error') {
//储存登录用户名和密码
plus.storage.setItem("username", accountBox.value);
plus.storage.setItem("password", passwordBox.value);
plus.storage.setItem("token", data);
plus.nativeUI.toast("登录成功!");
toMain();
} else {
alert("用户名或密码错误!");
}
}
})
}
}
});
}
loginButton.addEventListener('tap', function(event) {
var loginInfo = {
account: accountBox.value,
password: passwordBox.value
};
value = plus.storage.getItem('ipconfig');
if (value) {} else {
value = 'http://192.168.1.1';
}
var w = plus.nativeUI.showWaiting("加载中,请稍候...\n", {
modal: false
});
mui.ajax(value + '/mobile_new/linkurl.ashx', {
data: loginInfo,
type: 'post',
timeout: 5000,
success: function(data) {
if (data != 'Error') {
//储存登录用户名和密码
plus.storage.setItem("username", accountBox.value);
plus.storage.setItem("password", passwordBox.value);
plus.storage.setItem("token", data);
plus.nativeUI.toast("登录成功!");
w.close();
toMain();
} else {
w.close();
alert("用户名或密码错误!");
}
},
error: function(type) {
w.close();
plus.nativeUI.toast("连接超时,请检查您的网络连接或者IP配置是否正确!");
}
})
});
mui.enterfocus('#login-form input', function() {
mui.trigger(loginButton, 'tap');
});
autoLoginButton.classList[settings.autoLogin ? 'add' : 'remove']('mui-active')
autoLoginButton.addEventListener('toggle', function(event) {
setTimeout(function() {
var isActive = event.detail.isActive;
settings.autoLogin = isActive;
app.setSettings(settings);
}, 50);
}, false);
ipButton.addEventListener('tap', function(event) {
mui.openWindow({
url: 'ipConfig.html',
id: 'ipConfig',
show: {
aniShow: 'pop-in'
},
styles: {
popGesture: 'hide'
},
waiting: {
autoShow: true
}
});
}, false);
/*regButton.addEventListener('tap', function(event) {
$.openWindow({
url: 'reg.html',
id: 'reg',
show: {
aniShow: 'pop-in'
},
styles: {
popGesture: 'hide'
},
waiting: {
autoShow: false
}
});
}, false);*/
/*forgetButton.addEventListener('tap', function(event) {
$.openWindow({
url: 'forget_password.html',
id: 'forget_password',
show: {
aniShow: 'pop-in'
},
styles: {
popGesture: 'hide'
},
waiting: {
autoShow: false
}
});
}, false);*/
//
/*window.addEventListener('resize', function() {
oauthArea.style.display = document.body.clientHeight > 400 ? 'block' : 'none';
}, false);*/
//
var backButtonPress = 0;
mui.back = function(event) {
backButtonPress++;
if (backButtonPress > 1) {
plus.runtime.quit();
} else {
plus.nativeUI.toast('再按一次退出应用');
}
setTimeout(function() {
backButtonPress = 0;
}, 1000);
return false;
};
});
}(document));
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<link href="css/mui.min.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet" />
<style>
ul {
font-size: 14px;
color: #8f8f94;
}
.mui-btn {
padding: 10px;
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav" style="padding-right: 15px;">
<button id='homeing' class=" mui-pull-left mui-btn-link" style="display: none;">主页</button>
<h1 class="mui-title" >SRM科研管理系统</h1>
<button id='setting' class=" mui-pull-right mui-btn-link" >设置</button>
</header>
<div class="mui-content">
<div class="mui-content-padded">
<P>456您好 <span id='account'></span>,您已成功登录。</P>
<div style="width:100%">
<div style="width:49%;float: left;">
<img id='camera' src="images/1.png" class="divs" style="width:100%;height: 100%;" />
<img id='chartList' src="images/5.png" class="divs" style="width:100%;height: 100%;" />
</div>
<div style="width:49%;float: right;">
<img id='default' src="images/2.png" class="divs" style="width:100%;height: 100%;" />
<img id='mynews' src="images/3.png" class="divs" style="width:100%;height: 100%;" />
<img id='myreserach' src="images/4.png" class="divs" style="width:100%;height: 100%;" />
</div>
</div>
</div>
</div>
<script src="js/mui.min.js"></script>
<script src="js/app.js"></script>
<script>
(function($, doc) {
//
/*window.addEventListener('show', function() {
}, false);*/
$.plusReady(function() {
//欢迎词
var account = doc.getElementById('account');
account.innerText = plus.storage.getItem("username");
//home
var homeingButton = doc.getElementById('homeing');
homeingButton.addEventListener('tap', function(event) {
$.openWindow({
id: 'main.html',
url:'main.html',
show: {
aniShow: 'pop-in'
},
styles: {
popGesture: 'hide'
},
waiting: {
autoShow: false
}
});
});
var settingPage = $.preload({
"id": 'setting',
"url": 'setting.html'
});
//设置
var settingButton = doc.getElementById('setting');
//settingButton.style.display = settings.autoLogin ? 'block' : 'none';
settingButton.addEventListener('tap', function(event) {
$.openWindow({
id: 'setting',
show: {
aniShow: 'pop-in'
},
styles: {
popGesture: 'hide'
},
waiting: {
autoShow: false
}
});
});
//审核
var defaultButton = doc.getElementById("default");
defaultButton.addEventListener('tap',function(event){
mui.openWindow({
id:'default',
url:'mobile_new/default.html',
show: {
aniShow: 'pop-in'
},
styles: {
popGesture: 'hide'
},
waiting: {
autoShow: false
}
});
});
//我的科研
var myreserachButton = doc.getElementById("myreserach");
myreserachButton.addEventListener('tap',function(event){
mui.openWindow({
id:'myreserach',
url:'mobile_new/MyResearch.html',
show: {
aniShow: 'pop-in'
},
styles: {
popGesture: 'hide'
},
waiting: {
autoShow: false
}
});
});
//信息
var mynewsButton = doc.getElementById('mynews');
mynewsButton.addEventListener('tap',function(event){
//新页面打开
mui.openWindow({
id:'mynews',
url:'mobile_new/mynews.html',
show: {
aniShow: 'pop-in'
},
styles: {
popGesture: 'hide'
},
waiting: {
autoShow: false
}
});
});
//照相
var cameraPage = $.preload({
"id": 'camera',
"url": 'mobile_new/camera.html'
});
var cameragButton = doc.getElementById('camera');
//settingButton.style.display = settings.autoLogin ? 'block' : 'none';
cameragButton.addEventListener('tap', function(event) {
//新页面打开
mui.openWindow({
id: 'camera',
show: {
aniShow: 'pop-in'
},
styles: {
popGesture: 'hide'
},
waiting: {
autoShow: false
}
});
});
//科研统计报表
var chartListPage = $.preload({
"id": 'chartList',
"url": 'mobile_new/chartList.html'
});
var chartListButton = doc.getElementById('chartList');
//settingButton.style.display = settings.autoLogin ? 'block' : 'none';
chartListButton.addEventListener('tap', function(event) {
//新页面打开
mui.openWindow({
url: 'mobile_new/chartList.html',
show: {
aniShow: 'pop-in'
},
styles: {
popGesture: 'hide'
},
waiting: {
autoShow: false
}
});
});
//--
$.oldBack = mui.back;
var backButtonPress = 0;
$.back = function(event) {
backButtonPress++;
if (backButtonPress > 1) {
plus.runtime.quit();
} else {
plus.nativeUI.toast('再按一次退出应用');
}
setTimeout(function() {
backButtonPress = 0;
}, 1000);
return false;
};
});
}(mui, document));
</script>
</body>
</html>
从main跳转到其他的功能页面的时候一定会卡半分钟左右。之后再切换其他页面的时候就不卡了。
非常奇怪,求教原因。
如梦渲染 (作者)
重现不能,重新编译了一次之后不卡了。之前也是忽然之间卡顿的,同一个app。
2015-11-10 17:43