123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760 |
- mui.init({
- keyEventBind: {
- backbutton: false //Boolean(默认true)关闭back按键监听
- }
- });
- function loginIm(userId,token,client_id,platform){
- if(token!=null){
- imClient.Users.login(userId, token, client_id, platform, function(res){
-
- }, function(res){
- alert("聊天服务器登录失败!");
- console.error("im_loin_fail: "+JSON.stringify(res))
- })
- }else{
- var info = plus.push.getClientInfo();
- var tokenNew = info.token;
- var client_idNew = info.clientid;
- setTimeout(function(){
- imClient.Users.login(userId, tokenNew, client_idNew, platform, function(res){
-
- }, function(res){
- alert("聊天服务器登录失败!");
- console.error("im_loin_fail: "+JSON.stringify(res))
- })
- },1000);
- }
- }
- var teamCount = 0;
- var topoffset = "0px";
- var wgtVer = null;
- mui.plusReady(function() {
- /**
- * 勿删
- */
- /*if(plus.navigator.isImmersedStatusbar()){
- topoffset = Math.round(plus.navigator.getStatusbarHeight()) + 'px';
- }*/
-
- /*
- * 退出事件
- */
-
-
- //清空角标
- clearInc();
-
-
- var first = null;
- mui.back = function() {
- if(!first) {
- first = new Date().getTime();
- plus.nativeUI.toast("再按一次退出");
- setTimeout(function() {
- first = null;
- }, 1000);
- } else {
- if(new Date().getTime() - first < 1000) {
- var userId = plus.storage.getItem("im_userid");
- imClient.Users.updateStatus(userId, 0);
- setTimeout(function(){
- plus.runtime.quit();
- },500);
-
-
-
- }
- }
- }
-
- //plus.nativeUI.showWaiting();
- sendPost("doctor/baseinfo", {}, null, function(res) {
- if(res.status == 200) {
- var infoStr = JSON.stringify(res.data);
- plus.storage.setItem("docInfo", infoStr);
- var userRole=JSON.stringify(res.data.userRole);//级别 省市县区
- plus.storage.setItem("hospital", res.data.hospital);
- plus.storage.setItem("userRole", userRole);
- sendGet("/doctor/admin-teams/team/"+ res.data.code +"/teams", {}, null, function(res){
- if(res.status==200){
- plus.storage.setItem("teamInfo", JSON.stringify(res));
- teamCount = res.data.length;
- initApp();
- } else
- mui.toast("获取医生团队失败")
- //plus.nativeUI.closeWaiting();
- })
- } else {
- mui.toast("获取医生信息失败");
- mui.openWindow({
- id: "login",
- url: "../../login/html/login.html",
- extras: {
-
- }
- })
- }
- });
-
- //运行环境从后台切换到前台事件
- document.addEventListener("resume", function() {
- // console.log("运行环境从后台切换到前台事件")
- var userId = plus.storage.getItem("im_userid");
- imClient.Users.updateStatus(userId, 0);
- //清空角标
- clearInc();
- }, false);
- //运行环境从前台切换到后台事件
- document.addEventListener("pause", function() {
- // console.log("运行环境从前台切换到后台事件")
- var userId = plus.storage.getItem("im_userid");
- imClient.Users.updateStatus(userId, 1);
- //清空角标
- clearInc();
- }, false);
-
- //监听推送的消息
- plus.push.addEventListener("receive", function(msg){
- plusReceive(msg);
- }, false);
- plus.push.addEventListener("click", function(msg) {
- plusClick(msg);
- }, false);
-
- //判断版本信息显示小红点
- plus.runtime.getProperty(plus.runtime.appid, function(inf){
- wgtVer = inf.version;
- if(plus.os.name == "iOS") {
- // 检测app小版本的更新
- checkUpgrade();
- } else if(plus.os.name == "Android") {
- // 先检测大版本的更新,如果没有再检测app小版本的更新
- checkVersion();
- }
- });
- /*
- * 在安卓条件下检查版本
- */
- function checkVersion() {
- mui.ajax(server + 'version/app', {
- data: {
- version: 0,//获取当前版本的所有信息,然后以version_int号来校验升级信息
- code: "app_doc"
- },
- dataType: 'json', //服务器返回json格式数据
- type: 'post', //HTTP请求类型
- timeout: 10000, //超时时间设置为10秒;
- success: function(res) {
- console.log(JSON.stringify(res));
- if(res.status == 200) {
- if(res.data && res.data.version_int && (res.data.version_int > curr_app_version)) {
- $('#mine_point').show();
- }else {
- // 没有大版本时就检测小版本的升级
- checkUpgrade();
- }
- }
- },
- error: function(xhr, type, errorThrown) {
- if(type == "timeout" || type == "abort" || type == "error") {
- plus.nativeUI.toast("网络错误: 无法进行版本升级检测!");
- }
- }
- });
- }
- // 检测app小版本的更新
- function checkUpgrade(){
- mui.ajax(server + 'version/app', {
- data: {
- version: 0,//资源包不以version_int号来校验升级信息,而以version_str判断.version_str不相同就会升级。
- code: "wgt"
- },
- dataType: 'json', //服务器返回json格式数据
- type: 'post', //HTTP请求类型
- timeout: 10000, //超时时间设置为10秒;
- success: function(res) {
- console.log(JSON.stringify(res));
- if(res.status == 200) {
- if(res.data && res.data.version_str && wgtVer && (res.data.version_str != wgtVer)) {
- $('#mine_point').show()
- }
- }
- },
- error: function(xhr, type, errorThrown) {
- if(type == "timeout" || type == "abort" || type == "error") {
- plus.nativeUI.toast("网络错误: 无法进行版本升级检测!");
- }
- }
- });
- }
- });
- function initApp(){
- var self = plus.webview.currentWebview();
- var docInfo = JSON.parse(plus.storage.getItem("docInfo"));//doctor表中的level
- var level = docInfo.level;
- //level与docType的值一致,将level值存储为docType raolu 20170118
- plus.storage.setItem('docType', level+"");
-
- var docType = plus.storage.getItem("docType");
- // var docType = plus.storage.getItem("docType");
- if(!docType) {
- alert("获取医生类型失败");
- }
- var userAgent = JSON.parse(plus.storage.getItem("userAgent"));
- var userId = userAgent.uid;
- var info = plus.push.getClientInfo();
- var token = info.token;
- var client_id = info.clientid;
- var platform = 0;
- if(plus.os.name == "Android") { //ios暂无im功能 只在安卓下才执行该方法
- platform = 1;
- }
- //如果当前状态是观察者模式,则不登录IM。
- if(!userAgent.observer){
- loginIm(userId,token,client_id,platform);
- }
-
- var subPages = [];
- //docType 10 是管理员
- // docType="10"
- switch(docType) {
- case "1":
- subPages = ["home1.html", "huanzhe-specal.html", "../../contact/html/contacts-zk.html", "mine.html"];
- // if(teamCount > 0){
- // $(".mui-tab-item").eq(2).show();
- // subPages.push("../../tuandui/html/tuandui.html");
- // }
- $(".mui-tab-item").eq(3).hide();
- $(".mui-tab-item").eq(2).find(".mui-tab-label").text("通讯录");
- $(".mui-tab-item").eq(2).attr("data-src", "../../contact/html/contacts-zk.html")
- $(".mui-tab-item").eq(2).show();
- $(".mui-tab-item").eq(1).attr("data-src", "huanzhe-specal.html")
- $(".mui-tab-item").eq(1).show();
- $(".mui-tab-item").eq(0).attr("data-src", "home1.html")
- break;
- case "2":
- case "3":
- subPages = ["home2.html", "huanzhe.html", "../../tuandui/html/tuandui.html", "xiaoxi.html", "mine.html"];
- if(teamCount > 0){
- $(".mui-tab-item").eq(1).show();
- $(".mui-tab-item").eq(2).show();
- subPages.push("../../tuandui/html/tuandui.html");
- }
- break;
- case "10":
- subPages = ["admin.html", "mine.html"];
- if(level!=10){
- if(teamCount > 0){
- subPages.push("../../tuandui/html/tuandui.html");
- }
- subPages.push("huanzhe.html");
- subPages.push("xiaoxi.html");
- }
- $(".mui-tab-item").eq(2).hide();
- $(".mui-tab-item").eq(1).hide();
- $(".mui-tab-item").eq(3).hide();
- $(".mui-tab-item").eq(0).attr("data-src","admin.html")
- break;
- default:
- break;
- }
-
- if(isMultiRole()){
- subPages.push("admin.html");
- //初始化角色切换事件
- qiehuanInit(self);
- }
- $('.mui-bar').show();
- var subStyles = {
- top: topoffset,
- bottom: "51px",
- scorllIndicator: "none",
- bounceBackground: "#17b3ec"
- };
- // for(var i = 0; i < subPages.length; i++) {
- // var sub_wv ;
- // var ws = plus.webview.getWebviewById(subPages[i]);
- // if(ws){
- // continue;
- // }
- // else
- // sub_wv = plus.webview.create(subPages[i], subPages[i], subStyles);
- // if(i > 0) {
- // sub_wv.hide();
- // }
- //
- // self.append(sub_wv);
- // }
- //添加返回管理员账号时,显示admin页面
- if(plus.storage.getItem('backToAdmin')){
- console.log("back to admin");
-
- var ws = mui.openWindow({
- url:"admin.html",
- id:"admin.html",
- styles:subStyles,
- waiting:{
- autoShow:true,//自动显示等待框,默认为true
- title:'正在加载...'//等待对话框上显示的提示内容
- }
- });
- self.append(ws);
- $(".mui-tab-item").eq(2).hide();
- $(".mui-tab-item").eq(1).hide();
- $(".mui-tab-item").eq(3).hide();
- $(".mui-tab-item").eq(0).attr("data-src","admin.html");
- mui.later(function(){
- var qiehuan = plus.webview.getWebviewById('qiehuan.html');
- mui.fire(qiehuan, 'checkAdmin');
- console.log("clear backtoAdmin");
- plus.storage.removeItem('backToAdmin');
- }, 2000);
-
- }else{
- var activeSub = subPages[0];
- var ws = plus.webview.getWebviewById(activeSub);
- if(ws){
- ws.show();
- }
- else{
- // ws = plus.webview.create(activeSub, activeSub, subStyles);
- ws = mui.openWindow({
- url:activeSub,
- id:activeSub,
- styles:subStyles,
- waiting:{
- autoShow:true,//自动显示等待框,默认为true
- title:'正在加载...'//等待对话框上显示的提示内容
- }
- });
- }
-
- self.append(ws);
- }
-
- //请求消息数量
- sendPost("/doctor/message/messages",{}, null, function(res){
- if(res.status == 200){
- var data = res.data,
- hasNew = false,
- _hasNew = false;
- for(var k in data){
- if(k == "imMsgCount"){
- var json = JSON.parse(data[k]);
- if(json.count > 0){
- if (json.patientEnd > 0 &&json.patient == 0 && json.doctor== 0) {
- _hasNew = true;
- }
- }
- }else{
- if(data[k].amount > 0){
- hasNew = true;
- }
- }
- }
- if(hasNew){
- $("#point").css('color','red').show();
- }else if(_hasNew){
- $("#point").css('color','blue').show();
- }
- }else{
- mui.toast("获取新消息失败");
- }
- },'POST','',true);
- var aTab = document.querySelectorAll(".mui-tab-item");
- for(var i = 0; i < aTab.length; i++) {
- aTab[i].addEventListener("tap", function() {
- var targetSub = this.getAttribute("data-src");
- if(targetSub == activeSub) {
- return;
- }
- var xxWv = plus.webview.getWebviewById(targetSub);
- if(xxWv) {
- mui.fire(xxWv, "refresh");
- xxWv.show();
- }else{
- // plus.nativeUI.showWaiting();
- // xxWv = plus.webview.create(targetSub, targetSub, subStyles);
- // xxWv.show();
- // plus.nativeUI.closeWaiting();
- xxWv = mui.openWindow({
- url:targetSub,
- id:targetSub,
- styles:subStyles,
- waiting:{
- autoShow:true,//自动显示等待框,默认为true
- title:'正在加载...'//等待对话框上显示的提示内容
- }
- });
- self.append(xxWv);
- }
- if(targetSub=="xiaoxi.html"){
- //$("#point").hide();
- }
- plus.webview.hide(activeSub);
- activeSub = targetSub;
- });
- }
-
- window.addEventListener("activeHuanzhe", function() {
- var items = $(".mui-tab-item");
- mui.trigger(items.get(1), "tap");
- items.removeClass("mui-active");
- mui.later(function() {
- items.eq(1).addClass("mui-active");
- }, 100);
- });
- window.addEventListener("activeXiaoxi", function() {
- var items = $(".mui-tab-item");
- mui.trigger(items.get(3), "tap");
- items.removeClass("mui-active");
- mui.later(function() {
- items.eq(3).addClass("mui-active");
- var xxWv = plus.webview.getWebviewById("xiaoxi.html");
- var yisheng_wv = plus.webview.getWebviewById('yishengim.html');
- xxWv.show();
- mui.fire(xxWv, "ysrefresh");
- mui.fire(yisheng_wv, "xiaoxiUpdate");
- }, 100);
- });
- }
- // 监听离线点击消息事件
- // plus.push.addEventListener("click", function(msg) {
- function plusClick(msg){
- // console.log("click");
- // plus.ui.alert("click");
- var qunzuduihuaView = plus.webview.getWebviewById("dlz");
- if(qunzuduihuaView) {
- $("#red_sign").css("display", "none");
- mui.fire(qunzuduihuaView, "update");
- } else {
- $("#red_sign").css("display", "");
- }
-
- var p2pHtml = plus.webview.getWebviewById("p2p");
- if(p2pHtml) {
- mui.fire(p2pHtml, "update");
- }
-
- var payload;
- if (plus.os.name == "iOS") {
- payload = msg.payload.payload1;
- }
- else {
- payload = JSON.parse(msg.payload);
-
- if (payload.pushtype == 'transmission') { // 透明传输消息
- return;
- } else if (payload.pushtype == 'notify') { // 点击通知栏消息
- payload = JSON.parse(payload.data);
- } else {
- return;
- }
- }
-
- // plus.nativeUI.alert("click事件")
- // plus.nativeUI.alert(JSON.stringify(msg));
- if (payload) {
- if ((payload.business_type=="1" && payload.session_type=="2") || //医生对医生 p2p
- (payload.business_type=="1" && payload.session_type=="3") || //群组
- (payload.business_type=="2" && payload.session_type=="1") || //健康咨询 p2d
- (payload.business_type=="2" && payload.session_type=="2")) //患者名医咨询
- {
- getDoctorTeamInfo(payload);
- }else if (payload.session_type && (payload.business_type == "D_CT_01" || payload.business_type == "D_CT_02")) {
- mui.later(function() {
- openWebview('../../zdzx/html/zhidingzixun.html');
- }, 100);
- }else if (payload.session_type && (payload.session_type == "D_CT_03" || payload.session_type == "D_CT_04")) {
- mui.later(function() {
- openWebview('../../mygl/html/mingyizixunliebiao.html');
- }, 200);
- } else if (payload.session_type && (payload.session_type == "D_SW_01" || payload.session_type == "D_SW_02" || payload.session_type == "D_SW_03" || payload.session_type == "D_SW_04")) {
- mui.later(function() {
- openWebview('../../qygl/html/qianyuexiaoxi.html');
- }, 100);
- } else if (payload.session_type && payload.session_type == "D_HI_01") {
- mui.later(function() {
- openWebview('../../xiaoxi/html/tizhengzhibiao.html');
- }, 100);
- }else if (payload.session_type && payload.session_type == "D_NH_01") {
- mui.later(function() {
- openWebview('../../home/html/xiaoxi.html');
- }, 200);
- } else if (payload.session_type && payload.session_type == "D_NH_01") {
- mui.later(function() {
- openWebview('../../home/html/xiaoxi.html');
- }, 200);
- }else if (payload.session_type && payload.session_type == "D_P_WRD") {
- mui.later(function() {
- openWebview('../../prescription/html/xufangxiaoxi.html',{type:7});
- }, 200);
- }else if (payload.session_type && payload.session_type == "D_CT_05") {
- mui.later(function() {
- openWebview('../../prescription/html/xufangxiaoxi.html',{type:6});
- }, 200);
- }
- }
- // }, false);
- }
-
- // 监听在线消息事件
- // plus.push.addEventListener("receive", function(msg) {
- function plusReceive(msg){
- //if(publish_version == false){
- // mui.toast("您收到一条新消息");
- //}
- // plus.ui.alert(JSON.stringify(msg));
- var qunzuduihuaView = plus.webview.getWebviewById("dlz");
- if(qunzuduihuaView) {
- $("#red_sign").css("display", "none");
- mui.fire(qunzuduihuaView, "update");
- } else {
- $("#red_sign").css("display", "");
- }
-
- //通知一对一聊天更新数据
- var p2pHtml = plus.webview.getWebviewById("p2p");
- if(p2pHtml) {
- //mui.fire(p2pHtml, "update");
- }
- p2pHtml = plus.webview.getWebviewById("p2dzixun");
- if(p2pHtml) {
- //mui.fire(p2pHtml, "update");
- }
-
- //通知团队聊天更新数据
- var tuanduiHtml = plus.webview.getWebviewById("tuanduiqunliao.html")
- || plus.webview.getWebviewById("tuanduiqunliao");
- if(tuanduiHtml) {
- //mui.fire(tuanduiHtml, "update");
- }
- tuanduiHtml = plus.webview.getWebviewById("qiuzhuqunliao");
- if(tuanduiHtml) {
- //mui.fire(tuanduiHtml, "update");
- }
- tuanduiHtml = plus.webview.getWebviewById("qiuzhuqunliao2");
- if(tuanduiHtml) {
- //mui.fire(tuanduiHtml, "update");
- }
-
- var home2 = plus.webview.getWebviewById("home2.html");
- if(home2) {
- mui.fire(home2, "getMsgAmount");
- }
-
- var jumingHtml = plus.webview.getWebviewById("jumingim.html");
- if(jumingHtml) {
- mui.fire(jumingHtml, "update");
- }
-
- var yishengHtml = plus.webview.getWebviewById("yishengim.html");
- if(yishengHtml) {
- mui.fire(yishengHtml, "update");
- }
-
- var xiaoxipage = plus.webview.getWebviewById("xiaoxipage.html");
- if(xiaoxipage) {
- mui.fire(xiaoxipage, "update");
- }
-
-
- var payload;
- var pushtype;
- if (plus.os.name == "iOS") {
- payload = msg.payload.payload1;
- } else {
- payload = JSON.parse(msg.payload);
- if (payload.pushtype == 'transmission') { // 透明传输消息
- return;
- } else if (payload.pushtype == 'notify') { // 点击通知栏消息
- payload = JSON.parse(payload.data);
- } else {
- return;
- }
- }
-
- // plus.nativeUI.alert("receive事件")
- // plus.nativeUI.alert(JSON.stringify(msg));
-
- if (payload) {
- if ((payload.business_type=="1" && payload.session_type=="2") || //医生对医生 p2p
- (payload.business_type=="1" && payload.session_type=="3") || //群组
- (payload.business_type=="2" && payload.session_type=="1") || //健康咨询 p2d
- (payload.business_type=="2" && payload.session_type=="2")) //患者名医咨询
- {
- // getDoctorTeamInfo(payload);
- }
- // else if (payload.business_type && (payload.business_type == "D_CT_01" || payload.business_type == "D_CT_02")) {
- // //D_CT_01, 指定咨询, 您有新的指定咨询
- // //D_CT_02, 指定咨询, 您有新的消息
- // mui.later(function() {
- // openWebview('../html/xiaoxipage.html');
- // }, 200);
- // } else if (payload.business_type && (payload.business_type == "D_CT_03" || payload.business_type == "D_CT_04")) {
- // //D_CT_03, 名医咨询, 您有新的名医咨询(患者发起)
- // //D_CT_04, 名医咨询, 您有新的名医咨询(医生发起)
- // mui.later(function() {
- // openWebview('../html/home1.html');
- // }, 200);
- // } else if (payload.business_type && (payload.business_type == "D_SW_01" || payload.business_type == "D_SW_02" || payload.business_type == "D_SW_03" || payload.business_type == "D_SW_04")) {
- // //家庭签约
- // mui.later(function() {
- // openWebview('../../qygl/html/qianyuexiaoxi.html');
- //// openWebview("../../qygl/html/sign_manage.html")
- // }, 200);
- // } else if (payload.business_type && payload.business_type == "D_HI_01") {//体征指标
- // mui.later(function() {
- //// openWebview('../../xiaoxi/html/tizhengzhibiao.html');
- // openWebview("../../xiaoxi/html/jiankangtizheng.html");
- // }, 200);
- // } else if (payload.business_type && payload.business_type == "D_NH_01") {
- // mui.later(function() {
- //// openWebview('../../home/html/xiaoxi.html');
- // openWebview("../../message/html/xitongxiaoxi.html");
- // }, 200);
- // } else if (payload.business_type && payload.business_type == "D_ST_01") {
- // mui.later(function() {
- // openWebview('../../home/html/home1.html');
- // }, 200);
- // }else if (payload.business_type && (payload.business_type == "D_ST_02"||payload.business_type == "D_ST_03")) {
- // mui.later(function() {
- //// openWebview('../../home/html/home2.html');
- // openWebview('../../qygl/html/qianyuexiaoxi.html');
- // }, 200);
- // }
- //配置随访相关的消息页面跳转:随访计划提醒(4)、随访计划完成消息(D_FU_01)、随访计划阶段完成消息(D_FU_02)、随访计划随访项完成消息(D_FU_03)、患者回答随访记录消息(D_FU_04)
- else if(payload.business_type && (payload.business_type == "4" || payload.business_type == "D_FU_01" || payload.business_type == "D_FU_02" || payload.business_type == "D_FU_03" || payload.business_type == "D_FU_04")){
- // mui.later(function(){
- // openWebview('../../suifang/html/index.html');
- // }, 200);
- }
- }
- // }, false);
- }
- //获取医生团队信息
- function getDoctorTeamInfo(payload){
- imClient.Sessions.getSessionsInfo(payload.session_id,payload.from, function(res){
- // plus.nativeUI.alert(JSON.stringify(res))
- mui.later(function() {
- var params = {sessionId: payload.session_id, sessionName: res.name};
- if (payload.business_type=="1" && payload.session_type=="2") {//医生对医生 p2p
- openWebview("../../message/html/p2p.html",params);
- }else if (payload.business_type=="1" && payload.session_type=="3") {//群组
- openWebview("../../message/html/tuanduiqunliao.html",params);
- }else if (payload.business_type=="2" && payload.session_type=="1") {//健康咨询 p2d
- openWebview("../../message/html/p2dzixun.html",params);
- }else if (payload.business_type=="2" && payload.session_type=="2") {//患者名医咨询
- openWebview("../../message/html/p2dzixun.html",params);
- }
- }, 200);
-
- });
-
- }
- //角标增长
- //function addInc () {
- // var badgeStep = plus.storage.getItem('badge_step');
- // if(!!!badgeStep) badgeStep = 0;
- // badgeStep = (+badgeStep) + 1;
- // plus.storage.setItem( 'badge_step', badgeStep.toString());
- // plus.runtime.setBadgeNumber(badgeStep);
- //}
- //清空角标
- function clearInc () {
- if (plus.os.name != "iOS") {
- plus.push.clear();
- }
- // plus.storage.setItem( 'badgeStep', 0);
- plus.runtime.setBadgeNumber(0);
- }
- /**
- * 初始化角色切换事件
- */
- function qiehuanInit(main){
- if(plus.webview.getWebviewById('qiehuan.html')){
- plus.webview.getWebviewById('qiehuan.html').close();
- }
-
- var qiehuan = mui.createWindow({
- id: 'qiehuan.html',
- url: 'qiehuan.html',
- styles: {
- top: 0,
- bottom: 0,
- left: '45%',
- // width: '55%',
- scorllIndicator: "none"
- },
- show:{
- aniShow: "slide-in-right",
- duration: "400"
- }
- });
-
- main.addEventListener("maskClick",function(){
- main.setStyle({mask:"none"});
- qiehuan.hide();
- }, false);
-
- window.addEventListener("showQiehuan", function() {
- qiehuan.show();
- main.setStyle({mask:"rgba(0,0,0,0.5)"});
- });
-
- window.addEventListener("hideQiehuan", function(e) {
- var docType = parseInt(e.detail.type);
- var wbId, isShow;
- switch(docType) {
- case 1:
- isShow = false;
- wbId = "home1.html";
- break;
- case 2:
- case 3:
- isShow = true;
- wbId = "home2.html";
- break;
- case 10:
- isShow = false;
- wbId = "admin.html";
- break;
- default:
- break;
- }
-
- $(".mui-tab-item").eq(2).toggle((docType==1 || isShow) && teamCount>0);
- $(".mui-tab-item").eq(3).toggle(isShow);
- $(".mui-tab-item").eq(1).toggle(isShow && teamCount>0);
- $(".mui-tab-item").eq(0).attr("data-src", wbId);
-
- var wb;
- if(!(wb=plus.webview.getWebviewById(wbId))){
- var subStyles = {
- top: 0,
- bottom: "51px",
- scorllIndicator: "none"
- };
- main.append(plus.webview.create(wbId, wbId, subStyles));
- }
- else
- wb.show();
- main.setStyle({mask:"none"});
- qiehuan.hide("slide-in-left");
- });
-
- }
|