info-confirm.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. var pagetype = 21;
  2. var d = null;
  3. var imgKey = null;
  4. var openid = "";
  5. $(function(){
  6. var selectData='';//用户信息
  7. initValidate();
  8. d= dialog({contentType:'load', skin:'bk-popup'});
  9. checkUserAgent();
  10. var doctorInfo = window.localStorage.getItem("doctorInfo");
  11. if(doctorInfo&&doctorInfo!=""){
  12. doctorInfo = JSON.parse(doctorInfo);
  13. }else{
  14. //dialog({contentType:'tipsbox', skin:'bk-popup' , content:'医生数据异常重新选择!',bottom:true}).show();
  15. //return;
  16. }
  17. var arrangeDate = window.localStorage.getItem("arrangeDate");
  18. if(arrangeDate&&arrangeDate!=""){
  19. arrangeDate = JSON.parse(arrangeDate);
  20. }else{
  21. //dialog({contentType:'tipsbox', skin:'bk-popup' , content:'预约日期异常请返回重新选择!',bottom:true}).show();
  22. //return;
  23. }
  24. bindEvents();
  25. function initValidate(){
  26. // var serurl="patient/captcha";
  27. openid = JSON.parse(window.localStorage.getItem(agentName)).openid;
  28. var serurl = "/questionnaire/captcha/withOpenId/"+openid;
  29. var posttype="post";
  30. // if(imgKey!=null){
  31. // serurl=serurl+"/"+imgKey;
  32. // posttype="post";
  33. // }
  34. sendPost(serurl,{},"json",posttype,function(res){
  35. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"验证码获取失败!",bottom:true}).show();
  36. },function(res){
  37. if(res.status==200){
  38. imgKey = res.data.key;
  39. $("#validateDiv").attr("src","data:image/png;base64,"+res.data.image);
  40. }else{
  41. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"验证码获取失败!",bottom:true}).show();
  42. }
  43. })
  44. }
  45. $("#validateDiv").on("click",function(){
  46. initValidate();
  47. })
  48. function getUsersPromise() {
  49. return new Promise(function(resolve, reject) {
  50. sendPost('patient/family/authorize_members',{},"json",'GET',function(res){
  51. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"就诊居民列表获取失败!",bottom:true}).show();
  52. },function(res){
  53. if(res.status==200){
  54. resolve(res)
  55. }else{
  56. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"就诊居民列表获取失败!",bottom:true}).show();
  57. }
  58. })
  59. })
  60. }
  61. function bindEvents(){
  62. var scroller1 = new IScrollPullUpDown('wrapper',{
  63. probeType:2,
  64. bounceTime: 250,
  65. bounceEasing: 'quadratic',
  66. mouseWheel:false,
  67. scrollbars:true,
  68. fadeScrollbars:true,
  69. click:true,
  70. interactiveScrollbars:false
  71. },null,null);
  72. $("#mobile").on("focus",function(){
  73. $(".searchbar-clear").css("pointer-events","none").css("opacity",0);
  74. if($(this).val()){
  75. $(this).next().css("pointer-events","auto").css("opacity",1);
  76. $(this).next().show();
  77. }
  78. }).on("input",function(){
  79. $(this).next().css("pointer-events","auto").css("opacity",1);
  80. $(this).next().show();
  81. });
  82. $(".visit-ul").on("click",".searchbar-clear",function(){
  83. $(this).prev().val("");
  84. $(this).css("pointer-events","none").css("opacity",0);
  85. $(this).prev().focus();
  86. return false;
  87. });
  88. $(".div-immediately-btn").on("click",function(){
  89. var mobile = $("#mobile").val();
  90. if(!isphone(mobile)){
  91. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'手机号格式不正确'}).show();
  92. return;
  93. }
  94. $("#validateCode").blur();
  95. $("#mobile").blur();
  96. //校验验证码是否正确
  97. // sendPost("patient/captcha/"+imgKey,{"text":$("#validateCode").val()},"json","get",function(res){
  98. // dialog({contentType:'tipsbox', skin:'bk-popup' , content:"验证码校验失败!",bottom:true}).show();
  99. // },function(res){
  100. // if(res.status==200){
  101. // if(res.pass==true){
  102. // imgKey = null;
  103. // initValidate();
  104. applyData();
  105. // }else{
  106. // dialog({contentType:'tipsbox', skin:'bk-popup' , content:"验证码错误,请重新输入!",bottom:true}).show();
  107. // }
  108. // }else{
  109. // dialog({contentType:'tipsbox', skin:'bk-popup' , content:"验证码校验失败!",bottom:true}).show();
  110. // }
  111. // });
  112. })
  113. window.addEventListener("resize", function(){
  114. var u = navigator.userAgent;
  115. if(u.indexOf('Android') > -1 || u.indexOf('Linux') > -1){
  116. var self = document.getElementById("validateCode");
  117. setTimeout(function(){
  118. self.scrollIntoView({block: "end", behavior: "smooth"});
  119. }, 150);
  120. }
  121. })
  122. }
  123. initData();
  124. function initData(){
  125. $("#hospitalName").html(doctorInfo['hospitalName']);
  126. $("#hosDeptDocName").html(doctorInfo['hosDeptName']+" "+doctorInfo['name']);
  127. $("#yyTime").html(arrangeDate['startTime'].split(" ")[0]+" "+arrangeDate['yysj']);
  128. // query();
  129. getUsersPromise().then(function(res) {
  130. var list = res.data;
  131. selectData = list[0]
  132. $("#mobile").val(selectData.mobile);
  133. $("#username").html(selectData.name);
  134. $("#idcard").html(selectData.idcard);
  135. $("#ssc").html(selectData.ssc);
  136. $('#ms-username').mobiscroll({
  137. theme: 'ios',
  138. lang: 'zh',
  139. formatValue: function(d) {
  140. return d.join(',');
  141. },
  142. customWheels: true,
  143. wheels: [
  144. [{
  145. keys: _.range(0, list.length),
  146. values: _.pluck(list, 'name')
  147. }]
  148. ],
  149. onSelect: function(valueText, inst) {
  150. var dd = eval("[" + valueText + "]");
  151. var selectKey = dd[0].keys;
  152. var user = list[selectKey];
  153. selectData = list[selectKey];//储存信息
  154. $('#username').text(user.name);
  155. $('#idcard').text(user.idcard);
  156. $('#ssc').text(user.ssc);
  157. $("#mobile").val(user.mobile);
  158. }
  159. });
  160. })
  161. .catch(function(e) {
  162. console && console.error(e)
  163. })
  164. }
  165. function query() {
  166. d.show();
  167. var data={};
  168. sendPost('patient/baseinfo', data, 'json', 'post', queryFailed, querySuccess);
  169. }
  170. function querySuccess(res){
  171. d.close();
  172. if(res.status==200){
  173. var ssc = res.data.ssc;
  174. var j = ssc.substring(ssc.length,ssc.length-3);
  175. var sscStr = ssc.replace(j,'***');
  176. $("#username").html(res.data.name);
  177. $("#idcard").html(res.data.idcard);
  178. $("#ssc").html(sscStr);
  179. }else{
  180. queryFailed(res);
  181. }
  182. }
  183. function queryFailed(res){
  184. d.close();
  185. if (res && res.msg) {
  186. if((res.msg).indexOf("SOAP")>=0){
  187. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"医院接口访问异常,请刷新后重试!",bottom:true}).show();
  188. return false;
  189. }
  190. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
  191. } else {
  192. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败',bottom:true}).show();
  193. }
  194. }
  195. function applyData(){
  196. d.show();
  197. var params = {};
  198. params.city=CITY_CODE;
  199. params.hospitalId=doctorInfo.hospitalId;
  200. params.hospitalName = doctorInfo.hospitalName;
  201. params.hosDeptId = doctorInfo.hosDeptId;
  202. params.hosDeptName = doctorInfo.hosDeptName;
  203. params.doctorId = doctorInfo.id;
  204. params.doctorName = doctorInfo.name;
  205. delete arrangeDate.yysj;
  206. params.arrangeDate=JSON.stringify(arrangeDate);
  207. params.patient = selectData.code
  208. params.patientName = selectData.name;
  209. params.cardNo = selectData.idcardAll;
  210. params.clinicCard = selectData.ssc;
  211. params.patientPhone = $("#mobile").val();
  212. params.openId = openid;
  213. //添加验证码信息
  214. params.key = imgKey;
  215. params.text = $("#validateCode").val();
  216. sendPost("third/guahao/CreateOrder",params,"json","POST",queryFailed,submitSuccess);
  217. }
  218. function submitSuccess(res){
  219. d.close();
  220. if(res.status==200){
  221. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'预约成功!',bottom:true}).show();
  222. setTimeout(function(){
  223. location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+wxurl+"%2fwdyy%2fhtml%2fmy-appointment.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
  224. },200);
  225. }else{
  226. queryFailed(res);
  227. }
  228. }
  229. });