guanzhuxinxi.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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. $("#pati_info_wrap").html(template("pati_info_tmpl", patiInfoObj));
  136. $('#view_wrap').show();
  137. }
  138. /*
  139. * 查看居民资料
  140. */
  141. function toInfo() {
  142. var $el = $(this);
  143. mui.openWindow("huanzeziliao.html", "huanzeziliao", {
  144. extras: {
  145. patiPhoto: $el.find('.doc-avatar img').attr('src'),
  146. patiCode: patiCode,
  147. signType: signType,
  148. teamCode: self.teamCode,
  149. //添加续签状态值
  150. qyRelation: qyRelation,
  151. renewable: oPatiInfo.isRenewable
  152. }
  153. })
  154. }
  155. function openwdsb(){
  156. // var params={};
  157. // params.patient = patiCode;
  158. // openWebviewExtras("../../wdsb/html/my-equipments.html",params);
  159. mui.openWindow('../../jkjl/html/health-record.html', 'health-record', {
  160. extras: {
  161. patientCode: patiCode,
  162. patientName: oPatiInfo.name,
  163. qyRelation: qyRelation
  164. }
  165. })
  166. }
  167. /*
  168. * 服务记录
  169. */
  170. function fwjl() {
  171. mui.openWindow('fuwujilu.html', 'fuwujilu', {
  172. extras: {
  173. patientCode: patiCode,
  174. patientName: oPatiInfo.name,
  175. qyRelation: qyRelation
  176. }
  177. });
  178. }
  179. /*
  180. * 健康指导
  181. */
  182. function jkzd() {
  183. // diaAdd.close();
  184. mui.openWindow('../../hzzd/html/guidance_list.html', 'jkzd', {
  185. extras: {
  186. code: patiCode
  187. }
  188. });
  189. }
  190. /*
  191. * 体征预警
  192. */
  193. function tzyj() {
  194. // diaAdd.close();
  195. mui.openWindow('tzyj.html', 'tzyj', {
  196. extras: {
  197. code: patiCode
  198. }
  199. });
  200. }
  201. /*
  202. * 健康记录点击事件
  203. */
  204. /*
  205. * 药物记录
  206. */
  207. function ywjl(dom) {
  208. var text = $(dom).find("p").eq(0).text();
  209. if(text == "-") {
  210. mui.toast("暂无健康记录");
  211. return;
  212. }
  213. mui.openWindow('../../hzgl/html/health-record-drug.html', 'health-record-drug', {
  214. extras: {
  215. pCode: patiCode
  216. }
  217. });
  218. }
  219. /*
  220. * 饮食记录
  221. */
  222. function ysjl(dom) {
  223. var text = $(dom).find("p").eq(0).text();
  224. if(text == "-") {
  225. mui.toast("暂无健康记录");
  226. return;
  227. }
  228. mui.openWindow('../../hzgl/html/health-record-diet.html', 'health-record-diet', {
  229. extras: {
  230. pCode: patiCode
  231. }
  232. });
  233. }
  234. /*
  235. * 运动记录
  236. */
  237. function ydjl(dom) {
  238. var text = $(dom).find("p").eq(0).text();
  239. if(text == "-") {
  240. mui.toast("暂无健康记录");
  241. return;
  242. }
  243. mui.openWindow('../../hzgl/html/health-record-sport.html', 'health-record-sport', {
  244. extras: {
  245. pCode: patiCode
  246. }
  247. });
  248. }
  249. /*
  250. * 分组
  251. */
  252. function fz() {
  253. mui.openWindow('../../zxyy/html/xuanzeyiyuan.html', 'xuanzeyiyuan', {
  254. extras: {
  255. pCode: patiCode
  256. }
  257. });
  258. }
  259. function toSelectJb(){
  260. var self = plus.webview.currentWebview();
  261. var update = localStorage.getItem('updateService');
  262. var oldData = jtServerCode.join(',');
  263. mui.openWindow({
  264. url: 'disease-label-edit.html',
  265. id: 'disease-label-edit',
  266. extras: {
  267. patientCode: patiCode,
  268. viewId: self.id,
  269. signCode:oPatiInfo.signCode,//变更服务类型用
  270. serviceCode: update?update:oldData,
  271. isChange:$("#smallTipSev").is(":hidden")?false:true//判断是否处于变更
  272. }
  273. });
  274. }
  275. function dial(){
  276. var moblie = $(".div-dianhua").attr("data-mobile");
  277. var phone = $(".div-dianhua").attr("data-phone");
  278. var type = $(this).attr("data-type");
  279. //观察者模式下,不可以拨打被观察者患者的电话
  280. var userAgent = plus.navigator.getUserAgent(),
  281. index = userAgent.indexOf("}"),
  282. s = userAgent.substr(0, index+1),
  283. item = JSON.parse(s);
  284. if(item.observer){
  285. mui.toast("观察者模式无法拨打患者电话");
  286. }else{
  287. if(type==1){
  288. if(moblie){
  289. dialog({
  290. content: moblie,
  291. okValue:'立即拨号',
  292. ok: function (){
  293. window.location.href = "tel:"+moblie;
  294. },
  295. cancelValue: '不了,谢谢',
  296. cancel: function () {
  297. return;
  298. }
  299. }).showModal();
  300. }else{
  301. if(phone){
  302. dialog({
  303. content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,是否拨打联系人电话?",
  304. okValue:'立即拨号',
  305. ok: function (){
  306. window.location.href = "tel:"+phone;
  307. },
  308. cancelValue: '不了,谢谢',
  309. cancel: function () {
  310. return;
  311. }
  312. }).showModal();
  313. }else{
  314. dialog({
  315. content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,无法电话联系",
  316. okValue:'我知道了',
  317. ok: function (){
  318. return;
  319. },
  320. }).showModal();
  321. }
  322. }
  323. }else{
  324. if(phone){
  325. dialog({
  326. content: phone,
  327. okValue:'立即拨号',
  328. ok: function (){
  329. window.location.href = "tel:"+moblie;
  330. },
  331. cancelValue: '不了,谢谢',
  332. cancel: function () {
  333. return;
  334. }
  335. }).showModal();
  336. }else{
  337. if(moblie){
  338. dialog({
  339. content: "对不起,"+$(".patient-name").html()+"未填写联系人电话,是否拨打绑定的手机号码?",
  340. okValue:'立即拨号',
  341. ok: function (){
  342. window.location.href = "tel:"+phone;
  343. },
  344. cancelValue: '不了,谢谢',
  345. cancel: function () {
  346. return;
  347. }
  348. }).showModal();
  349. }else{
  350. dialog({
  351. content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,无法电话联系",
  352. okValue:'我知道了',
  353. ok: function (){
  354. return;
  355. },
  356. }).showModal();
  357. }
  358. }
  359. }
  360. }
  361. }
  362. function refreshPage () {
  363. labelName =[];
  364. jtServerCode = [];
  365. localStorage.removeItem('updateService');
  366. getPatiInfo();
  367. }
  368. window.addEventListener("refresh1", function(){
  369. refreshPage();
  370. var xxWv = plus.webview.getWebviewById("huanzhe-by-type");
  371. // 如果有打开分组列表也要刷新列表
  372. if(xxWv){
  373. mui.fire(xxWv, "refresh");
  374. }
  375. var xxindex = plus.webview.getWebviewById("huanzhe.html");
  376. // 如果有打开分组列表也要刷新列表
  377. if(xxindex){
  378. mui.fire(xxindex, "refresh");
  379. }
  380. })
  381. window.addEventListener("setDiseaseTypes", function(e){
  382. $('#diseases').html(e.detail.names);
  383. oPatiInfo.diseases = e.detail.diseases;
  384. })
  385. function toInfo() {
  386. var $el = $(this);
  387. mui.openWindow("../../huanzhe/html/huanzhexinxi.html", "huanzhexinxi", {
  388. extras: {
  389. patiCode: patiCode
  390. }
  391. })
  392. }
  393. /* 事件绑定*/
  394. function bindEvents(){
  395. //查看居民详情
  396. $("#pati_info_wrap").on('tap', '#pati_info', toInfo);
  397. //拨打电话
  398. $("#pati_info_wrap").on('tap','.div-dianhua',dial)
  399. }