main.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. mui.init({
  2. keyEventBind: {
  3. backbutton: false //Boolean(默认true)关闭back按键监听
  4. }
  5. });
  6. function loginIm(userId,token,client_id,platform){
  7. if(token!=null){
  8. imClient.Users.login(userId, token, client_id, platform, function(res){
  9. }, function(res){
  10. alert("聊天服务器登录失败!");
  11. console.error("im_loin_fail: "+JSON.stringify(res))
  12. })
  13. }else{
  14. var info = plus.push.getClientInfo();
  15. var tokenNew = info.token;
  16. var client_idNew = info.clientid;
  17. setTimeout(function(){
  18. imClient.Users.login(userId, tokenNew, client_idNew, platform, function(res){
  19. }, function(res){
  20. alert("聊天服务器登录失败!");
  21. console.error("im_loin_fail: "+JSON.stringify(res))
  22. })
  23. },1000);
  24. }
  25. }
  26. var teamCount = 0;
  27. var topoffset = "0px";
  28. var wgtVer = null;
  29. mui.plusReady(function() {
  30. /**
  31. * 勿删
  32. */
  33. /*if(plus.navigator.isImmersedStatusbar()){
  34. topoffset = Math.round(plus.navigator.getStatusbarHeight()) + 'px';
  35. }*/
  36. /*
  37. * 退出事件
  38. */
  39. //清空角标
  40. clearInc();
  41. var first = null;
  42. mui.back = function() {
  43. if(!first) {
  44. first = new Date().getTime();
  45. plus.nativeUI.toast("再按一次退出");
  46. setTimeout(function() {
  47. first = null;
  48. }, 1000);
  49. } else {
  50. if(new Date().getTime() - first < 1000) {
  51. var userId = plus.storage.getItem("im_userid");
  52. imClient.Users.updateStatus(userId, 0);
  53. setTimeout(function(){
  54. plus.runtime.quit();
  55. },500);
  56. }
  57. }
  58. }
  59. //plus.nativeUI.showWaiting();
  60. sendPost("doctor/baseinfo", {}, null, function(res) {
  61. if(res.status == 200) {
  62. var infoStr = JSON.stringify(res.data);
  63. plus.storage.setItem("docInfo", infoStr);
  64. var userRole=JSON.stringify(res.data.userRole);//级别 省市县区
  65. plus.storage.setItem("hospital", res.data.hospital);
  66. plus.storage.setItem("userRole", userRole);
  67. sendGet("/doctor/admin-teams/team/"+ res.data.code +"/teams", {}, null, function(res){
  68. if(res.status==200){
  69. plus.storage.setItem("teamInfo", JSON.stringify(res));
  70. teamCount = res.data.length;
  71. initApp();
  72. } else
  73. mui.toast("获取医生团队失败")
  74. //plus.nativeUI.closeWaiting();
  75. })
  76. } else {
  77. mui.toast("获取医生信息失败");
  78. mui.openWindow({
  79. id: "login",
  80. url: "../../login/html/login.html",
  81. extras: {
  82. }
  83. })
  84. }
  85. });
  86. //运行环境从后台切换到前台事件
  87. document.addEventListener("resume", function() {
  88. // console.log("运行环境从后台切换到前台事件")
  89. var userId = plus.storage.getItem("im_userid");
  90. imClient.Users.updateStatus(userId, 0);
  91. //清空角标
  92. clearInc();
  93. }, false);
  94. //运行环境从前台切换到后台事件
  95. document.addEventListener("pause", function() {
  96. // console.log("运行环境从前台切换到后台事件")
  97. var userId = plus.storage.getItem("im_userid");
  98. imClient.Users.updateStatus(userId, 1);
  99. //清空角标
  100. clearInc();
  101. }, false);
  102. //监听推送的消息
  103. plus.push.addEventListener("receive", function(msg){
  104. plusReceive(msg);
  105. }, false);
  106. plus.push.addEventListener("click", function(msg) {
  107. plusClick(msg);
  108. }, false);
  109. //判断版本信息显示小红点
  110. plus.runtime.getProperty(plus.runtime.appid, function(inf){
  111. wgtVer = inf.version;
  112. if(plus.os.name == "iOS") {
  113. // 检测app小版本的更新
  114. checkUpgrade();
  115. } else if(plus.os.name == "Android") {
  116. // 先检测大版本的更新,如果没有再检测app小版本的更新
  117. checkVersion();
  118. }
  119. });
  120. /*
  121. * 在安卓条件下检查版本
  122. */
  123. function checkVersion() {
  124. mui.ajax(server + 'version/app', {
  125. data: {
  126. version: 0,//获取当前版本的所有信息,然后以version_int号来校验升级信息
  127. code: "app_doc"
  128. },
  129. dataType: 'json', //服务器返回json格式数据
  130. type: 'post', //HTTP请求类型
  131. timeout: 10000, //超时时间设置为10秒;
  132. success: function(res) {
  133. console.log(JSON.stringify(res));
  134. if(res.status == 200) {
  135. if(res.data && res.data.version_int && (res.data.version_int > curr_app_version)) {
  136. $('#mine_point').show();
  137. }else {
  138. // 没有大版本时就检测小版本的升级
  139. checkUpgrade();
  140. }
  141. }
  142. },
  143. error: function(xhr, type, errorThrown) {
  144. if(type == "timeout" || type == "abort" || type == "error") {
  145. plus.nativeUI.toast("网络错误: 无法进行版本升级检测!");
  146. }
  147. }
  148. });
  149. }
  150. // 检测app小版本的更新
  151. function checkUpgrade(){
  152. mui.ajax(server + 'version/app', {
  153. data: {
  154. version: 0,//资源包不以version_int号来校验升级信息,而以version_str判断.version_str不相同就会升级。
  155. code: "wgt"
  156. },
  157. dataType: 'json', //服务器返回json格式数据
  158. type: 'post', //HTTP请求类型
  159. timeout: 10000, //超时时间设置为10秒;
  160. success: function(res) {
  161. console.log(JSON.stringify(res));
  162. if(res.status == 200) {
  163. if(res.data && res.data.version_str && wgtVer && (res.data.version_str != wgtVer)) {
  164. $('#mine_point').show()
  165. }
  166. }
  167. },
  168. error: function(xhr, type, errorThrown) {
  169. if(type == "timeout" || type == "abort" || type == "error") {
  170. plus.nativeUI.toast("网络错误: 无法进行版本升级检测!");
  171. }
  172. }
  173. });
  174. }
  175. });
  176. function initApp(){
  177. var self = plus.webview.currentWebview();
  178. var docInfo = JSON.parse(plus.storage.getItem("docInfo"));//doctor表中的level
  179. var level = docInfo.level;
  180. //level与docType的值一致,将level值存储为docType raolu 20170118
  181. plus.storage.setItem('docType', level+"");
  182. var docType = plus.storage.getItem("docType");
  183. // var docType = plus.storage.getItem("docType");
  184. if(!docType) {
  185. alert("获取医生类型失败");
  186. }
  187. var userAgent = JSON.parse(plus.storage.getItem("userAgent"));
  188. var userId = userAgent.uid;
  189. var info = plus.push.getClientInfo();
  190. var token = info.token;
  191. var client_id = info.clientid;
  192. var platform = 0;
  193. if(plus.os.name == "Android") { //ios暂无im功能 只在安卓下才执行该方法
  194. platform = 1;
  195. }
  196. //如果当前状态是观察者模式,则不登录IM。
  197. if(!userAgent.observer){
  198. loginIm(userId,token,client_id,platform);
  199. }
  200. var subPages = [];
  201. //docType 10 是管理员
  202. // docType="10"
  203. switch(docType) {
  204. case "1":
  205. subPages = ["home1.html", "huanzhe-specal.html", "../../contact/html/contacts-zk.html", "mine.html"];
  206. // if(teamCount > 0){
  207. // $(".mui-tab-item").eq(2).show();
  208. // subPages.push("../../tuandui/html/tuandui.html");
  209. // }
  210. $(".mui-tab-item").eq(3).hide();
  211. $(".mui-tab-item").eq(2).find(".mui-tab-label").text("通讯录");
  212. $(".mui-tab-item").eq(2).attr("data-src", "../../contact/html/contacts-zk.html")
  213. $(".mui-tab-item").eq(2).show();
  214. $(".mui-tab-item").eq(1).attr("data-src", "huanzhe-specal.html")
  215. $(".mui-tab-item").eq(1).show();
  216. $(".mui-tab-item").eq(0).attr("data-src", "home1.html")
  217. break;
  218. case "2":
  219. case "3":
  220. subPages = ["home2.html", "huanzhe.html", "../../tuandui/html/tuandui.html", "xiaoxi.html", "mine.html"];
  221. if(teamCount > 0){
  222. $(".mui-tab-item").eq(1).show();
  223. $(".mui-tab-item").eq(2).show();
  224. subPages.push("../../tuandui/html/tuandui.html");
  225. }
  226. break;
  227. case "10":
  228. subPages = ["admin.html", "mine.html"];
  229. if(level!=10){
  230. if(teamCount > 0){
  231. subPages.push("../../tuandui/html/tuandui.html");
  232. }
  233. subPages.push("huanzhe.html");
  234. subPages.push("xiaoxi.html");
  235. }
  236. $(".mui-tab-item").eq(2).hide();
  237. $(".mui-tab-item").eq(1).hide();
  238. $(".mui-tab-item").eq(3).hide();
  239. $(".mui-tab-item").eq(0).attr("data-src","admin.html")
  240. break;
  241. default:
  242. break;
  243. }
  244. if(isMultiRole()){
  245. subPages.push("admin.html");
  246. //初始化角色切换事件
  247. qiehuanInit(self);
  248. }
  249. $('.mui-bar').show();
  250. var subStyles = {
  251. top: topoffset,
  252. bottom: "51px",
  253. scorllIndicator: "none",
  254. bounceBackground: "#17b3ec"
  255. };
  256. // for(var i = 0; i < subPages.length; i++) {
  257. // var sub_wv ;
  258. // var ws = plus.webview.getWebviewById(subPages[i]);
  259. // if(ws){
  260. // continue;
  261. // }
  262. // else
  263. // sub_wv = plus.webview.create(subPages[i], subPages[i], subStyles);
  264. // if(i > 0) {
  265. // sub_wv.hide();
  266. // }
  267. //
  268. // self.append(sub_wv);
  269. // }
  270. //添加返回管理员账号时,显示admin页面
  271. if(plus.storage.getItem('backToAdmin')){
  272. console.log("back to admin");
  273. var ws = mui.openWindow({
  274. url:"admin.html",
  275. id:"admin.html",
  276. styles:subStyles,
  277. waiting:{
  278. autoShow:true,//自动显示等待框,默认为true
  279. title:'正在加载...'//等待对话框上显示的提示内容
  280. }
  281. });
  282. self.append(ws);
  283. $(".mui-tab-item").eq(2).hide();
  284. $(".mui-tab-item").eq(1).hide();
  285. $(".mui-tab-item").eq(3).hide();
  286. $(".mui-tab-item").eq(0).attr("data-src","admin.html");
  287. mui.later(function(){
  288. var qiehuan = plus.webview.getWebviewById('qiehuan.html');
  289. mui.fire(qiehuan, 'checkAdmin');
  290. console.log("clear backtoAdmin");
  291. plus.storage.removeItem('backToAdmin');
  292. }, 2000);
  293. }else{
  294. var activeSub = subPages[0];
  295. var ws = plus.webview.getWebviewById(activeSub);
  296. if(ws){
  297. ws.show();
  298. }
  299. else{
  300. // ws = plus.webview.create(activeSub, activeSub, subStyles);
  301. ws = mui.openWindow({
  302. url:activeSub,
  303. id:activeSub,
  304. styles:subStyles,
  305. waiting:{
  306. autoShow:true,//自动显示等待框,默认为true
  307. title:'正在加载...'//等待对话框上显示的提示内容
  308. }
  309. });
  310. }
  311. self.append(ws);
  312. }
  313. //请求消息数量
  314. sendPost("/doctor/message/messages",{}, null, function(res){
  315. if(res.status == 200){
  316. var data = res.data,
  317. hasNew = false,
  318. _hasNew = false;
  319. for(var k in data){
  320. if(k == "imMsgCount"){
  321. var json = JSON.parse(data[k]);
  322. if(json.count > 0){
  323. if (json.patientEnd > 0 &&json.patient == 0 && json.doctor== 0) {
  324. _hasNew = true;
  325. }
  326. }
  327. }else{
  328. if(data[k].amount > 0){
  329. hasNew = true;
  330. }
  331. }
  332. }
  333. if(hasNew){
  334. $("#point").css('color','red').show();
  335. }else if(_hasNew){
  336. $("#point").css('color','blue').show();
  337. }
  338. }else{
  339. mui.toast("获取新消息失败");
  340. }
  341. },'POST','',true);
  342. var aTab = document.querySelectorAll(".mui-tab-item");
  343. for(var i = 0; i < aTab.length; i++) {
  344. aTab[i].addEventListener("tap", function() {
  345. var targetSub = this.getAttribute("data-src");
  346. if(targetSub == activeSub) {
  347. return;
  348. }
  349. var xxWv = plus.webview.getWebviewById(targetSub);
  350. if(xxWv) {
  351. mui.fire(xxWv, "refresh");
  352. xxWv.show();
  353. }else{
  354. // plus.nativeUI.showWaiting();
  355. // xxWv = plus.webview.create(targetSub, targetSub, subStyles);
  356. // xxWv.show();
  357. // plus.nativeUI.closeWaiting();
  358. xxWv = mui.openWindow({
  359. url:targetSub,
  360. id:targetSub,
  361. styles:subStyles,
  362. waiting:{
  363. autoShow:true,//自动显示等待框,默认为true
  364. title:'正在加载...'//等待对话框上显示的提示内容
  365. }
  366. });
  367. self.append(xxWv);
  368. }
  369. if(targetSub=="xiaoxi.html"){
  370. //$("#point").hide();
  371. }
  372. plus.webview.hide(activeSub);
  373. activeSub = targetSub;
  374. });
  375. }
  376. window.addEventListener("activeHuanzhe", function() {
  377. var items = $(".mui-tab-item");
  378. mui.trigger(items.get(1), "tap");
  379. items.removeClass("mui-active");
  380. mui.later(function() {
  381. items.eq(1).addClass("mui-active");
  382. }, 100);
  383. });
  384. window.addEventListener("activeXiaoxi", function() {
  385. var items = $(".mui-tab-item");
  386. mui.trigger(items.get(3), "tap");
  387. items.removeClass("mui-active");
  388. mui.later(function() {
  389. items.eq(3).addClass("mui-active");
  390. var xxWv = plus.webview.getWebviewById("xiaoxi.html");
  391. var yisheng_wv = plus.webview.getWebviewById('yishengim.html');
  392. xxWv.show();
  393. mui.fire(xxWv, "ysrefresh");
  394. mui.fire(yisheng_wv, "xiaoxiUpdate");
  395. }, 100);
  396. });
  397. }
  398. // 监听离线点击消息事件
  399. // plus.push.addEventListener("click", function(msg) {
  400. function plusClick(msg){
  401. // console.log("click");
  402. // plus.ui.alert("click");
  403. var qunzuduihuaView = plus.webview.getWebviewById("dlz");
  404. if(qunzuduihuaView) {
  405. $("#red_sign").css("display", "none");
  406. mui.fire(qunzuduihuaView, "update");
  407. } else {
  408. $("#red_sign").css("display", "");
  409. }
  410. var p2pHtml = plus.webview.getWebviewById("p2p");
  411. if(p2pHtml) {
  412. mui.fire(p2pHtml, "update");
  413. }
  414. var payload;
  415. if (plus.os.name == "iOS") {
  416. payload = msg.payload.payload1;
  417. }
  418. else {
  419. payload = JSON.parse(msg.payload);
  420. if (payload.pushtype == 'transmission') { // 透明传输消息
  421. return;
  422. } else if (payload.pushtype == 'notify') { // 点击通知栏消息
  423. payload = JSON.parse(payload.data);
  424. } else {
  425. return;
  426. }
  427. }
  428. // plus.nativeUI.alert("click事件")
  429. // plus.nativeUI.alert(JSON.stringify(msg));
  430. if (payload) {
  431. if ((payload.business_type=="1" && payload.session_type=="2") || //医生对医生 p2p
  432. (payload.business_type=="1" && payload.session_type=="3") || //群组
  433. (payload.business_type=="2" && payload.session_type=="1") || //健康咨询 p2d
  434. (payload.business_type=="2" && payload.session_type=="2")) //患者名医咨询
  435. {
  436. getDoctorTeamInfo(payload);
  437. }else if (payload.session_type && (payload.business_type == "D_CT_01" || payload.business_type == "D_CT_02")) {
  438. mui.later(function() {
  439. openWebview('../../zdzx/html/zhidingzixun.html');
  440. }, 100);
  441. }else if (payload.session_type && (payload.session_type == "D_CT_03" || payload.session_type == "D_CT_04")) {
  442. mui.later(function() {
  443. openWebview('../../mygl/html/mingyizixunliebiao.html');
  444. }, 200);
  445. } 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")) {
  446. mui.later(function() {
  447. openWebview('../../qygl/html/qianyuexiaoxi.html');
  448. }, 100);
  449. } else if (payload.session_type && payload.session_type == "D_HI_01") {
  450. mui.later(function() {
  451. openWebview('../../xiaoxi/html/tizhengzhibiao.html');
  452. }, 100);
  453. }else if (payload.session_type && payload.session_type == "D_NH_01") {
  454. mui.later(function() {
  455. openWebview('../../home/html/xiaoxi.html');
  456. }, 200);
  457. } else if (payload.session_type && payload.session_type == "D_NH_01") {
  458. mui.later(function() {
  459. openWebview('../../home/html/xiaoxi.html');
  460. }, 200);
  461. }else if (payload.session_type && payload.session_type == "D_P_WRD") {
  462. mui.later(function() {
  463. openWebview('../../prescription/html/xufangxiaoxi.html',{type:7});
  464. }, 200);
  465. }else if (payload.session_type && payload.session_type == "D_CT_05") {
  466. mui.later(function() {
  467. openWebview('../../prescription/html/xufangxiaoxi.html',{type:6});
  468. }, 200);
  469. }
  470. }
  471. // }, false);
  472. }
  473. // 监听在线消息事件
  474. // plus.push.addEventListener("receive", function(msg) {
  475. function plusReceive(msg){
  476. //if(publish_version == false){
  477. // mui.toast("您收到一条新消息");
  478. //}
  479. // plus.ui.alert(JSON.stringify(msg));
  480. var qunzuduihuaView = plus.webview.getWebviewById("dlz");
  481. if(qunzuduihuaView) {
  482. $("#red_sign").css("display", "none");
  483. mui.fire(qunzuduihuaView, "update");
  484. } else {
  485. $("#red_sign").css("display", "");
  486. }
  487. //通知一对一聊天更新数据
  488. var p2pHtml = plus.webview.getWebviewById("p2p");
  489. if(p2pHtml) {
  490. //mui.fire(p2pHtml, "update");
  491. }
  492. p2pHtml = plus.webview.getWebviewById("p2dzixun");
  493. if(p2pHtml) {
  494. //mui.fire(p2pHtml, "update");
  495. }
  496. //通知团队聊天更新数据
  497. var tuanduiHtml = plus.webview.getWebviewById("tuanduiqunliao.html")
  498. || plus.webview.getWebviewById("tuanduiqunliao");
  499. if(tuanduiHtml) {
  500. //mui.fire(tuanduiHtml, "update");
  501. }
  502. tuanduiHtml = plus.webview.getWebviewById("qiuzhuqunliao");
  503. if(tuanduiHtml) {
  504. //mui.fire(tuanduiHtml, "update");
  505. }
  506. tuanduiHtml = plus.webview.getWebviewById("qiuzhuqunliao2");
  507. if(tuanduiHtml) {
  508. //mui.fire(tuanduiHtml, "update");
  509. }
  510. var home2 = plus.webview.getWebviewById("home2.html");
  511. if(home2) {
  512. mui.fire(home2, "getMsgAmount");
  513. }
  514. var jumingHtml = plus.webview.getWebviewById("jumingim.html");
  515. if(jumingHtml) {
  516. mui.fire(jumingHtml, "update");
  517. }
  518. var yishengHtml = plus.webview.getWebviewById("yishengim.html");
  519. if(yishengHtml) {
  520. mui.fire(yishengHtml, "update");
  521. }
  522. var xiaoxipage = plus.webview.getWebviewById("xiaoxipage.html");
  523. if(xiaoxipage) {
  524. mui.fire(xiaoxipage, "update");
  525. }
  526. var payload;
  527. var pushtype;
  528. if (plus.os.name == "iOS") {
  529. payload = msg.payload.payload1;
  530. } else {
  531. payload = JSON.parse(msg.payload);
  532. if (payload.pushtype == 'transmission') { // 透明传输消息
  533. return;
  534. } else if (payload.pushtype == 'notify') { // 点击通知栏消息
  535. payload = JSON.parse(payload.data);
  536. } else {
  537. return;
  538. }
  539. }
  540. // plus.nativeUI.alert("receive事件")
  541. // plus.nativeUI.alert(JSON.stringify(msg));
  542. if (payload) {
  543. if ((payload.business_type=="1" && payload.session_type=="2") || //医生对医生 p2p
  544. (payload.business_type=="1" && payload.session_type=="3") || //群组
  545. (payload.business_type=="2" && payload.session_type=="1") || //健康咨询 p2d
  546. (payload.business_type=="2" && payload.session_type=="2")) //患者名医咨询
  547. {
  548. // getDoctorTeamInfo(payload);
  549. }
  550. // else if (payload.business_type && (payload.business_type == "D_CT_01" || payload.business_type == "D_CT_02")) {
  551. // //D_CT_01, 指定咨询, 您有新的指定咨询
  552. // //D_CT_02, 指定咨询, 您有新的消息
  553. // mui.later(function() {
  554. // openWebview('../html/xiaoxipage.html');
  555. // }, 200);
  556. // } else if (payload.business_type && (payload.business_type == "D_CT_03" || payload.business_type == "D_CT_04")) {
  557. // //D_CT_03, 名医咨询, 您有新的名医咨询(患者发起)
  558. // //D_CT_04, 名医咨询, 您有新的名医咨询(医生发起)
  559. // mui.later(function() {
  560. // openWebview('../html/home1.html');
  561. // }, 200);
  562. // } 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")) {
  563. // //家庭签约
  564. // mui.later(function() {
  565. // openWebview('../../qygl/html/qianyuexiaoxi.html');
  566. //// openWebview("../../qygl/html/sign_manage.html")
  567. // }, 200);
  568. // } else if (payload.business_type && payload.business_type == "D_HI_01") {//体征指标
  569. // mui.later(function() {
  570. //// openWebview('../../xiaoxi/html/tizhengzhibiao.html');
  571. // openWebview("../../xiaoxi/html/jiankangtizheng.html");
  572. // }, 200);
  573. // } else if (payload.business_type && payload.business_type == "D_NH_01") {
  574. // mui.later(function() {
  575. //// openWebview('../../home/html/xiaoxi.html');
  576. // openWebview("../../message/html/xitongxiaoxi.html");
  577. // }, 200);
  578. // } else if (payload.business_type && payload.business_type == "D_ST_01") {
  579. // mui.later(function() {
  580. // openWebview('../../home/html/home1.html');
  581. // }, 200);
  582. // }else if (payload.business_type && (payload.business_type == "D_ST_02"||payload.business_type == "D_ST_03")) {
  583. // mui.later(function() {
  584. //// openWebview('../../home/html/home2.html');
  585. // openWebview('../../qygl/html/qianyuexiaoxi.html');
  586. // }, 200);
  587. // }
  588. //配置随访相关的消息页面跳转:随访计划提醒(4)、随访计划完成消息(D_FU_01)、随访计划阶段完成消息(D_FU_02)、随访计划随访项完成消息(D_FU_03)、患者回答随访记录消息(D_FU_04)
  589. 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")){
  590. // mui.later(function(){
  591. // openWebview('../../suifang/html/index.html');
  592. // }, 200);
  593. }
  594. }
  595. // }, false);
  596. }
  597. //获取医生团队信息
  598. function getDoctorTeamInfo(payload){
  599. imClient.Sessions.getSessionsInfo(payload.session_id,payload.from, function(res){
  600. // plus.nativeUI.alert(JSON.stringify(res))
  601. mui.later(function() {
  602. var params = {sessionId: payload.session_id, sessionName: res.name};
  603. if (payload.business_type=="1" && payload.session_type=="2") {//医生对医生 p2p
  604. openWebview("../../message/html/p2p.html",params);
  605. }else if (payload.business_type=="1" && payload.session_type=="3") {//群组
  606. openWebview("../../message/html/tuanduiqunliao.html",params);
  607. }else if (payload.business_type=="2" && payload.session_type=="1") {//健康咨询 p2d
  608. openWebview("../../message/html/p2dzixun.html",params);
  609. }else if (payload.business_type=="2" && payload.session_type=="2") {//患者名医咨询
  610. openWebview("../../message/html/p2dzixun.html",params);
  611. }
  612. }, 200);
  613. });
  614. }
  615. //角标增长
  616. //function addInc () {
  617. // var badgeStep = plus.storage.getItem('badge_step');
  618. // if(!!!badgeStep) badgeStep = 0;
  619. // badgeStep = (+badgeStep) + 1;
  620. // plus.storage.setItem( 'badge_step', badgeStep.toString());
  621. // plus.runtime.setBadgeNumber(badgeStep);
  622. //}
  623. //清空角标
  624. function clearInc () {
  625. if (plus.os.name != "iOS") {
  626. plus.push.clear();
  627. }
  628. // plus.storage.setItem( 'badgeStep', 0);
  629. plus.runtime.setBadgeNumber(0);
  630. }
  631. /**
  632. * 初始化角色切换事件
  633. */
  634. function qiehuanInit(main){
  635. if(plus.webview.getWebviewById('qiehuan.html')){
  636. plus.webview.getWebviewById('qiehuan.html').close();
  637. }
  638. var qiehuan = mui.createWindow({
  639. id: 'qiehuan.html',
  640. url: 'qiehuan.html',
  641. styles: {
  642. top: 0,
  643. bottom: 0,
  644. left: '45%',
  645. // width: '55%',
  646. scorllIndicator: "none"
  647. },
  648. show:{
  649. aniShow: "slide-in-right",
  650. duration: "400"
  651. }
  652. });
  653. main.addEventListener("maskClick",function(){
  654. main.setStyle({mask:"none"});
  655. qiehuan.hide();
  656. }, false);
  657. window.addEventListener("showQiehuan", function() {
  658. qiehuan.show();
  659. main.setStyle({mask:"rgba(0,0,0,0.5)"});
  660. });
  661. window.addEventListener("hideQiehuan", function(e) {
  662. var docType = parseInt(e.detail.type);
  663. var wbId, isShow;
  664. switch(docType) {
  665. case 1:
  666. isShow = false;
  667. wbId = "home1.html";
  668. break;
  669. case 2:
  670. case 3:
  671. isShow = true;
  672. wbId = "home2.html";
  673. break;
  674. case 10:
  675. isShow = false;
  676. wbId = "admin.html";
  677. break;
  678. default:
  679. break;
  680. }
  681. $(".mui-tab-item").eq(2).toggle((docType==1 || isShow) && teamCount>0);
  682. $(".mui-tab-item").eq(3).toggle(isShow);
  683. $(".mui-tab-item").eq(1).toggle(isShow && teamCount>0);
  684. $(".mui-tab-item").eq(0).attr("data-src", wbId);
  685. var wb;
  686. if(!(wb=plus.webview.getWebviewById(wbId))){
  687. var subStyles = {
  688. top: 0,
  689. bottom: "51px",
  690. scorllIndicator: "none"
  691. };
  692. main.append(plus.webview.create(wbId, wbId, subStyles));
  693. }
  694. else
  695. wb.show();
  696. main.setStyle({mask:"none"});
  697. qiehuan.hide("slide-in-left");
  698. });
  699. }