| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <link href="../css/mui.min.css" rel="stylesheet" />
- <link rel="stylesheet" type="text/css" href="../css/common.css" />
- </head>
- <body>
- <header class="mui-bar mui-bar-nav">
- <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
- <h1 class="mui-title">设置</h1>
- </header>
- <div class="mui-content">
- <ul class="mui-table-view" id="user" style="margin-top: 15px;">
- <li class="mui-table-view-cell">
- <div>接受新消息通知</div>
- <div class="mui-switch mui-switch-mini mui-switch-blue" id="ReceiveNews">
- <div class="mui-switch-handle"></div>
- </div>
- </li>
- <li class="mui-table-view-cell" id='cache'>
- <a class="mui-navigate-right">清除缓存</a>
- </li>
- </ul>
- <ul class="mui-table-view" id="" style="margin-top: 15px;">
- <li class="mui-table-view-cell" id='quitBtn'>
- <a class="mui-navigate-right">退出</a>
- </li>
- </ul>
- </div>
- <script src="../js/mui.min.js"></script>
- <script type="text/javascript">
- mui.init();
- var isActive = document.getElementById("ReceiveNews").classList.contains("mui-active");
- if(isActive) {
- console.log("打开状态");
- } else {
- console.log("关闭状态");
- }
- document.getElementById("ReceiveNews").addEventListener("toggle", function(event) {
- if(event.detail.isActive) {
- console.log("你启动了开关");
- } else {
- console.log("你关闭了开关");
- }
- })
- document.getElementById("cache").addEventListener('tap', function() {
- plus.cache.calculate(function(size) {
- console.log(size)
- sizeCache = size;
- // 您目前的系统缓存为" + parseFloat(sizeCache / (1024 * 1024)).toFixed(2) + "M?
- mui.confirm("清除后App中的数据将会被清理,用户需重新登录", "清除缓存", ["确认", "取消"], function(e) {
- if(e.index == 1) {} else {
- plus.cache.clear(function() {
- clearAllItem()
- });
- }
- });
- });
- })
- //清除所有内容
- function getLengthFun() {
- return plus.storage.getLength();
- }
- function clearAllItem() {
- plus.storage.clear();
- var num = getLengthFun();
- if(num == 0) {
- plus.nativeUI.toast("重置成功,2秒后重启app。", {
- verticalAlign: "center"
- });
- /**
- * 2秒后重启应用
- * http://www.html5plus.org/doc/zh_cn/runtime.html#plus.runtime.restart
- */
- setTimeout(function() {
- plus.runtime.restart();
- }, 2000);
- } else {
- toast('重置失败')
- }
- }
- //退出选择
- document.getElementById('quitBtn').addEventListener('tap', function() {
- plus.nativeUI.actionSheet({
- // title: '退出',
- cancel: '取消',
- buttons: [{
- title: '退出登录'
- }, {
- title: '关闭程序'
- }]
- }, function(b) {
- switch(b.index) {
- case 0:
- break;
- case 1:
- //退出登录
- var username = plus.storage.getItem('username');
- console.log(username)
- mui.ajax('http://120.27.222.26/app_logout',{
- data:{
- username:username
- },
- dataType:'json',//服务器返回json格式数据
- type:'post',//HTTP请求类型
- timeout:10000,//超时时间设置为10秒;
- success:function(data){
- if(data == 0){
- plus.storage.clear();
- mui.openWindow({
- url:'../home/login.html',
- id:'login'
- })
- }
- },
- error:function(xhr,type,errorThrown){
- console.log(type)
-
- }
- });
- break;
- case 2:
- //关闭程序
- plus.runtime.quit();
- break;
- default:
- break;
- }
- }, false);
- })
- </script>
- </body>
- </html>
|