main.js 23 KB

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