info-confirm.js 9.0 KB

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