dailiqianyue_bac.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868
  1. var idCardReg = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
  2. var mobileReg = /^[1][3578][0-9]{9}$/;
  3. var doctorCode,name, idCard, ssc, mobile, emerMobile, key, encyIdCard;
  4. var //groupCode = [],
  5. //groupName = [],
  6. healthManagementCode=[],
  7. healthManagementName=[],
  8. diseaseCode=[],
  9. diseaseName=[];
  10. var /**currGroupCode,**/currHealthManagement,currHealthManagementName;
  11. var self;
  12. var encryURL = "login/public_key";
  13. var docInfo =null;
  14. var userAgent
  15. var docType
  16. mui.plusReady(function() {
  17. userAgent = JSON.parse(plus.storage.getItem("userAgent"));//登录的意思信息
  18. docType = JSON.parse(plus.storage.getItem("docType"));//登录的医生类别
  19. $("#doctor_zk").hide();
  20. docInfo= plus.storage.getItem("docInfo");
  21. docInfo = JSON.parse(docInfo);
  22. self = plus.webview.currentWebview();
  23. RSAUtils.getKeyFromServer(encryURL, function(res) {
  24. if(res.status == 200) {
  25. var mod = res.data.modulus;
  26. var exp = res.data.exponent;
  27. key = RSAUtils.getKeyPair(exp, "", mod);
  28. }
  29. });
  30. if(docType==2)//全科医生登录不显示 选择全科医生选项
  31. {
  32. $("#dortor_qke").hide()
  33. }else if(docType==3){//健康医生登录的时候 健康医生那个地方不能让选
  34. $("#healthManagement .no").show();
  35. }
  36. var hospital = plus.storage.getItem("hospital");
  37. //console.log(hospital);
  38. //健康管理师查询
  39. var healthManagementUrl//查询接口
  40. var params//参数
  41. if(docType==2){
  42. healthManagementUrl = "/doctor/doctor_combobox";
  43. params={type:3,hospital:hospital}
  44. }else{
  45. healthManagementUrl = "/doctor/findDoctorByLevelAndHospital";
  46. params={hospital:hospital,level:docType}
  47. }
  48. sendPost(healthManagementUrl, params, function(){
  49. mui.toast("健康管理师查询失败!");
  50. }, function(res) {
  51. if(res.status == 200) {
  52. if(docType==1){//专科
  53. }else if(docType==3){//健康管理师
  54. currHealthManagement=docInfo.code
  55. currHealthManagementName=docInfo.name
  56. $('#healthManagement input[data-val=healthManagement]').val(currHealthManagementName).attr("data-code",currHealthManagement);
  57. var healthManagementList = res.doctors;
  58. for(var i = 0; i < healthManagementList.length; i++) {
  59. healthManagementCode[i] = healthManagementList[i].code;
  60. healthManagementName[i] = healthManagementList[i].name;
  61. }
  62. }else{//全科
  63. //console.log(JSON.stringify(res))
  64. var healthManagementList = res.list;
  65. for(var i = 0; i < healthManagementList.length; i++) {
  66. healthManagementCode[i] = healthManagementList[i].code;
  67. healthManagementName[i] = healthManagementList[i].name;
  68. }
  69. }
  70. activHealthM();
  71. };
  72. });
  73. var imgArea = document.querySelector(".add-img");
  74. //添加附件
  75. document.querySelector(".add").addEventListener("tap", function() {
  76. showActionSheet(imgArea, this);
  77. });
  78. //提交
  79. document.getElementById("upload").addEventListener("tap", function() {
  80. plus.nativeUI.showWaiting();
  81. name = $("#name").find("input").val().trim();
  82. if(docType!=3 && $('#dortor_qke input[data-val=dortor_qke]').val().length == 0) {
  83. mui.toast("请选择全科医生");
  84. plus.nativeUI.closeWaiting();
  85. return;
  86. }
  87. if(name.length == 0) {
  88. mui.toast("请填写居民姓名");
  89. plus.nativeUI.closeWaiting();
  90. return;
  91. }
  92. //if($("#li_group input").attr("data-code")=="0") {
  93. //shenzaixin 20160829 取消验证
  94. //mui.toast("请选择居民分组");
  95. //plus.nativeUI.closeWaiting();
  96. //return
  97. //}
  98. // if($("#li_expenses").attr("data-code")=="0") {
  99. // mui.toast("请选择政府补贴费");
  100. // plus.nativeUI.closeWaiting();
  101. // return
  102. // }
  103. var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
  104. idCard = $("#idcard").find("input").val().trim();
  105. if(!idCardReg.test(idCard)) {
  106. $("#idcard input").css("color","red")
  107. mui.toast("请填写有效身份证号");
  108. plus.nativeUI.closeWaiting();
  109. return;
  110. }else{
  111. $("#idcard input").css("color","")
  112. }
  113. encyIdCard = RSAUtils.encryStr(key, idCard);
  114. mobile = $("#mobile").find("input").val().trim();
  115. if(!mobileReg.test(mobile)) {
  116. $("#mobile input").css("color","red")
  117. mui.toast("请填写有效的手机号码");
  118. plus.nativeUI.closeWaiting();
  119. return;
  120. }else{
  121. $("#mobile input").css("color","")
  122. }
  123. if(!currHealthManagement){
  124. mui.toast("请选择健康管理师!");
  125. plus.nativeUI.closeWaiting();
  126. return;
  127. }
  128. var patrn = /^[a-zA-Z0-9]+$/;
  129. ssc = $("#ssc").find("input").val().trim();
  130. if(ssc) {
  131. if(!patrn.test(ssc)) {
  132. mui.toast("请填写有效的医保卡卡号");
  133. plus.nativeUI.closeWaiting();
  134. return;
  135. }
  136. } else {
  137. ssc = "";
  138. mui.toast("医保卡号不能为空!");
  139. plus.nativeUI.closeWaiting();
  140. return;
  141. }
  142. emerMobile = $("#emerMoblie").find("input").val().trim();
  143. if(emerMobile) {
  144. if(emerMobile.length != 11) {
  145. mui.toast("请填写有效的应急人联系方式");
  146. plus.nativeUI.closeWaiting();
  147. return;
  148. }
  149. } else {
  150. emerMobile = "";
  151. }
  152. if(!$(".input-group-pack").hasClass("checked")) {
  153. mui.toast("您还未接受签约协议");
  154. plus.nativeUI.closeWaiting();
  155. return;
  156. }
  157. var uploadImgUrl = getCompressImg();
  158. if(uploadImgUrl) {
  159. setTimeout(function() {
  160. uploadImg(uploadImgUrl, handleUploadSucc);
  161. }, 1000)
  162. } else {
  163. sendData("");
  164. }
  165. });
  166. //设置政府补贴
  167. setExpenses();
  168. qke(userAgent,docType)
  169. //选择分组
  170. $("body").on("click","#li_group",function(){
  171. mui.openWindow({
  172. url:"../../qygl/html/xiaoxichuli_fzgl.html",
  173. id:"xiaoxichuli_fzgl.html"
  174. })
  175. })
  176. //图片识别点击事件
  177. // mui("body").on("tap",".tit1 a",function(){
  178. // page.imgUp();
  179. // })
  180. });
  181. // //图片识别
  182. // var page=null;
  183. // page={
  184. // imgUp:function(){
  185. // var m=this;
  186. // plus.nativeUI.actionSheet({cancel:"取消",buttons:[
  187. // {title:"拍照"},
  188. // {title:"从相册中选择"}
  189. // ]}, function(e){//1 是拍照 2 从相册中选择
  190. // switch(e.index){
  191. // case 1:clickCamera();break;
  192. // case 2:clickGallery();break;
  193. // }
  194. // });
  195. // }
  196. // //摄像头
  197. // }
  198. // //图片上传
  199. // function clickGallery() {
  200. // var server = "http://192.168.131.144:3000/";//在鑫
  201. // plus.gallery.pick(function(path) {
  202. // plus.zip.compressImage({
  203. // src: path,
  204. // dst: "_doc/chat/gallery/" + path,
  205. // quality: 20,
  206. // overwrite: true
  207. // }, function(e) {
  208. // var task = plus.uploader.createUpload(server + "/ocr", {
  209. // method: "post"
  210. // }, function(t, sta) {
  211. // //console.log(JSON.stringify(t))
  212. // if(sta == 200) {
  213. // var msg = t.responseText;
  214. // var oImg = JSON.parse(msg);
  215. // var imgUrl = oImg.urls;
  216. // var re = new RegExp("\\\\", "g");
  217. // imgUrl = imgUrl.replace(re, "/");
  218. // uploadMsg(2, imgUrl);
  219. // }
  220. // });
  221. // task.addFile(e.target, {});
  222. // task.start();
  223. // }, function(err) {
  224. // console.error("压缩失败:" + err.message);
  225. // });
  226. //
  227. // }, function(err) {});
  228. // };
  229. //
  230. //
  231. // // 拍照
  232. //
  233. // function clickCamera() {
  234. // var server = "http://192.168.131.144:3000/";//在鑫
  235. // var cmr = plus.camera.getCamera();
  236. // var res = cmr.supportedImageResolutions[0];
  237. // var fmt = cmr.supportedImageFormats[0];
  238. // cmr.captureImage(function(path) {
  239. //
  240. // //plus.io.resolveLocalFileSystemURL(path, function(entry) {
  241. // plus.io.resolveLocalFileSystemURL(path, function(entry) {
  242. //
  243. // var localUrl = entry.toLocalURL();
  244. // plus.zip.compressImage({
  245. // src: localUrl,
  246. // dst: "_doc/chat/camera/" + localUrl,
  247. // quality: 20,
  248. // overwrite: true
  249. // }, function(e) {
  250. //
  251. // var task = plus.uploader.createUpload(server + "/ocr", {
  252. // method: "post"
  253. // }, function(t, sta) {
  254. //
  255. // if(sta == 200) {
  256. // var msg = t.responseText;
  257. // var oImg = JSON.parse(msg);
  258. // var imgUrl = oImg.urls;
  259. // var re = new RegExp("\\\\", "g");
  260. // imgUrl = imgUrl.replace(re, "/");
  261. // console.log(imgUrl);
  262. // uploadMsg(2, imgUrl);
  263. // }
  264. // });
  265. // task.addFile(e.target, {});
  266. // task.start();
  267. // }, function(err) {
  268. // console.log("压缩失败: " + err.message);
  269. // });
  270. // });
  271. // }, function(err) {
  272. // console.error("拍照失败:" + err.message);
  273. // }, {
  274. // index: 1
  275. // });
  276. // };
  277. //
  278. //
  279. //
  280. //获取全科医生
  281. function qke(userAgent,docType){
  282. var qkeCode=[];
  283. var qkeName=[];
  284. var hospital =userAgent.hospital
  285. var level =docType
  286. sendPost("/doctor/findDoctorByLevelAndHospital", {hospital:hospital,level:2}, function(res){
  287. }, function(res) {
  288. if(res.status == 200) {
  289. //
  290. // qkeCode.push("0");
  291. // qkeName.push("无");
  292. var expensesList = res.doctors;
  293. for(var i = 0; i < expensesList.length; i++) {
  294. qkeCode.push(expensesList[i].code);
  295. qkeName.push(expensesList[i].name);
  296. }
  297. qkeSelect(qkeCode,qkeName);
  298. };
  299. });
  300. }
  301. //设置全科医生下拉框
  302. function qkeSelect(qkeCode,qkeName) {
  303. $('#dortor_qke input[data-val=dortor_qke]').mobiscroll({
  304. theme: 'ios',
  305. lang: 'zh',
  306. customWheels: true,
  307. wheels: [
  308. [{
  309. keys: qkeCode,
  310. values: qkeName
  311. }]
  312. ],
  313. onSelect: function(valueText, inst) {
  314. var dd = eval("[" + valueText + "]");
  315. var name=dd[0].values
  316. $(this).val(name);
  317. currExpenses = dd[0].keys;
  318. $('#dortor_qke input[data-val=dortor_qke]').attr("data-code",currExpenses);
  319. }
  320. });
  321. };
  322. //获取政府补贴数据
  323. function setExpenses(){
  324. var expensesCode=[];
  325. var expensesName=[];
  326. sendGet("/common/getDictByDictName?name=SIGN_EXPENSES", null, null, function(res) {
  327. if(res.status == 200) {
  328. // expensesCode.push("0");
  329. // expensesName.push("无");
  330. var expensesList = res.list;
  331. for(var i = 0; i < expensesList.length; i++) {
  332. expensesCode.push(expensesList[i].code);
  333. expensesName.push(expensesList[i].value);
  334. }
  335. activExpensesM(expensesCode,expensesName);
  336. };
  337. });
  338. }
  339. //设置政府补贴下拉框
  340. function activExpensesM(expensesCode,expensesName) {
  341. $('#li_expenses input[data-val=expenses]').mobiscroll({
  342. theme: 'ios',
  343. lang: 'zh',
  344. customWheels: true,
  345. wheels: [
  346. [{
  347. keys: expensesCode,
  348. values: expensesName
  349. }]
  350. ],
  351. onSelect: function(valueText, inst) {
  352. var dd = eval("[" + valueText + "]");
  353. var name=dd[0].values
  354. $(this).val(name);
  355. currExpenses = dd[0].keys;
  356. $('#li_expenses input[data-val=expenses]').attr("data-code",currExpenses);
  357. }
  358. });
  359. };
  360. //分组选择
  361. // function activMob() {
  362. // $('#group input[data-val=group]').mobiscroll({
  363. // theme: 'ios',
  364. // lang: 'zh',
  365. // customWheels: true,
  366. // wheels: [
  367. // [{
  368. // keys: groupCode,
  369. // values: groupName
  370. // }]
  371. // ],
  372. // onSelect: function(valueText, inst) {
  373. // var dd = eval("[" + valueText + "]");
  374. // $(this).val(dd[0].values);
  375. // currGroupCode = dd[0].keys;
  376. // }
  377. // });
  378. // };
  379. //健康管理师选择
  380. function activHealthM() {
  381. $('#healthManagement input[data-val=healthManagement]').mobiscroll({
  382. theme: 'ios',
  383. lang: 'zh',
  384. customWheels: true,
  385. wheels: [
  386. [{
  387. keys: healthManagementCode,
  388. values: healthManagementName
  389. }]
  390. ],
  391. onSelect: function(valueText, inst) {
  392. var dd = eval("[" + valueText + "]");
  393. $(this).val(dd[0].values);
  394. currHealthManagement = dd[0].keys;
  395. currHealthManagementName = dd[0].values;
  396. }
  397. });
  398. };
  399. /*
  400. * 上传成功后 处理方法
  401. */
  402. function handleUploadSucc(uploadObj) {
  403. var resText = uploadObj.responseText;
  404. var oRes = JSON.parse(resText);
  405. var imgNames = oRes.images;
  406. var imgUrls = oRes.urls;
  407. sendData(imgUrls);
  408. }
  409. /*
  410. * 提交
  411. */
  412. var submitUrl = "doctor/family_contract/agent";
  413. function sendData(imgUrls) {
  414. var majorDoctorName = $("#doctor_zk input").val();
  415. var majorDoctor = $("#doctor_zk input").attr("data-code");
  416. var disease = $("#disease input").attr("data-code");
  417. var diseaseVal = $("#disease input").val();
  418. var ismb=$(".tag_cyc").hasClass("on");//是否慢病
  419. if(ismb && diseaseVal.length=="0") {
  420. mui.toast("疾病类型不能为空!");
  421. plus.nativeUI.closeWaiting();
  422. return false;
  423. }
  424. if(docType!=2 && $('#dortor_qke input[data-val=dortor_qke]').attr("data-code")=="0"){
  425. mui.toast("全科医生为必填!");
  426. plus.nativeUI.closeWaiting();
  427. return false;
  428. }
  429. if(ismb &&(disease==0||disease==1)&&(majorDoctor==null||majorDoctor=="")){
  430. mui.toast("专科医生不能为空!");
  431. plus.nativeUI.closeWaiting();
  432. return false;
  433. }
  434. var params ={};
  435. // console.log(docType)
  436. if(docType==2){
  437. params={
  438. doctor:docInfo.code,//全科医生code
  439. doctorName:docInfo.name,//全科医生名字
  440. signDoctorCode:docInfo.code,//簽約人code
  441. signDoctorName:docInfo.name,//簽約人銘
  442. signDoctorLevel:docType,//簽約人等级
  443. name: name,
  444. idcard: encyIdCard,
  445. ssc: ssc,
  446. mobile: mobile,
  447. emerMobile: emerMobile,
  448. images: imgUrls,
  449. //group: currGroupCode,
  450. healthDoctor:currHealthManagement,
  451. healthDoctorName:currHealthManagementName,
  452. // majorDoctor:majorDoctor,
  453. // majorDoctorName:majorDoctorName,
  454. // disease:disease,
  455. expenses:$("#li_expenses input").attr("data-code"),
  456. group:$("#li_group input").attr("data-code")
  457. };
  458. }else{
  459. params={
  460. doctor:$('#dortor_qke input[data-val=dortor_qke]').attr("data-code"),//全科医生code
  461. doctorName:$('#dortor_qke input[data-val=dortor_qke]').val(),//全科医生名字
  462. signDoctorCode:docInfo.code,//簽約人code
  463. signDoctorName:docInfo.name,//簽約人銘
  464. signDoctorLevel:docType,//簽約人等级
  465. name: name,
  466. idcard: encyIdCard,
  467. ssc: ssc,
  468. mobile: mobile,
  469. emerMobile: emerMobile,
  470. images: imgUrls,
  471. //group: currGroupCode,
  472. healthDoctor:currHealthManagement,
  473. healthDoctorName:currHealthManagementName,
  474. // majorDoctor:majorDoctor,
  475. // majorDoctorName:majorDoctorName,
  476. // disease:disease,
  477. expenses:$("#li_expenses input").attr("data-code"),
  478. group:$("#li_group input").attr("data-code")
  479. };
  480. }
  481. if(!ismb){//如果没有选择慢病
  482. params.disease=0//慢病
  483. }else{//如果选中了病种
  484. params.majorDoctor=majorDoctor
  485. params.majorDoctorName=majorDoctorName
  486. params.disease=disease//慢病
  487. }
  488. sendPost(submitUrl, params, function(){
  489. plus.nativeUI.closeWaiting();
  490. mui.toast("系统异常!");
  491. }, function(res) {
  492. plus.nativeUI.closeWaiting();
  493. if(res.status == 200) {
  494. mui.confirm("代理签约成功, 是否继续代理签约?", "提示", ['是', '否'], function(e){
  495. if(e.index==0){
  496. plus.webview.currentWebview().reload();
  497. } else{
  498. mui.fire(self.opener(), 'updatePatiAmount');
  499. mui.later(function() {
  500. var hzWv = plus.webview.getWebviewById("huanzhe.html");
  501. if(hzWv) {
  502. mui.fire(hzWv, "update");
  503. }
  504. var syWv = plus.webview.getWebviewById("home2.html");
  505. if(syWv) {
  506. mui.fire(syWv, "refreshPatCount");
  507. }
  508. mui.back();
  509. }, 500);
  510. }
  511. })
  512. } else {
  513. mui.toast(res.msg);
  514. }
  515. });
  516. }
  517. /*
  518. * 删除图片
  519. */
  520. mui(".add-img").on("tap", ".icon-del", function() {
  521. var oli = this.parentElement;
  522. var oul = this.parentElement.parentElement;
  523. oul.removeChild(oli);
  524. });
  525. $(function() {
  526. //图片缩放( 动态添加了上传的图片后运行一下下面这条这个)
  527. scaleRefresh(".upload-img-list");
  528. $('body').on('click', '.input-group-pack', function() {
  529. // $(this).find(".input-group-pack").toggleClass("checked");
  530. $(this).toggleClass("checked");
  531. //$("#upload").parent().toggle();
  532. });
  533. });
  534. function toXieYiShu() {
  535. mui.openWindow('../../qygl/html/xieyishu.html', 'xieyishu', {})
  536. }
  537. //图片缩放,
  538. function scaleRefresh(dom) {
  539. ImagesZoom.init({
  540. "elem": dom,
  541. "delBack": function(index) {
  542. $(".pic-count").text($(".pic-count").text() - 1); //删除图片后的回调
  543. $(dom).find("li").eq(index).remove();
  544. }
  545. });
  546. }
  547. function getSSCNoByIdcard(idcard)
  548. {
  549. var checkUrl = "doctor/patient_cardno";
  550. sendPost(checkUrl,{idcard:idcard},null,function(res){
  551. //console.log(JSON.stringify(res));
  552. if(res.status=='200'){
  553. $("#ssc").find("input").val(res.data);
  554. if(res.data!="" && res.data!=null)
  555. {
  556. $("#ssc").find("input").attr("readonly","readonly");
  557. }
  558. else{
  559. $("#ssc").find("input").removeAttr("readonly");
  560. }
  561. } else {
  562. mui.toast(res.msg);
  563. }
  564. });
  565. }
  566. /* 签约三师 */
  567. function validIdCard(data) {
  568. // 该医生(登录者)所在社区(机构)编码
  569. var hospital = plus.storage.getItem("hospital"),
  570. // 该医生(登录者)基础信息
  571. docInfo = plus.storage.getItem("docInfo"),
  572. // 该医生(登录者)所在社区主编码(截取前8位,后两位是服务站)
  573. communityCode = hospital.slice(0,8),
  574. // 三师中全科医生所在社区主编码(截取前8位,后两位是服务站)
  575. qkCommunityCode = data.hospital.slice(0,8),
  576. // 该医生(登录者)编码
  577. doctor = docInfo.code,
  578. // 三师中全科医生编码
  579. qkDoctor = data.doctor,
  580. // 三师中全科医生是否在本社区
  581. isInCommunity = data.hospital,
  582. // 全科医生是否是该医生
  583. isSameDoctor = doctor == qkDoctor
  584. // ①三师中全科医生不在本社区,则弹窗提示“该居民已签约三师,无法继续签约”,点击“我知道了”,关闭弹窗,退出代理签约
  585. }
  586. $("#idcard input").on("blur", function() {
  587. $("#disease input").css("pointer-events", "");
  588. $("#healthManagement input").css("pointer-events","");
  589. $("#doctor_zk input").css("pointer-events", "");
  590. // $("#ssc input").removeAttr("readonly");
  591. var $this = $(this);
  592. var card = $this.val().trim();
  593. if(!idCardReg.test(card) || !card) {
  594. $("#idcard input").css("color","red")
  595. mui.toast("请输入正确的身份证号!");
  596. $("#ssc input").val("")
  597. //$this.val("");
  598. return;
  599. }else{
  600. $("#idcard input").css("color","")
  601. }
  602. var checkUrl = "doctor/family_contract/patient_sanshi_signinfo";
  603. sendPost(checkUrl,{idCard:card},null,function(res){
  604. //console.log(JSON.stringify(res));
  605. if(res.status=='200'){
  606. var resultData =res.data;
  607. //是三师签约,团队保持一致
  608. if(resultData.signStatus==1){
  609. //如果当前登录是健康管理师
  610. var qkcode="";
  611. if(docType==2){
  612. qkcode=docInfo.code;
  613. }else if(docType==3){
  614. qkcode=$('#dortor_qke input[data-val=dortor_qke]').attr("data-code");
  615. }
  616. //有三师签约,且全科医生不一致的情况下,不能进行签约
  617. if(qkcode=="0" || qkcode==""){
  618. mui.alert("请先选择全科医生,在填写身份证号");
  619. $("#idcard input").val("")
  620. $("#ssc input").val("")
  621. return false;
  622. }else if(qkcode!=resultData.doctor){
  623. //清空人员身份证
  624. $('#idcard input').val("").attr("data-code","");
  625. /*$("#info_list input").val("");
  626. $("#info_list input").attr("data-code","");*/
  627. mui.alert("存在三师签约,由于团队不一致无法进行签约!");
  628. return false;
  629. }else{
  630. $("#doctor_zk").show();
  631. $("#doctor_zk input").val(resultData.majorDoctorName);
  632. $("#doctor_zk input").attr("data-code",resultData.majorDoctor);
  633. $("#healthManagement input").val(resultData.healthDoctorName);
  634. currHealthManagement = resultData.healthDoctor;
  635. currHealthManagementName = resultData.healthDoctorName;
  636. $("#healthManagement input").attr("data-code",resultData.healthDoctor);
  637. $("#disease input").val(resultData.diseaseName);
  638. $("#disease input").attr("data-code",resultData.disease);
  639. $("#disease input").css("pointer-events","none");
  640. $("#healthManagement input").css("pointer-events","none");
  641. $("#doctor_zk input").css("pointer-events","none");
  642. }
  643. }else if(resultData.signStatus==2){
  644. alert(resultData.msg);
  645. $("#info_list input").val("");
  646. $("#info_list input").attr("data-code","");
  647. return false;
  648. } else {
  649. activHealthM();
  650. disease() ;
  651. }
  652. }
  653. getSSCNoByIdcard(card);
  654. });
  655. // plus.nativeUI.showWaiting();
  656. // idCard = $("#idcard").find("input").val().trim();
  657. // var checkUrl = "doctor/family_contract/check";
  658. // sendPost(checkUrl, {
  659. // idcard: RSAUtils.encryStr(key, idCard)
  660. // }, null, function(res) {
  661. // if(res.status == 200) {
  662. // var text;
  663. // if(res.data.sign == 1)
  664. // text = "该居民已签约 " + res.data.hospitalName.trim() + " 的 " + res.data.doctorName.trim() + " 医生。";
  665. // else if(res.data.sign == 2)
  666. // text = "不存在该居民!";
  667. //
  668. // if(text)
  669. // dialog({ content: text, ok: function() { $this.val(""); }}).showModal();
  670. // } else {
  671. // mui.toast("身份证验证异常!");
  672. // $this.val("");
  673. // }
  674. // plus.nativeUI.closeWaiting();
  675. // })
  676. });
  677. function validMobile(){
  678. var $this = $(this);
  679. var mobile = $this.val().trim();
  680. if($this.attr("id")=='emerMoblieIpt' && mobile=='')
  681. return;
  682. if(!mobileReg.test(mobile) || !mobile) {
  683. $("#mobile input").css("color","red")
  684. mui.toast("请输入正确的手机号!");
  685. //$this.val("");
  686. return;
  687. }else{
  688. $("#mobile input").css("color","")
  689. }
  690. if(!$this.hasClass("ajax"))
  691. return;
  692. plus.nativeUI.showWaiting();
  693. var checkUrl = "doctor/family_contract/checkMoblie";
  694. sendPost(checkUrl, {
  695. mobile: mobile
  696. }, null, function(res) {
  697. if(res.status == 200) {
  698. if(res.data.islive == "false") {
  699. dialog({
  700. content: "该手机号已签约!",
  701. ok: function() {
  702. $this.val("");
  703. }
  704. }).showModal();
  705. }
  706. } else {
  707. mui.toast("手机号验证异常!");
  708. $this.val("");
  709. }
  710. plus.nativeUI.closeWaiting();
  711. })
  712. }
  713. $("#emerMoblie input").on("blur", validMobile);
  714. $("#mobile input").on("blur", validMobile);
  715. $("#doctor_zk input").on("click",function(){
  716. mui.openWindow('hospital_list.html', 'hospital_list', {
  717. extras: {
  718. hosptialType: 1,
  719. callbackview:"dailiqianyue",
  720. callbackmethod:"getDoctor"
  721. }
  722. });
  723. })
  724. window.addEventListener('getDoctor', function(event) {
  725. //console.log(event.detail.name)
  726. $("#doctor_zk input").val(event.detail.name);
  727. $("#doctor_zk input").attr("data-code",event.detail.code);
  728. });
  729. var currdiseaseCode;// 病种类型CODE
  730. //病种
  731. var diseaseData= {"msg":"查询成功!","list":[{"code":"1","name":"高血压",},{"code":"2","name":"糖尿病",}],"status":200} ;
  732. // var diseaseData= {"msg":"查询成功!","list":[{"code":"0","name":"无"},{"code":"1","name":"高血压",},{"code":"2","name":"糖尿病",}],"status":200} ;
  733. var diseaseList = diseaseData.list;
  734. for(var i = 0; i < diseaseList.length; i++) {
  735. diseaseCode[i] = diseaseList[i].code;
  736. diseaseName[i] = diseaseList[i].name;
  737. }
  738. disease();//病种类型
  739. function disease() {
  740. $('#disease input[data-val=disease]').mobiscroll({
  741. theme: 'ios',
  742. lang: 'zh',
  743. customWheels: true,
  744. wheels: [
  745. [{
  746. keys: diseaseCode,
  747. values: diseaseName
  748. }]
  749. ],
  750. onSelect: function(valueText, inst) {
  751. var dd = eval("[" + valueText + "]");
  752. $(this).val(dd[0].values);
  753. currdiseaseCode = dd[0].keys;
  754. $('#disease input[data-val=disease]').attr("data-code",currdiseaseCode);
  755. // if(currdiseaseCode!=0){//如果选者的是 糖尿病 或者高血压 就显示专科医生
  756. // $("#doctor_zk").show();
  757. // }else{
  758. // $("#doctor_zk").hide();
  759. // $("#doctor_zk input").val("");
  760. // $("#doctor_zk input").attr("data-code","");
  761. // }
  762. }
  763. });
  764. };
  765. /*分组事件*/
  766. function group(e) {
  767. var groupcode=e.detail.code
  768. var groupName=e.detail.name
  769. //console.log(groupName)
  770. $('#li_group input[data-val=li_group]').val(groupName).attr("data-code",groupcode)
  771. }
  772. window.addEventListener("group", group);
  773. //切换是否慢病的 按钮
  774. tag_cyc()
  775. function tag_cyc(){
  776. $(".tag_cyc").on("click",function(){
  777. if($(this).hasClass("on")){
  778. $(this).removeClass("on");
  779. $("#doctor_zk").hide();
  780. $("#disease").hide();
  781. }else{
  782. $(this).addClass("on")
  783. $("#doctor_zk").css("display","-webkit-box")
  784. $("#disease").css("display","-webkit-box")
  785. }
  786. })
  787. }