huanzhexinxi.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. var self; //当前页面对象
  2. var patiCode; //居民标识
  3. var currDays = 7; //默认日期类型
  4. var indexType = "1"; //指标类型
  5. var currIndexCode = "" //当前要显示的指标类型
  6. var docType=""//医生类别
  7. var signType = "";
  8. var date_begin = getDateBefore(6);
  9. var date_end = getNowDate();
  10. var oPatiInfo =null;
  11. var iscroller = null;
  12. var doctorCode = null;
  13. var qyRelation;
  14. var overdue; //判断患者与医生的签约状态是否已过期
  15. var currService;
  16. var jtServerCode=[];//服务类型名称
  17. var jtAdminTeamId; // 标记患者的签约团队id
  18. mui.plusReady(function() {
  19. self = plus.webview.currentWebview();
  20. patiCode = self.patiCode;
  21. console.log(patiCode)
  22. doctorCode = JSON.parse(plus.storage.getItem("docInfo")).code;
  23. overdue = self.overdue;
  24. $("#pati_info").attr("code",patiCode);
  25. localStorage.removeItem('updateService');
  26. getPatiInfo();
  27. initScroller();
  28. });
  29. mui.back = function(){
  30. // self.opener().reload(true);
  31. //如果父窗口为im, 更新im
  32. if(self.opener().id=='p2dzixun'){
  33. mui.fire(self.opener(), 'update');
  34. }
  35. self.close();
  36. }
  37. //获取病人信息
  38. function getPatiInfo(){
  39. sendPost("/doctor/patient_label_info/patient",
  40. {patient: patiCode}, null,
  41. function(res){
  42. if(res.status == 200){
  43. oPatiInfo = res.data;
  44. bindEvents();
  45. dealPatiInfoTmpl(oPatiInfo);
  46. $(".div-dianhua").attr("data-mobile",oPatiInfo.mobile).attr("data-phone",oPatiInfo.phone);
  47. } else {
  48. mui.toast("获取病人信息失败");
  49. }
  50. },'POST','',true);
  51. }
  52. function sendWeixinRemind() {
  53. sendPost("doctor/family_contract/wechat_focus_remind",
  54. {patient: patiCode,isAll:0}, null,
  55. function(res){
  56. if(res.status == 200){
  57. oPatiInfo.wechatFocusRemind = 1;
  58. showRemindBtn(true);
  59. } else {
  60. oPatiInfo.wechatFocusRemind = 1;
  61. showRemindBtn(true);
  62. mui.toast(res.msg);
  63. }
  64. },'POST','',true);
  65. }
  66. function showRemindBtn(isReminded) {
  67. var $remind = $("#remind_gz");
  68. $remind.show();
  69. if(isReminded) {
  70. $remind.addClass("ytx");
  71. $remind.find("a").text("已提醒关注");
  72. } else {
  73. $remind.removeClass("ytx");
  74. $remind.find("a").text("提醒关注微信");
  75. }
  76. }
  77. function checkWeixinRemind(data) {
  78. return new Promise(function(resolve, reject) {
  79. sendPost("doctor/family_contract/is_patient_remind_focus",
  80. {patient: patiCode}, null,
  81. function(res){
  82. if(res.status == 200){
  83. if(res.data==0) { // 0: 当日未提醒
  84. isWeiXinRemind(data);
  85. }
  86. } else {
  87. mui.toast(res.msg);
  88. }
  89. },'POST','',true)
  90. });
  91. }
  92. function isWeiXinRemind (data) {
  93. if(data) {
  94. var isReminded = data.wechatFocusRemind=="1"? true: false,
  95. // 签约类型: 1-->三师 2-->家庭 3-->三师 、家庭两者都有
  96. signType = data.signType,
  97. // 缴费状态: 2-->已退费 1-->已缴费 0-->未交费
  98. expensesStatus = data.expensesStatus,
  99. openid = data.openid;
  100. if(!openid) {
  101. // 有签约家庭医生,但未交费,则有该悬浮按钮
  102. if((signType=="2" || signType=="3") && expensesStatus=="1") {
  103. showRemindBtn(isReminded);
  104. }
  105. // 2、如只有三师签约,但无openid,则有该悬浮按钮
  106. else if(signType == "1") {
  107. showRemindBtn(isReminded);
  108. }
  109. }
  110. }
  111. }
  112. // 滚动条实例初始化
  113. function initScroller() {
  114. //阻尼系数
  115. var deceleration = mui.os.ios?0.003:0.0009;
  116. mui('.mui-scroll-wrapper').scroll({
  117. bounce: false,
  118. indicators: true, //是否显示滚动条
  119. deceleration:deceleration
  120. });
  121. iscroller = mui(".mui-scroll").pullToRefresh({
  122. down: {
  123. callback: function() {
  124. var self = this;
  125. setTimeout(function() {
  126. refreshPage();
  127. self.endPullDownToRefresh();
  128. }, 1000);
  129. }
  130. }
  131. });
  132. }
  133. /*
  134. * 拼接居民信息模板
  135. */
  136. function dealPatiInfoTmpl(patiInfoObj) {
  137. $("#pati_info_wrap").html(template("pati_info_tmpl", patiInfoObj));
  138. $('#view_wrap').show();
  139. }
  140. /*
  141. * 查看居民资料
  142. */
  143. function toInfo() {
  144. var $el = $(this);
  145. mui.openWindow("huanzeziliao.html", "huanzeziliao", {
  146. extras: {
  147. patiPhoto: $el.find('.doc-avatar img').attr('src'),
  148. patiCode: patiCode,
  149. signType: signType,
  150. teamCode: self.teamCode,
  151. //添加续签状态值
  152. qyRelation: qyRelation,
  153. renewable: oPatiInfo.isRenewable
  154. }
  155. })
  156. }
  157. function openwdsb(){
  158. // var params={};
  159. // params.patient = patiCode;
  160. // openWebviewExtras("../../wdsb/html/my-equipments.html",params);
  161. mui.openWindow('../../jkjl/html/health-record.html', 'health-record', {
  162. extras: {
  163. patientCode: patiCode,
  164. patientName: oPatiInfo.name,
  165. qyRelation: qyRelation
  166. }
  167. })
  168. }
  169. /*
  170. * 服务记录
  171. */
  172. function fwjl() {
  173. mui.openWindow('fuwujilu.html', 'fuwujilu', {
  174. extras: {
  175. patientCode: patiCode,
  176. patientName: oPatiInfo.name,
  177. qyRelation: qyRelation
  178. }
  179. });
  180. }
  181. /*
  182. * 健康指导
  183. */
  184. function jkzd() {
  185. // diaAdd.close();
  186. mui.openWindow('../../hzzd/html/guidance_list.html', 'jkzd', {
  187. extras: {
  188. code: patiCode
  189. }
  190. });
  191. }
  192. /*
  193. * 体征预警
  194. */
  195. function tzyj() {
  196. // diaAdd.close();
  197. mui.openWindow('tzyj.html', 'tzyj', {
  198. extras: {
  199. code: patiCode
  200. }
  201. });
  202. }
  203. /*
  204. * 健康记录点击事件
  205. */
  206. /*
  207. * 药物记录
  208. */
  209. function ywjl(dom) {
  210. var text = $(dom).find("p").eq(0).text();
  211. if(text == "-") {
  212. mui.toast("暂无健康记录");
  213. return;
  214. }
  215. mui.openWindow('../../hzgl/html/health-record-drug.html', 'health-record-drug', {
  216. extras: {
  217. pCode: patiCode
  218. }
  219. });
  220. }
  221. /*
  222. * 饮食记录
  223. */
  224. function ysjl(dom) {
  225. var text = $(dom).find("p").eq(0).text();
  226. if(text == "-") {
  227. mui.toast("暂无健康记录");
  228. return;
  229. }
  230. mui.openWindow('../../hzgl/html/health-record-diet.html', 'health-record-diet', {
  231. extras: {
  232. pCode: patiCode
  233. }
  234. });
  235. }
  236. /*
  237. * 运动记录
  238. */
  239. function ydjl(dom) {
  240. var text = $(dom).find("p").eq(0).text();
  241. if(text == "-") {
  242. mui.toast("暂无健康记录");
  243. return;
  244. }
  245. mui.openWindow('../../hzgl/html/health-record-sport.html', 'health-record-sport', {
  246. extras: {
  247. pCode: patiCode
  248. }
  249. });
  250. }
  251. /*
  252. * 分组
  253. */
  254. function fz() {
  255. mui.openWindow('../../zxyy/html/xuanzeyiyuan.html', 'xuanzeyiyuan', {
  256. extras: {
  257. pCode: patiCode
  258. }
  259. });
  260. }
  261. function toSelectJb(){
  262. debugger
  263. var self = plus.webview.currentWebview();
  264. var update = localStorage.getItem('updateService');
  265. var oldData = jtServerCode.join(',');
  266. mui.openWindow({
  267. url: 'disease-label-edit.html',
  268. id: 'disease-label-edit',
  269. extras: {
  270. patientCode: patiCode,
  271. viewId: self.id,
  272. signCode:oPatiInfo.signCode,//变更服务类型用
  273. serviceCode: update?update:oldData,
  274. isChange:$("#smallTipSev").is(":hidden")?false:true//判断是否处于变更
  275. }
  276. });
  277. }
  278. var labelName =[];
  279. function queryFailed(res){
  280. if(res.msg){
  281. if (res.msg != '查询失败') {
  282. mui.toast(res.msg);
  283. }
  284. }else{
  285. mui.toast("标签加载失败!");
  286. }
  287. }
  288. $('#more_event').on('tap',function() {
  289. openWebview("jiuzhenjilu.html",{patiInfo: oPatiInfo})
  290. });
  291. $('.fix-adds').on('tap', function() {
  292. $(".div-dialog-content").show();
  293. $(".modal-overlay").addClass("modal-overlay-visible");
  294. });
  295. $('.div-dialog-content').on('tap',"div", function() {
  296. if(!$(this).hasClass("quxiao")){
  297. hideBing();
  298. if($(this).hasClass("addjkzd")){//健康指导
  299. jkzd();
  300. }else if($(this).hasClass("addfzgl")){//分组管理
  301. fz();
  302. }else if($(this).hasClass("addtzyj")){//体征预警
  303. tzyj();
  304. }else if($(this).hasClass("addtzsb")){//体征设备
  305. openwdsb();
  306. }else if($(this).hasClass("addjtcy")){//家庭成员
  307. jtcy();
  308. }
  309. }else if($(this).hasClass("quxiao")){//取消
  310. $('.fix-adds').show();
  311. $(".div-dialog-content").hide();
  312. $(".modal-overlay").removeClass("modal-overlay-visible");
  313. }
  314. });
  315. function hideBing(){
  316. $('.fix-adds').show();
  317. $(".div-dialog-content").hide();
  318. $(".modal-overlay").removeClass("modal-overlay-visible");
  319. }
  320. $(".modal-overlay").on('tap', function() {
  321. hideBing();
  322. });
  323. $('#recent_events').on('tap','li',function() {
  324. var data = JSON.parse($(this).attr("data-json"));
  325. openWebview("health-profile.html",{eventInfo: data,patiInfo: oPatiInfo});
  326. });
  327. /*
  328. * 家庭成员
  329. */
  330. function jtcy() {
  331. mui.openWindow('jiatingchengyuan.html', 'jiatingchengyuan', {
  332. extras: {
  333. code: patiCode,
  334. patiInfo: oPatiInfo,
  335. qyRelation: qyRelation
  336. }
  337. });
  338. }
  339. /*
  340. * 咨询记录
  341. */
  342. function zxjl() {
  343. mui.openWindow('zixunjilu.html', 'zixunjilu', {
  344. extras: {
  345. code: patiCode,
  346. qyRelation: qyRelation
  347. }
  348. });
  349. }
  350. /*
  351. * 指导记录
  352. */
  353. function zdjl() {
  354. mui.openWindow('zhidaojilu.html', 'zhidaojilu', {
  355. extras: {
  356. code: patiCode,
  357. qyRelation: qyRelation
  358. }
  359. });
  360. }
  361. /*
  362. * 代预约记录
  363. */
  364. function dyyjl(){
  365. mui.openWindow('../../wdyy/html/my-appointment.html', 'my-appointment', {
  366. extras: {
  367. patient: patiCode,
  368. qyRelation: qyRelation
  369. }
  370. });
  371. }
  372. /*
  373. * 代预约
  374. */
  375. function dyy() {
  376. mui.openWindow('../../wdyy/html/appointment-register.html', 'appointment-register', {
  377. extras: {
  378. patient: patiCode
  379. }
  380. });
  381. }
  382. //拨打电话
  383. $(".div-dianhua").on("tap",function(){
  384. var moblie = $(this).attr("data-mobile");
  385. var phone = $(this).attr("data-phone");
  386. //观察者模式下,不可以拨打被观察者患者的电话
  387. var userAgent = plus.navigator.getUserAgent(),
  388. index = userAgent.indexOf("}"),
  389. s = userAgent.substr(0, index+1),
  390. item = JSON.parse(s);
  391. if(item.observer){
  392. mui.toast("观察者模式无法拨打患者电话");
  393. }else{
  394. if(moblie){
  395. dialog({
  396. content: moblie,
  397. okValue:'立即拨号',
  398. ok: function (){
  399. window.location.href = "tel:"+moblie;
  400. },
  401. cancelValue: '不了,谢谢',
  402. cancel: function () {
  403. return;
  404. }
  405. }).showModal();
  406. }else{
  407. if(phone){
  408. dialog({
  409. content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,是否拨打联系人电话?",
  410. okValue:'立即拨号',
  411. ok: function (){
  412. window.location.href = "tel:"+phone;
  413. },
  414. cancelValue: '不了,谢谢',
  415. cancel: function () {
  416. return;
  417. }
  418. }).showModal();
  419. }else{
  420. dialog({
  421. content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,无法电话联系",
  422. okValue:'我知道了',
  423. ok: function (){
  424. return;
  425. },
  426. }).showModal();
  427. }
  428. }
  429. }
  430. })
  431. function refreshPage () {
  432. labelName =[];
  433. jtServerCode = [];
  434. localStorage.removeItem('updateService');
  435. getPatiInfo();
  436. }
  437. window.addEventListener("refresh1", function(){
  438. refreshPage();
  439. var xxWv = plus.webview.getWebviewById("huanzhe-by-type");
  440. // 如果有打开分组列表也要刷新列表
  441. if(xxWv){
  442. mui.fire(xxWv, "refresh");
  443. }
  444. var xxindex = plus.webview.getWebviewById("huanzhe.html");
  445. // 如果有打开分组列表也要刷新列表
  446. if(xxindex){
  447. mui.fire(xxindex, "refresh");
  448. }
  449. })
  450. window.addEventListener("setDiseaseTypes", function(e){
  451. $('#diseases').html(e.detail.names);
  452. oPatiInfo.diseases = e.detail.diseases;
  453. })
  454. //门诊记录
  455. $(".div-menzhen-btn").on("tap",function(){
  456. // openWebview(templateServer,{itemIndex:0,name:"就诊记录", idcard: "362321199703137824"})
  457. })
  458. //住院记录
  459. $(".div-zhuyuan-btn").on("tap",function(){
  460. // openWebview(templateServer,{itemIndex:0,name:"就诊记录", idcard: oPatiInfo.idcard})
  461. })
  462. //检查检验记录
  463. $(".div-jianche-btn").on("tap",function(){
  464. // openWebview(templateServer,{itemIndex:1,name:"检查检验", idcard: oPatiInfo.idcard})
  465. })
  466. //用药记录
  467. $(".div-yongyao-btn").on("tap",function(){
  468. // openWebview(templateServer,{itemIndex:2,name:"用药记录", idcard: oPatiInfo.idcard})
  469. })
  470. //健康体检
  471. $(".div-jiankangtijian-btn").on("tap",function(){
  472. openWebview("jiankangtijian.html",{patiInfo: oPatiInfo})
  473. })
  474. /*
  475. * 健康教育
  476. */
  477. function jkjy() {
  478. // mui.openWindow('../../jkjy/html/jiankangjiaoyu.html', 'jiankangjiaoyu', {
  479. mui.openWindow('../../jkjy/html/article-store.html', 'jiankangjiaoyu', {
  480. extras: {
  481. patient: patiCode,
  482. patientName: oPatiInfo.name,
  483. teamCode: jtAdminTeamId
  484. }
  485. });
  486. }
  487. function xfjl() {
  488. mui.openWindow('../../prescription/html/juminxufangjilu.html', 'juminxufangjilu', {
  489. extras: {
  490. teamCode:oPatiInfo.jtAdminTeam,
  491. patiCode: patiCode,
  492. patiName: oPatiInfo.name
  493. }
  494. })
  495. }
  496. function fybj() {
  497. mui.openWindow('../../fybj/html/yunjianjihua.html', 'yunjianjihua', {
  498. extras: {
  499. patiCode: patiCode,
  500. doctorCode:doctorCode
  501. }
  502. })
  503. }
  504. function myjl() {
  505. mui.openWindow('../../fybj/html/mianyijihua.html', 'mianyijihua', {
  506. extras: {
  507. patiCode: patiCode
  508. }
  509. })
  510. }
  511. /* 事件绑定*/
  512. function bindEvents(){
  513. //服务记录
  514. $("#fwjl").on('tap', fwjl);
  515. //健康记录
  516. $("#tzsb").on('tap', openwdsb);
  517. //家庭成员
  518. $("#family").on('tap', jtcy);
  519. //提醒关注
  520. $("#remind_gz").on('tap', function(){
  521. mui("#sheet1").popover('toggle');
  522. if($(this).hasClass("ytx")){//今日已提醒
  523. mui.toast("居民今天已经收到过提醒了哦,不可再次提醒");
  524. }else{//今日未提醒
  525. sendWeixinRemind();
  526. }
  527. });
  528. //健康指导
  529. $("#jkzd").on('tap', jkzd);
  530. //体征预警
  531. $("#tzyj").on('tap', tzyj);
  532. //分组
  533. $("#fz").on('tap', fz);
  534. //干预
  535. $("#gy").on('tap', gy);
  536. $("#pati_info_wrap").on('tap', '#pati_info', toInfo);
  537. $("#view_scroller").on('tap', "#diseasesWrap", toSelectJb);
  538. //健康教育
  539. $(".div-jkjy-btn").on('tap', jkjy);
  540. //新增指导
  541. $(".div-add-guide-btn").on('tap', jkzd);
  542. //随访
  543. $(".div-suifang-btn").on('tap',function(){
  544. // openWebview("../../suifang/html/choose_suifang.html", {patiCode: oPatiInfo.code});
  545. openWebview("../../suifang/html/suifang_list.html", {patientCode: oPatiInfo.code});
  546. });
  547. //显示更过操作
  548. $(".header-link").on('tap', function(){
  549. mui('#sheet1').popover('toggle');
  550. });
  551. }