electronicHealthCard.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. var Request = GetRequest();
  2. var d = dialog({ contentType: 'load', skin: 'bk-popup' });
  3. var checktype=false;
  4. (function() {
  5. myvue=new Vue({
  6. el: "#app",
  7. data: {
  8. isloading:true,
  9. loaddingTxt:"受理中...",
  10. patient:"", //当前用户code
  11. data:{}, //电子健康卡数据
  12. cardNo:"", //加密后卡号
  13. isSuccess:true,
  14. },
  15. mounted:function(){
  16. var vm = this
  17. checkUserAgent();
  18. vm.patient=JSON.parse(localStorage.getItem("wlyyAgent")).uid
  19. vm.checkType()
  20. // vm.patient="31ced409777a4d89968ff7a9444d41ef"
  21. // vm.getData()
  22. },
  23. methods: {
  24. getData:function(){
  25. var vm=this
  26. if(Request.id){ //有id直接获取电子健康卡
  27. vm.getCardDataById()
  28. }else if(Request.Code){ //上饶页面返回后进入//0:授权失败 1:新用户注册成功 2:新用户注册失败 3:老用户升级成功 4:老用户升级失败
  29. if(Request.Code==1||Request.Code==3){
  30. vm.registerEleDecoder()
  31. }else{
  32. var msg=""
  33. if(Request.Code==2){
  34. msg="新用户注册失败"
  35. }else if(Request.Code==4){
  36. msg="老用户升级失败"
  37. }else{
  38. msg="授权失败"
  39. }
  40. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:msg}).show();
  41. vm.loaddingTxt=msg
  42. vm.isSuccess=false
  43. }
  44. }else { //判断本人是否有卡 有:获取,无:跳转上饶页面注册
  45. vm.validateEle()
  46. }
  47. },
  48. getCardDataById:function(){ //有id直接获取电子健康卡
  49. var vm=this
  50. vm.loaddingTxt="加载中..."
  51. sendPost("patient/card/getCardInfo", {id:Request.id}, "json", "get",function(){
  52. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
  53. }, function(res){
  54. if(res.status == 200){
  55. if(res.data.patient==vm.patient){ //判断是否当前用户
  56. vm.data=res.data
  57. vm.setCardInfo()
  58. vm.isloading=false
  59. }else{
  60. vm.validateEle()
  61. }
  62. }else{
  63. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'数据获取失败'}).show();
  64. }
  65. })
  66. },
  67. validateEle:function(){ //判断本人是否有卡 有:获取,无:跳转上饶页面注册
  68. var vm=this
  69. var backUrl=window.location.href
  70. if(backUrl.indexOf("?")>-1){backUrl=backUrl.split("?")[0]}
  71. sendPost("/third/hr/validateEle", {patient:vm.patient,backUrl:backUrl}, "json", "get",function(){
  72. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
  73. }, function(res){
  74. if(res.status == 200){
  75. if(res.data.code == 200){
  76. vm.data=res.data.data
  77. vm.setCardInfo()
  78. vm.isloading=false
  79. }else{
  80. window.location.href=res.data.url
  81. }
  82. }else{
  83. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  84. }
  85. })
  86. },
  87. registerEleDecoder:function(){ //上饶页面返回后进入
  88. var vm=this
  89. sendPost("/third/hr/registerEle/callback/decoder", {patient:vm.patient,jsonStr:Request.Data}, "json", "post",function(){
  90. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
  91. }, function(res){
  92. if(res.status == 200){
  93. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  94. vm.data=res.data
  95. vm.setCardInfo()
  96. vm.isloading=false
  97. vm.setMorenDialog(vm.data.id)
  98. }else{
  99. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  100. }
  101. })
  102. },
  103. //设置默认弹框
  104. setMorenDialog:function(id){
  105. var vm = this
  106. dialog({title:'绑定成功', content:'您已添加电子健康卡,是否设为默认充值查询用卡?', cancelValue: '是',okValue: '否',cancel: function () {vm.setMoren(id);},ok: function (){}, }).showModal();
  107. },
  108. //设置默认
  109. setMoren:function(id){
  110. sendPost("/patient/card/defaultOpe", {id:id,isDefault:1}, "json", "post",function(){
  111. }, function(res){
  112. if(res.status == 200){
  113. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  114. }else{
  115. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'数据获取失败'}).show();
  116. }
  117. })
  118. },
  119. setCardInfo:function(){
  120. var vm = this
  121. var data=vm.data
  122. vm.cardNo=data.cardNo.substr(0,1)+"*******"+data.cardNo.substr(data.cardNo.length-4,4)
  123. if(data.idCard){
  124. var sexType=data.idCard.length==18?data.idCard.substr(data.idCard.length-2,1):data.idCard.substr(data.idCard.length-1,1)
  125. if(parseInt(sexType)%2==1){
  126. vm.data.sex="男"
  127. }else{
  128. vm.data.sex="女"
  129. }
  130. }
  131. },
  132. restart:function(){ //注册失败后重试
  133. var vm=this
  134. vm.validateEle()
  135. },
  136. gotoRepay:function(id){
  137. window.location.href='../../payment/html/repayment.html?id='+id+'&origin='+Request.origin;
  138. },
  139. gotoPay:function(id){
  140. window.location.href='../../payment/html/patientIDCards-pay.html?id='+id;
  141. },
  142. synchronization:function(){ //维山专用,同步his电子健康卡
  143. d.show();
  144. sendPost("/third/hr/registerEle/archive/all", {}, "json", "get",function(){
  145. }, function(res){
  146. d.close();
  147. if(res.status == 200){
  148. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  149. }else{
  150. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'数据同步失败'}).show();
  151. }
  152. })
  153. },
  154. //判断是否验证登录通过
  155. checkType:function(){
  156. var vm=this
  157. var timer = setInterval(function(){
  158. if(checktype){
  159. clearInterval(timer);
  160. vm.getData()
  161. }
  162. },10);
  163. },
  164. },
  165. })
  166. })()
  167. function queryInit(){
  168. checktype=true
  169. }