main.js 23 KB

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