main.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  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, 1);
  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, 0);
  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", "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(1).hide();
  212. $(".mui-tab-item").eq(0).attr("data-src", "home1.html")
  213. break;
  214. case "2":
  215. case "3":
  216. subPages = ["home2.html", "huanzhe.html", "../../tuandui/html/tuandui.html", "xiaoxi.html", "mine.html"];
  217. if(teamCount > 0){
  218. $(".mui-tab-item").eq(1).show();
  219. $(".mui-tab-item").eq(2).show();
  220. subPages.push("../../tuandui/html/tuandui.html");
  221. }
  222. break;
  223. case "10":
  224. subPages = ["admin.html", "mine.html"];
  225. if(level!=10){
  226. if(teamCount > 0){
  227. subPages.push("../../tuandui/html/tuandui.html");
  228. }
  229. subPages.push("huanzhe.html");
  230. subPages.push("xiaoxi.html");
  231. }
  232. $(".mui-tab-item").eq(2).hide();
  233. $(".mui-tab-item").eq(1).hide();
  234. $(".mui-tab-item").eq(3).hide();
  235. $(".mui-tab-item").eq(0).attr("data-src","admin.html")
  236. break;
  237. default:
  238. break;
  239. }
  240. if(isMultiRole()){
  241. subPages.push("admin.html");
  242. //初始化角色切换事件
  243. qiehuanInit(self);
  244. }
  245. $('.mui-bar').show();
  246. var subStyles = {
  247. top: topoffset,
  248. bottom: "51px",
  249. scorllIndicator: "none",
  250. bounceBackground: "#17b3ec"
  251. };
  252. // for(var i = 0; i < subPages.length; i++) {
  253. // var sub_wv ;
  254. // var ws = plus.webview.getWebviewById(subPages[i]);
  255. // if(ws){
  256. // continue;
  257. // }
  258. // else
  259. // sub_wv = plus.webview.create(subPages[i], subPages[i], subStyles);
  260. // if(i > 0) {
  261. // sub_wv.hide();
  262. // }
  263. //
  264. // self.append(sub_wv);
  265. // }
  266. //添加返回管理员账号时,显示admin页面
  267. if(plus.storage.getItem('backToAdmin')){
  268. console.log("back to admin");
  269. var ws = mui.openWindow({
  270. url:"admin.html",
  271. id:"admin.html",
  272. styles:subStyles,
  273. waiting:{
  274. autoShow:true,//自动显示等待框,默认为true
  275. title:'正在加载...'//等待对话框上显示的提示内容
  276. }
  277. });
  278. self.append(ws);
  279. $(".mui-tab-item").eq(2).hide();
  280. $(".mui-tab-item").eq(1).hide();
  281. $(".mui-tab-item").eq(3).hide();
  282. $(".mui-tab-item").eq(0).attr("data-src","admin.html");
  283. mui.later(function(){
  284. var qiehuan = plus.webview.getWebviewById('qiehuan.html');
  285. mui.fire(qiehuan, 'checkAdmin');
  286. console.log("clear backtoAdmin");
  287. plus.storage.removeItem('backToAdmin');
  288. }, 2000);
  289. }else{
  290. var activeSub = subPages[0];
  291. var ws = plus.webview.getWebviewById(activeSub);
  292. if(ws){
  293. ws.show();
  294. }
  295. else{
  296. // ws = plus.webview.create(activeSub, activeSub, subStyles);
  297. ws = mui.openWindow({
  298. url:activeSub,
  299. id:activeSub,
  300. styles:subStyles,
  301. waiting:{
  302. autoShow:true,//自动显示等待框,默认为true
  303. title:'正在加载...'//等待对话框上显示的提示内容
  304. }
  305. });
  306. }
  307. self.append(ws);
  308. }
  309. //请求消息数量
  310. sendPost("/doctor/message/messages",{}, null, function(res){
  311. if(res.status == 200){
  312. var data = res.data,
  313. hasNew = false,
  314. _hasNew = false;
  315. for(var k in data){
  316. if(k == "imMsgCount"){
  317. var json = JSON.parse(data[k]);
  318. if(json.count > 0){
  319. if (json.patientEnd > 0 &&json.patient == 0 && json.doctor== 0) {
  320. _hasNew = true;
  321. }
  322. }
  323. }else{
  324. if(data[k].amount > 0){
  325. hasNew = true;
  326. }
  327. }
  328. }
  329. if(hasNew){
  330. $("#point").css('color','red').show();
  331. }else if(_hasNew){
  332. $("#point").css('color','blue').show();
  333. }
  334. }else{
  335. mui.toast("获取新消息失败");
  336. }
  337. },'POST','',true);
  338. var aTab = document.querySelectorAll(".mui-tab-item");
  339. for(var i = 0; i < aTab.length; i++) {
  340. aTab[i].addEventListener("tap", function() {
  341. var targetSub = this.getAttribute("data-src");
  342. if(targetSub == activeSub) {
  343. return;
  344. }
  345. var xxWv = plus.webview.getWebviewById(targetSub);
  346. if(xxWv) {
  347. mui.fire(xxWv, "refresh");
  348. xxWv.show();
  349. }else{
  350. // plus.nativeUI.showWaiting();
  351. // xxWv = plus.webview.create(targetSub, targetSub, subStyles);
  352. // xxWv.show();
  353. // plus.nativeUI.closeWaiting();
  354. xxWv = mui.openWindow({
  355. url:targetSub,
  356. id:targetSub,
  357. styles:subStyles,
  358. waiting:{
  359. autoShow:true,//自动显示等待框,默认为true
  360. title:'正在加载...'//等待对话框上显示的提示内容
  361. }
  362. });
  363. self.append(xxWv);
  364. }
  365. if(targetSub=="xiaoxi.html"){
  366. //$("#point").hide();
  367. }
  368. plus.webview.hide(activeSub);
  369. activeSub = targetSub;
  370. });
  371. }
  372. window.addEventListener("activeHuanzhe", function() {
  373. var items = $(".mui-tab-item");
  374. mui.trigger(items.get(1), "tap");
  375. items.removeClass("mui-active");
  376. mui.later(function() {
  377. items.eq(1).addClass("mui-active");
  378. }, 100);
  379. });
  380. window.addEventListener("activeXiaoxi", function() {
  381. var items = $(".mui-tab-item");
  382. mui.trigger(items.get(3), "tap");
  383. items.removeClass("mui-active");
  384. mui.later(function() {
  385. items.eq(3).addClass("mui-active");
  386. var xxWv = plus.webview.getWebviewById("xiaoxi.html");
  387. var yisheng_wv = plus.webview.getWebviewById('yishengim.html');
  388. xxWv.show();
  389. mui.fire(xxWv, "ysrefresh");
  390. mui.fire(yisheng_wv, "xiaoxiUpdate");
  391. }, 100);
  392. });
  393. }
  394. // 监听离线点击消息事件
  395. // plus.push.addEventListener("click", function(msg) {
  396. function plusClick(msg){
  397. // console.log("click");
  398. // plus.ui.alert("click");
  399. var qunzuduihuaView = plus.webview.getWebviewById("dlz");
  400. if(qunzuduihuaView) {
  401. $("#red_sign").css("display", "none");
  402. mui.fire(qunzuduihuaView, "update");
  403. } else {
  404. $("#red_sign").css("display", "");
  405. }
  406. var p2pHtml = plus.webview.getWebviewById("p2p");
  407. if(p2pHtml) {
  408. mui.fire(p2pHtml, "update");
  409. }
  410. var payload;
  411. if (plus.os.name == "iOS") {
  412. payload = msg.payload.payload1;
  413. }
  414. else {
  415. payload = JSON.parse(msg.payload);
  416. if (payload.pushtype == 'transmission') { // 透明传输消息
  417. return;
  418. } else if (payload.pushtype == 'notify') { // 点击通知栏消息
  419. payload = JSON.parse(payload.data);
  420. } else {
  421. return;
  422. }
  423. }
  424. // plus.nativeUI.alert("click事件")
  425. // plus.nativeUI.alert(JSON.stringify(msg));
  426. if (payload) {
  427. if ((payload.business_type=="1" && payload.session_type=="2") || //医生对医生 p2p
  428. (payload.business_type=="1" && payload.session_type=="3") || //群组
  429. (payload.business_type=="2" && payload.session_type=="1") || //健康咨询 p2d
  430. (payload.business_type=="2" && payload.session_type=="2")) //患者名医咨询
  431. {
  432. getDoctorTeamInfo(payload);
  433. }else if (payload.session_type && (payload.business_type == "D_CT_01" || payload.business_type == "D_CT_02")) {
  434. mui.later(function() {
  435. openWebview('../../zdzx/html/zhidingzixun.html');
  436. }, 100);
  437. }else if (payload.session_type && (payload.session_type == "D_CT_03" || payload.session_type == "D_CT_04")) {
  438. mui.later(function() {
  439. openWebview('../../mygl/html/mingyizixunliebiao.html');
  440. }, 200);
  441. } 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")) {
  442. mui.later(function() {
  443. openWebview('../../qygl/html/qianyuexiaoxi.html');
  444. }, 100);
  445. } else if (payload.session_type && payload.session_type == "D_HI_01") {
  446. mui.later(function() {
  447. openWebview('../../xiaoxi/html/tizhengzhibiao.html');
  448. }, 100);
  449. }else if (payload.session_type && payload.session_type == "D_NH_01") {
  450. mui.later(function() {
  451. openWebview('../../home/html/xiaoxi.html');
  452. }, 200);
  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_P_WRD") {
  458. mui.later(function() {
  459. openWebview('../../prescription/html/xufangxiaoxi.html',{type:7});
  460. }, 200);
  461. }else if (payload.session_type && payload.session_type == "D_CT_05") {
  462. mui.later(function() {
  463. openWebview('../../prescription/html/xufangxiaoxi.html',{type:6});
  464. }, 200);
  465. }
  466. }
  467. // }, false);
  468. }
  469. // 监听在线消息事件
  470. // plus.push.addEventListener("receive", function(msg) {
  471. function plusReceive(msg){
  472. //if(publish_version == false){
  473. // mui.toast("您收到一条新消息");
  474. //}
  475. // plus.ui.alert(JSON.stringify(msg));
  476. var qunzuduihuaView = plus.webview.getWebviewById("dlz");
  477. if(qunzuduihuaView) {
  478. $("#red_sign").css("display", "none");
  479. mui.fire(qunzuduihuaView, "update");
  480. } else {
  481. $("#red_sign").css("display", "");
  482. }
  483. //通知一对一聊天更新数据
  484. var p2pHtml = plus.webview.getWebviewById("p2p");
  485. if(p2pHtml) {
  486. //mui.fire(p2pHtml, "update");
  487. }
  488. p2pHtml = plus.webview.getWebviewById("p2dzixun");
  489. if(p2pHtml) {
  490. //mui.fire(p2pHtml, "update");
  491. }
  492. //通知团队聊天更新数据
  493. var tuanduiHtml = plus.webview.getWebviewById("tuanduiqunliao.html")
  494. || plus.webview.getWebviewById("tuanduiqunliao");
  495. if(tuanduiHtml) {
  496. //mui.fire(tuanduiHtml, "update");
  497. }
  498. tuanduiHtml = plus.webview.getWebviewById("qiuzhuqunliao");
  499. if(tuanduiHtml) {
  500. //mui.fire(tuanduiHtml, "update");
  501. }
  502. tuanduiHtml = plus.webview.getWebviewById("qiuzhuqunliao2");
  503. if(tuanduiHtml) {
  504. //mui.fire(tuanduiHtml, "update");
  505. }
  506. var home2 = plus.webview.getWebviewById("home2.html");
  507. if(home2) {
  508. mui.fire(home2, "getMsgAmount");
  509. }
  510. var jumingHtml = plus.webview.getWebviewById("jumingim.html");
  511. if(jumingHtml) {
  512. mui.fire(jumingHtml, "update");
  513. }
  514. var yishengHtml = plus.webview.getWebviewById("yishengim.html");
  515. if(yishengHtml) {
  516. mui.fire(yishengHtml, "update");
  517. }
  518. var xiaoxipage = plus.webview.getWebviewById("xiaoxipage.html");
  519. if(xiaoxipage) {
  520. mui.fire(xiaoxipage, "update");
  521. }
  522. var payload;
  523. var pushtype;
  524. if (plus.os.name == "iOS") {
  525. payload = msg.payload.payload1;
  526. } else {
  527. payload = JSON.parse(msg.payload);
  528. if (payload.pushtype == 'transmission') { // 透明传输消息
  529. return;
  530. } else if (payload.pushtype == 'notify') { // 点击通知栏消息
  531. payload = JSON.parse(payload.data);
  532. } else {
  533. return;
  534. }
  535. }
  536. // plus.nativeUI.alert("receive事件")
  537. // plus.nativeUI.alert(JSON.stringify(msg));
  538. if (payload) {
  539. if ((payload.business_type=="1" && payload.session_type=="2") || //医生对医生 p2p
  540. (payload.business_type=="1" && payload.session_type=="3") || //群组
  541. (payload.business_type=="2" && payload.session_type=="1") || //健康咨询 p2d
  542. (payload.business_type=="2" && payload.session_type=="2")) //患者名医咨询
  543. {
  544. // getDoctorTeamInfo(payload);
  545. }
  546. // else if (payload.business_type && (payload.business_type == "D_CT_01" || payload.business_type == "D_CT_02")) {
  547. // //D_CT_01, 指定咨询, 您有新的指定咨询
  548. // //D_CT_02, 指定咨询, 您有新的消息
  549. // mui.later(function() {
  550. // openWebview('../html/xiaoxipage.html');
  551. // }, 200);
  552. // } else if (payload.business_type && (payload.business_type == "D_CT_03" || payload.business_type == "D_CT_04")) {
  553. // //D_CT_03, 名医咨询, 您有新的名医咨询(患者发起)
  554. // //D_CT_04, 名医咨询, 您有新的名医咨询(医生发起)
  555. // mui.later(function() {
  556. // openWebview('../html/home1.html');
  557. // }, 200);
  558. // } 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")) {
  559. // //家庭签约
  560. // mui.later(function() {
  561. // openWebview('../../qygl/html/qianyuexiaoxi.html');
  562. //// openWebview("../../qygl/html/sign_manage.html")
  563. // }, 200);
  564. // } else if (payload.business_type && payload.business_type == "D_HI_01") {//体征指标
  565. // mui.later(function() {
  566. //// openWebview('../../xiaoxi/html/tizhengzhibiao.html');
  567. // openWebview("../../xiaoxi/html/jiankangtizheng.html");
  568. // }, 200);
  569. // } else if (payload.business_type && payload.business_type == "D_NH_01") {
  570. // mui.later(function() {
  571. //// openWebview('../../home/html/xiaoxi.html');
  572. // openWebview("../../message/html/xitongxiaoxi.html");
  573. // }, 200);
  574. // } else if (payload.business_type && payload.business_type == "D_ST_01") {
  575. // mui.later(function() {
  576. // openWebview('../../home/html/home1.html');
  577. // }, 200);
  578. // }else if (payload.business_type && (payload.business_type == "D_ST_02"||payload.business_type == "D_ST_03")) {
  579. // mui.later(function() {
  580. //// openWebview('../../home/html/home2.html');
  581. // openWebview('../../qygl/html/qianyuexiaoxi.html');
  582. // }, 200);
  583. // }
  584. //配置随访相关的消息页面跳转:随访计划提醒(4)、随访计划完成消息(D_FU_01)、随访计划阶段完成消息(D_FU_02)、随访计划随访项完成消息(D_FU_03)、患者回答随访记录消息(D_FU_04)
  585. 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")){
  586. // mui.later(function(){
  587. // openWebview('../../suifang/html/index.html');
  588. // }, 200);
  589. }
  590. }
  591. // }, false);
  592. }
  593. //获取医生团队信息
  594. function getDoctorTeamInfo(payload){
  595. imClient.Sessions.getSessionsInfo(payload.session_id,payload.from, function(res){
  596. // plus.nativeUI.alert(JSON.stringify(res))
  597. mui.later(function() {
  598. var params = {sessionId: payload.session_id, sessionName: res.name};
  599. if (payload.business_type=="1" && payload.session_type=="2") {//医生对医生 p2p
  600. openWebview("../../message/html/p2p.html",params);
  601. }else if (payload.business_type=="1" && payload.session_type=="3") {//群组
  602. openWebview("../../message/html/tuanduiqunliao.html",params);
  603. }else if (payload.business_type=="2" && payload.session_type=="1") {//健康咨询 p2d
  604. openWebview("../../message/html/p2dzixun.html",params);
  605. }else if (payload.business_type=="2" && payload.session_type=="2") {//患者名医咨询
  606. openWebview("../../message/html/p2dzixun.html",params);
  607. }
  608. }, 200);
  609. });
  610. }
  611. //角标增长
  612. //function addInc () {
  613. // var badgeStep = plus.storage.getItem('badge_step');
  614. // if(!!!badgeStep) badgeStep = 0;
  615. // badgeStep = (+badgeStep) + 1;
  616. // plus.storage.setItem( 'badge_step', badgeStep.toString());
  617. // plus.runtime.setBadgeNumber(badgeStep);
  618. //}
  619. //清空角标
  620. function clearInc () {
  621. if (plus.os.name != "iOS") {
  622. plus.push.clear();
  623. }
  624. // plus.storage.setItem( 'badgeStep', 0);
  625. plus.runtime.setBadgeNumber(0);
  626. }
  627. /**
  628. * 初始化角色切换事件
  629. */
  630. function qiehuanInit(main){
  631. if(plus.webview.getWebviewById('qiehuan.html')){
  632. plus.webview.getWebviewById('qiehuan.html').close();
  633. }
  634. var qiehuan = mui.createWindow({
  635. id: 'qiehuan.html',
  636. url: 'qiehuan.html',
  637. styles: {
  638. top: 0,
  639. bottom: 0,
  640. left: '45%',
  641. // width: '55%',
  642. scorllIndicator: "none"
  643. },
  644. show:{
  645. aniShow: "slide-in-right",
  646. duration: "400"
  647. }
  648. });
  649. main.addEventListener("maskClick",function(){
  650. main.setStyle({mask:"none"});
  651. qiehuan.hide();
  652. }, false);
  653. window.addEventListener("showQiehuan", function() {
  654. qiehuan.show();
  655. main.setStyle({mask:"rgba(0,0,0,0.5)"});
  656. });
  657. window.addEventListener("hideQiehuan", function(e) {
  658. var docType = parseInt(e.detail.type);
  659. var wbId, isShow;
  660. switch(docType) {
  661. case 1:
  662. isShow = false;
  663. wbId = "home1.html";
  664. break;
  665. case 2:
  666. case 3:
  667. isShow = true;
  668. wbId = "home2.html";
  669. break;
  670. case 10:
  671. isShow = false;
  672. wbId = "admin.html";
  673. break;
  674. default:
  675. break;
  676. }
  677. $(".mui-tab-item").eq(2).toggle((docType==1 || isShow) && teamCount>0);
  678. $(".mui-tab-item").eq(3).toggle(isShow);
  679. $(".mui-tab-item").eq(1).toggle(isShow && teamCount>0);
  680. $(".mui-tab-item").eq(0).attr("data-src", wbId);
  681. var wb;
  682. if(!(wb=plus.webview.getWebviewById(wbId))){
  683. var subStyles = {
  684. top: 0,
  685. bottom: "51px",
  686. scorllIndicator: "none"
  687. };
  688. main.append(plus.webview.create(wbId, wbId, subStyles));
  689. }
  690. else
  691. wb.show();
  692. main.setStyle({mask:"none"});
  693. qiehuan.hide("slide-in-left");
  694. });
  695. }