main.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  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. console.log("login IM");
  199. loginIm(userId,token,client_id,platform);
  200. // }
  201. // var subPages = [];
  202. //docType 10 是管理员
  203. // docType="10"
  204. // switch(docType) {
  205. // case "1":
  206. // subPages = ["home1.html", "mine.html"];
  207. // if(teamCount > 0){
  208. // $(".mui-tab-item").eq(2).show();
  209. // subPages.push("../../tuandui/html/tuandui.html");
  210. // }
  211. // $(".mui-tab-item").eq(3).hide();
  212. // $(".mui-tab-item").eq(1).hide();
  213. // $(".mui-tab-item").eq(0).attr("data-src", "home1.html")
  214. // break;
  215. // case "2":
  216. // case "3":
  217. var subPages = ["home2.html", "huanzhe.html", "../../tuandui/html/tuandui.html", "xiaoxi.html", "mine.html"];
  218. // break;
  219. // case "10":
  220. // subPages = ["admin.html", "mine.html"];
  221. // if(level!=10){
  222. // if(teamCount > 0){
  223. // subPages.push("../../tuandui/html/tuandui.html");
  224. // }
  225. // subPages.push("huanzhe.html");
  226. // subPages.push("xiaoxi.html");
  227. // }
  228. // $(".mui-tab-item").eq(2).hide();
  229. // $(".mui-tab-item").eq(1).hide();
  230. // $(".mui-tab-item").eq(3).hide();
  231. // $(".mui-tab-item").eq(0).attr("data-src","admin.html")
  232. // break;
  233. // default:
  234. // break;
  235. // }
  236. // if(isMultiRole()){
  237. // subPages.push("admin.html");
  238. // //初始化角色切换事件
  239. // qiehuanInit(self);
  240. // }
  241. $('.mui-bar').show();
  242. var subStyles = {
  243. top: topoffset,
  244. bottom: "51px",
  245. scorllIndicator: "none",
  246. bounceBackground: "#17b3ec"
  247. };
  248. // for(var i = 0; i < subPages.length; i++) {
  249. // var sub_wv ;
  250. // var ws = plus.webview.getWebviewById(subPages[i]);
  251. // if(ws){
  252. // continue;
  253. // }
  254. // else
  255. // sub_wv = plus.webview.create(subPages[i], subPages[i], subStyles);
  256. // if(i > 0) {
  257. // sub_wv.hide();
  258. // }
  259. // self.append(sub_wv);
  260. // }
  261. //添加返回管理员账号时,显示admin页面
  262. // if(plus.storage.getItem('backToAdmin')){
  263. // console.log("back to admin");
  264. //
  265. // var ws = mui.openWindow({
  266. // url:"admin.html",
  267. // id:"admin.html",
  268. // styles:subStyles,
  269. // waiting:{
  270. // autoShow:true,//自动显示等待框,默认为true
  271. // title:'正在加载...'//等待对话框上显示的提示内容
  272. // }
  273. // });
  274. // self.append(ws);
  275. // $(".mui-tab-item").eq(2).hide();
  276. // $(".mui-tab-item").eq(1).hide();
  277. // $(".mui-tab-item").eq(3).hide();
  278. // $(".mui-tab-item").eq(0).attr("data-src","admin.html");
  279. // mui.later(function(){
  280. // var qiehuan = plus.webview.getWebviewById('qiehuan.html');
  281. // mui.fire(qiehuan, 'checkAdmin');
  282. // console.log("clear backtoAdmin");
  283. // plus.storage.removeItem('backToAdmin');
  284. // }, 2000);
  285. //
  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 = false;
  672. wbId = "home1.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) && teamCount>0);
  687. $(".mui-tab-item").eq(3).toggle(isShow);
  688. $(".mui-tab-item").eq(1).toggle(isShow && teamCount>0);
  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. }