mui.init(); //初始化单页view var viewApi = mui('#app').view({ defaultPage: '#setting' }); window.addEventListener('refresh', function(e){//执行刷新 adminTx(); }); var a = localStorage.getItem('token') var mineTx; //初始化单页的区域滚动 mui('.mui-scroll-wrapper').scroll(); function adminTx() { mui.ajax(huayi.config.callcenter_url + '/UserAccount/GetNowUser', { data: { token: a, }, dataType: 'json', //服务器返回json格式数据 type: 'get', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' }, success: function(data) { var RoleCode = data.data.role.F_RoleCode; $(".F_UserName").text(data.data.user.F_UserName); $(".rolname").text(data.data.user.F_UserCode); if(!data.data.FileUrl[0]) { $('.top_left img').attr("src", "img/3.png"); }else{ $('.top_left img').attr("src", data.data.FileUrl[0].F_Url); } }, error: function(xhr, type, errorThrown) { //异常处理; } }); } // //检测网络连接 mui.plusReady(function() { adminTx(); var Code_; var NewCode_; var server = huayi.config.callcenter_url + "ApplicationsVersion/GetAndroid?"; //获取升级描述文件服务器地址 document.addEventListener("netchange", wainshow, false); plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) { // $("#Vb").text(wgtinfo.version); // var // $('.update').text(Code_); console.log("当前应用版本:" + wgtinfo.version + "---" + plus.runtime.version); localStorage.setItem("Code", wgtinfo.version) //缓存保存版本号; Code_ = localStorage.getItem("Code"); $('.update').text(Code_); // Gx(); }); //检查更新 document.getElementById("update").addEventListener('tap', function() { var server = huayi.config.callcenter_url + "ApplicationsVersion/GetAndroid?"; //获取升级描述文件服务器地址 mui.ajax(server, { data: { isNew: true, token: a }, dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' }, success: function(data) { if(data.state == "success") { NewCode_ = data.data.F_VersionCode; localStorage.setItem("Code", NewCode_); //缓存保存版本号; if(Code_ != NewCode_) { var Codes = localStorage.setItem("Code", NewCode_); console.log(Codes); plus.nativeUI.confirm("发现新版本", function(event) { var tapIndex = event.index; if(tapIndex == 0) { plus.runtime.openURL(data.data.FileUrl[0].F_Url); } else { mui.toast("取消更新"); } }, "提示", ["立即更新", "取消", ]) } } else { mui.toast(data.message); } }, error: function(data) { //异常处理; console.log(data.message); } }) }); var backcount = 0; mui.back = function() { if(mui.os.ios) return; if(backcount > 0) { if(window.plus) plus.runtime.quit(); return; }; mui.toast('再按一次退出应用'); backcount++; setTimeout(function() { backcount = 0; }, 2000); }; //用户管理 $("#management").on('tap', function() { mui.openWindow({ id: 'Setting_manage', url: 'Common/Setting_manage.html', createNew: true, }); }) }); //检测网络连接 function wainshow() { if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) { mui.toast("网络异常,请检查网络设置!"); } else { mui.toast("网络连接"); } } //常见问题 document.getElementById('Question').addEventListener('tap', function() { var nwaiting = plus.nativeUI.showWaiting(); webviewShow = plus.webview.create("Common/portrait_head.html"); //后台创建webview并打开show.html webviewShow.addEventListener("loaded", function() { //注册新webview的载入完成事件 nwaiting.close(); //新webview的载入完毕后关闭等待框 webviewShow.show("slide-in-right", 300); //把新webview窗体显示出来,显示动画效果为速度300毫秒的右侧移入动画 }, false); }); //常见问题 document.getElementById('fwsz').addEventListener('tap', function() { var nwaiting = plus.nativeUI.showWaiting(); webviewShow = plus.webview.create("Common/Setting-SZ.html"); //后台创建webview并打开show.html webviewShow.addEventListener("loaded", function() { //注册新webview的载入完成事件 nwaiting.close(); //新webview的载入完毕后关闭等待框 webviewShow.show("slide-in-right", 300); //把新webview窗体显示出来,显示动画效果为速度300毫秒的右侧移入动画 }, false); }); //常见问题 document.getElementById('Bom').addEventListener('tap', function() { var nwaiting = plus.nativeUI.showWaiting(); webviewShow = plus.webview.create("Common/Setting-Bm.html"); //后台创建webview并打开show.html webviewShow.addEventListener("loaded", function() { //注册新webview的载入完成事件 nwaiting.close(); //新webview的载入完毕后关闭等待框 webviewShow.show("slide-in-right", 300); //把新webview窗体显示出来,显示动画效果为速度300毫秒的右侧移入动画 }, false); }); //退出 document.getElementById('exit').addEventListener('tap', function() { var btnArray = [{ title: "注销当前账号" }, { title: "直接关闭应用" }]; plus.nativeUI.actionSheet({ cancel: "取消", buttons: btnArray }, function(event) { var index = event.index; switch(index) { case 1: //注销账号 plus.runtime.restart(); break; case 2: plus.runtime.quit(); break; } }); }, false); function logout() { $.ajax({ url: huayi.config.callcenter_url + "Login/Logout", data: { token: a }, dataType: "json", type: 'post', //HTTP请求类型 success: function(res) { if(res.state == "success") { localStorage.clear(); mui.alert(res.data); } } }); } function Clean() { $("#mobile").val(''); $("#title").val(''); $("#content").val(''); } var view = viewApi.view; (function($) { //处理view的后退与webview后退 var oldBack = $.back; $.back = function() { if(viewApi.canBack()) { //如果view可以后退,则执行view的后退 viewApi.back(); } else { //执行webview后退 oldBack(); } }; //监听页面切换事件方案1,通过view元素监听所有页面切换事件,目前提供pageBeforeShow|pageShow|pageBeforeBack|pageBack四种事件(before事件为动画开始前触发) //第一个参数为事件名称,第二个参数为事件回调,其中e.detail.page为当前页面的html对象 view.addEventListener('pageBeforeShow', function(e) { // console.log(e.detail.page.id + ' beforeShow'); }); view.addEventListener('pageShow', function(e) { // console.log(e.detail.page.id + ' show'); }); view.addEventListener('pageBeforeBack', function(e) { // console.log(e.detail.page.id + ' beforeBack'); }); view.addEventListener('pageBack', function(e) { // console.log(e.detail.page.id + ' back'); }); })(mui); //点击两次就退出软件