guanzhuxinxi.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. var self; //当前页面对象
  2. var patiCode; //居民标识
  3. var concernCode; //居民关注标识
  4. var currDays = 7; //默认日期类型
  5. var indexType = "1"; //指标类型
  6. var currIndexCode = "" //当前要显示的指标类型
  7. var docType=""//医生类别
  8. var signType = "";
  9. var oPatiInfo =null;
  10. var iscroller = null;
  11. var doctorCode = null;
  12. var qyRelation;
  13. var overdue; //判断患者与医生的签约状态是否已过期
  14. var currService;
  15. var jtServerCode=[];//服务类型名称
  16. var jtAdminTeamId; // 标记患者的签约团队id
  17. mui.plusReady(function() {
  18. self = plus.webview.currentWebview();
  19. concernCode = self.concernCode;
  20. patiCode = self.code;
  21. doctorCode = JSON.parse(plus.storage.getItem("docInfo")).code;
  22. overdue = self.overdue;
  23. $("#pati_info").attr("code",patiCode);
  24. localStorage.removeItem('updateService');
  25. getPatiInfo();
  26. initScroller();
  27. });
  28. mui.back = function(){
  29. // self.opener().reload(true);
  30. //如果父窗口为im, 更新im
  31. if(self.opener().id=='p2dzixun'){
  32. mui.fire(self.opener(), 'update');
  33. }
  34. self.close();
  35. }
  36. //获取病人信息
  37. function getPatiInfo(code){
  38. sendGet("/doctor/concern/findByCode",
  39. {concernCode: concernCode}, null,
  40. function(res){
  41. if(res.status == 200){
  42. oPatiInfo = res.data;
  43. bindEvents();
  44. dealPatiInfoTmpl(oPatiInfo);
  45. } else {
  46. mui.toast("获取病人信息失败");
  47. }
  48. },'POST','',true);
  49. }
  50. function sendWeixinRemind() {
  51. sendPost("doctor/family_contract/wechat_focus_remind",
  52. {patient: patiCode,isAll:0}, null,
  53. function(res){
  54. if(res.status == 200){
  55. oPatiInfo.wechatFocusRemind = 1;
  56. showRemindBtn(true);
  57. } else {
  58. oPatiInfo.wechatFocusRemind = 1;
  59. showRemindBtn(true);
  60. mui.toast(res.msg);
  61. }
  62. },'POST','',true);
  63. }
  64. function showRemindBtn(isReminded) {
  65. var $remind = $("#remind_gz");
  66. $remind.show();
  67. if(isReminded) {
  68. $remind.addClass("ytx");
  69. $remind.find("a").text("已提醒关注");
  70. } else {
  71. $remind.removeClass("ytx");
  72. $remind.find("a").text("提醒关注微信");
  73. }
  74. }
  75. function checkWeixinRemind(data) {
  76. return new Promise(function(resolve, reject) {
  77. sendPost("doctor/family_contract/is_patient_remind_focus",
  78. {patient: patiCode}, null,
  79. function(res){
  80. if(res.status == 200){
  81. if(res.data==0) { // 0: 当日未提醒
  82. isWeiXinRemind(data);
  83. }
  84. } else {
  85. mui.toast(res.msg);
  86. }
  87. },'POST','',true)
  88. });
  89. }
  90. function isWeiXinRemind (data) {
  91. if(data) {
  92. var isReminded = data.wechatFocusRemind=="1"? true: false,
  93. // 签约类型: 1-->三师 2-->家庭 3-->三师 、家庭两者都有
  94. signType = data.signType,
  95. // 缴费状态: 2-->已退费 1-->已缴费 0-->未交费
  96. expensesStatus = data.expensesStatus,
  97. openid = data.openid;
  98. if(!openid) {
  99. // 有签约家庭医生,但未交费,则有该悬浮按钮
  100. if((signType=="2" || signType=="3") && expensesStatus=="1") {
  101. showRemindBtn(isReminded);
  102. }
  103. // 2、如只有三师签约,但无openid,则有该悬浮按钮
  104. else if(signType == "1") {
  105. showRemindBtn(isReminded);
  106. }
  107. }
  108. }
  109. }
  110. // 滚动条实例初始化
  111. function initScroller() {
  112. //阻尼系数
  113. var deceleration = mui.os.ios?0.003:0.0009;
  114. mui('.mui-scroll-wrapper').scroll({
  115. bounce: false,
  116. indicators: true, //是否显示滚动条
  117. deceleration:deceleration
  118. });
  119. iscroller = mui(".mui-scroll").pullToRefresh({
  120. down: {
  121. callback: function() {
  122. var self = this;
  123. setTimeout(function() {
  124. refreshPage();
  125. self.endPullDownToRefresh();
  126. }, 1000);
  127. }
  128. }
  129. });
  130. }
  131. /*
  132. * 拼接居民信息模板
  133. */
  134. function dealPatiInfoTmpl(patiInfoObj) {
  135. patiInfoObj.idcard = plusXing(patiInfoObj.idcard,6,2);
  136. patiInfoObj.ssc = plusXing(patiInfoObj.ssc,4,1);
  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. var self = plus.webview.currentWebview();
  263. var update = localStorage.getItem('updateService');
  264. var oldData = jtServerCode.join(',');
  265. mui.openWindow({
  266. url: 'disease-label-edit.html',
  267. id: 'disease-label-edit',
  268. extras: {
  269. patientCode: patiCode,
  270. viewId: self.id,
  271. signCode:oPatiInfo.signCode,//变更服务类型用
  272. serviceCode: update?update:oldData,
  273. isChange:$("#smallTipSev").is(":hidden")?false:true//判断是否处于变更
  274. }
  275. });
  276. }
  277. function dial(){
  278. var moblie = $(".div-dianhua").attr("data-mobile");
  279. var phone = $(".div-dianhua").attr("data-phone");
  280. var type = $(this).attr("data-type");
  281. //观察者模式下,不可以拨打被观察者患者的电话
  282. var userAgent = plus.navigator.getUserAgent(),
  283. index = userAgent.indexOf("}"),
  284. s = userAgent.substr(0, index+1),
  285. item = JSON.parse(s);
  286. if(item.observer){
  287. mui.toast("观察者模式无法拨打患者电话");
  288. }else{
  289. if(type==1){
  290. if(moblie){
  291. dialog({
  292. content: moblie,
  293. okValue:'立即拨号',
  294. ok: function (){
  295. window.location.href = "tel:"+moblie;
  296. },
  297. cancelValue: '不了,谢谢',
  298. cancel: function () {
  299. return;
  300. }
  301. }).showModal();
  302. }else{
  303. if(phone){
  304. dialog({
  305. content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,是否拨打联系人电话?",
  306. okValue:'立即拨号',
  307. ok: function (){
  308. window.location.href = "tel:"+phone;
  309. },
  310. cancelValue: '不了,谢谢',
  311. cancel: function () {
  312. return;
  313. }
  314. }).showModal();
  315. }else{
  316. dialog({
  317. content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,无法电话联系",
  318. okValue:'我知道了',
  319. ok: function (){
  320. return;
  321. },
  322. }).showModal();
  323. }
  324. }
  325. }else{
  326. if(phone){
  327. dialog({
  328. content: phone,
  329. okValue:'立即拨号',
  330. ok: function (){
  331. window.location.href = "tel:"+moblie;
  332. },
  333. cancelValue: '不了,谢谢',
  334. cancel: function () {
  335. return;
  336. }
  337. }).showModal();
  338. }else{
  339. if(moblie){
  340. dialog({
  341. content: "对不起,"+$(".patient-name").html()+"未填写联系人电话,是否拨打绑定的手机号码?",
  342. okValue:'立即拨号',
  343. ok: function (){
  344. window.location.href = "tel:"+phone;
  345. },
  346. cancelValue: '不了,谢谢',
  347. cancel: function () {
  348. return;
  349. }
  350. }).showModal();
  351. }else{
  352. dialog({
  353. content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,无法电话联系",
  354. okValue:'我知道了',
  355. ok: function (){
  356. return;
  357. },
  358. }).showModal();
  359. }
  360. }
  361. }
  362. }
  363. }
  364. function refreshPage () {
  365. labelName =[];
  366. jtServerCode = [];
  367. localStorage.removeItem('updateService');
  368. getPatiInfo();
  369. }
  370. window.addEventListener("refresh1", function(){
  371. refreshPage();
  372. var xxWv = plus.webview.getWebviewById("huanzhe-by-type");
  373. // 如果有打开分组列表也要刷新列表
  374. if(xxWv){
  375. mui.fire(xxWv, "refresh");
  376. }
  377. var xxindex = plus.webview.getWebviewById("huanzhe.html");
  378. // 如果有打开分组列表也要刷新列表
  379. if(xxindex){
  380. mui.fire(xxindex, "refresh");
  381. }
  382. })
  383. window.addEventListener("setDiseaseTypes", function(e){
  384. $('#diseases').html(e.detail.names);
  385. oPatiInfo.diseases = e.detail.diseases;
  386. })
  387. function toInfo() {
  388. var $el = $(this);
  389. mui.openWindow("../../huanzhe/html/huanzhexinxi.html", "huanzhexinxi", {
  390. extras: {
  391. patiCode: patiCode
  392. }
  393. })
  394. }
  395. /* 事件绑定*/
  396. function bindEvents(){
  397. //查看居民详情
  398. $("#pati_info_wrap").on('tap', '#pati_info', toInfo);
  399. //拨打电话
  400. $("#pati_info_wrap").on('tap','.div-dianhua',dial)
  401. }
  402. //str:字符串,frontLen:前面保留位数,endLen:后面保留位数
  403. function plusXing(str, frontLen, endLen) {
  404. var len = str.length - frontLen - endLen;
  405. var xing = '';
  406. for(var i = 0; i < len; i++) {
  407. xing += '*';
  408. }
  409. return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
  410. }