Login.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <div class="login">
  3. <div class="top">
  4. <div class="img">
  5. <img src="../images/logo.png" alt />
  6. </div>
  7. <h4>欢迎使用智能预问诊</h4>
  8. </div>
  9. <div class="main">
  10. <div class="iptWrap choose" v-if="hospitalShow">
  11. <p @click="handleShow(1)">
  12. {{hospitalName}}
  13. <img src="../images/down.png" />
  14. </p>
  15. <div class="slideType" v-if="showH">
  16. <ul>
  17. <li v-for="(item,idx) in hospitalList" :key="idx" @click="handleCode(item,idx)" :style="{'border':(idx == (hospitalList.length-1))?'0 none':''}">{{item.hospitalName}}</li>
  18. </ul>
  19. </div>
  20. </div>
  21. <div class="iptWrap choose iptWrapS">
  22. <p @click="handleShow(2)">
  23. {{name}}
  24. <img src="../images/down.png" />
  25. </p>
  26. <div class="slideType" v-if="show">
  27. <ul>
  28. <!-- <li @click="handleType('手机号',103)">手机号</li> -->
  29. <li @click="handleType('身份证号',101)">身份证号</li>
  30. <li @click="handleType('病历号',102)">病历号</li>
  31. <li @click="handleType('市民卡号',104)" style="border:0 none">市民卡号</li>
  32. </ul>
  33. </div>
  34. </div>
  35. <div class="iptWrap number numberIpt">
  36. <input
  37. @focus="focus"
  38. @blur="blur"
  39. :maxlength="type==103?11:type==101?18:type==102?20:type==104?9:30"
  40. v-model="value"
  41. @input="changeVal"
  42. class="input"
  43. type="text"
  44. :placeholder="'请输入'+name"
  45. />
  46. </div>
  47. <div class="iptWrap number">
  48. <input
  49. @blur="blur"
  50. @focus="focus"
  51. :maxlength="30"
  52. v-model="patName"
  53. @input="changeName"
  54. class="input"
  55. type="text"
  56. placeholder="请输入姓名"
  57. />
  58. </div>
  59. <div :class="['btn',canClick?'btnClick':'btnDis']" @click.stop.prevent="handleDepart">进入预问诊</div>
  60. </div>
  61. <!-- <div class="tip">注:建议您可先输入病情情况,方便医生提前了解情况</div> -->
  62. <Submit v-if="submit" :showType="showType" :fail="failMsg" @showSubmit="showSubmit"></Submit>
  63. <Loading v-if="this.$store.state.loadingShow"></Loading>
  64. <Tiptoast
  65. :show="showTip"
  66. @close="close"
  67. :data="message"/>
  68. </div>
  69. </template>
  70. <script>
  71. import { phoneTest, identify, jgpattern,name } from "@utils/tools.js";
  72. import Submit from "../common/Submit";
  73. import Tiptoast from "../common/Tiptoast";
  74. import api from "@utils/api.js";
  75. import Loading from '../common/Loading';
  76. import $ from "jquery";
  77. // let iscanscrollpage = false
  78. export default {
  79. name: "Login",
  80. data() {
  81. return {
  82. loadingShow: this.$store.state.loadingShow,
  83. showTip: false,
  84. showType: "fail",
  85. failMsg: "",
  86. submit: false,
  87. show: false,
  88. showH:false,
  89. type: "102",
  90. name: "病历号",
  91. patName:'',
  92. value: "",
  93. message:{
  94. title: "",
  95. text: ""
  96. },
  97. code:'',
  98. allow:false,
  99. canClick:false,
  100. hospitalName:'',
  101. hospitalNum:'',
  102. hospitalList:[],
  103. hospitalShow:false,
  104. son:false,//有无子医院
  105. clique:1
  106. };
  107. },
  108. created(){
  109. let query = this.$route.query;
  110. let type = query.patientInfoType,name = query.patientName,value = query.patientInfo,code=query.hospitalCode,sonHospitalCode=query.sonHospitalCode,sonHospitalName=query.sonHospitalName,clique=(query.clique!=2?1:query.clique);
  111. this.code = code||'';
  112. if(value&&name&&type&&code){
  113. this.type = type
  114. this.name = type == 101?'身份证号':type == 102?'病历号':type == 104?'市民卡号':''
  115. this.value = value
  116. this.patName = name
  117. if(sonHospitalCode&&sonHospitalName){
  118. this.hospitalNum=sonHospitalCode
  119. this.hospitalName=sonHospitalName
  120. this.son = true
  121. }else{
  122. this.son = false
  123. }
  124. }
  125. this.clique = clique
  126. this.getSysConfig(code)
  127. },
  128. watch:{
  129. value:{
  130. handler: function(val, oldVal) {
  131. if(val&&this.patName){
  132. this.canClick = true
  133. }else{
  134. this.canClick = false
  135. }
  136. },
  137. deep: true
  138. },
  139. patName:{
  140. handler: function(val, oldVal) {
  141. if(val&&this.value){
  142. this.canClick = true
  143. }else{
  144. this.canClick = false
  145. }
  146. },
  147. deep: true
  148. }
  149. },
  150. beforeRouteLeave(to, from, next){
  151. const { value,patName,allow } = this;
  152. if(!value||!patName){
  153. return
  154. }
  155. next();
  156. },
  157. methods: {
  158. getHospitalList(code){
  159. api.getHospitalDatas({'hospitalCode':code}).then(res => {
  160. let result = res.data;
  161. if (result.code == 0) {
  162. let tmpMain = result.data.superiorsInfo;
  163. let tmpLis = result.data.juniorHospital;
  164. if(this.clique == 1){
  165. tmpLis.unshift(tmpMain)
  166. }
  167. this.hospitalList = tmpLis
  168. if(!this.son){
  169. this.hospitalName = tmpLis[0].hospitalName //默认第一个
  170. this.hospitalNum = tmpLis[0].hospitalCode
  171. }
  172. }else{
  173. // this.defaultWaring(res.data.msg);
  174. }
  175. })
  176. },
  177. getSysConfig(code){
  178. api.getSysConfig({'hospitalCode':code}).then((res)=>{
  179. const result = res.data;
  180. if(result.code==0){
  181. const datas = result.data;
  182. this.child = datas.filter((item)=>{return item.code == "constitution_show"})
  183. this.$store.commit('saveSysConfig',datas)
  184. for(let i = 0;i < datas.length;i++){
  185. if(datas[i].code == 'junior_show'){
  186. this.hospitalShow = +datas[i].value==1?true:false
  187. if(datas[i].value==1){
  188. this.hospitalShow = true
  189. this.getHospitalList(code)
  190. }else{
  191. this.hospitalShow = false
  192. }
  193. }
  194. }
  195. }else{
  196. this.defaultWaring(res.data.msg);
  197. }
  198. })
  199. },
  200. close() {
  201. this.showTip = false;
  202. },
  203. handleType(name, type) {
  204. let tmpType = this.type;
  205. if (tmpType != type) {
  206. this.name = name;
  207. this.type = type;
  208. this.value = "";
  209. }
  210. this.show = false;
  211. },
  212. handleCode(item,idx) {
  213. this.hospitalName = item.hospitalName
  214. this.hospitalNum = item.hospitalCode
  215. this.showH = false;
  216. },
  217. handleShow(flg) {
  218. const { show,showH } = this;
  219. if(flg == 1){
  220. if(!showH){
  221. this.show=false
  222. }
  223. this.showH = !showH;
  224. }else{
  225. if(!show){
  226. this.showH=false
  227. }
  228. this.show = !show;
  229. }
  230. },
  231. focus(){
  232. // iscanscrollpage = false;
  233. },
  234. blur() {
  235. // iscanscrollpage = true;
  236. // if(MobileDevice.getModels().join(' or ').indexOf('6') == -1){
  237. // document.activeElement.scrollIntoView({behavior: "smooth",block:'end'})
  238. // }
  239. },
  240. changeName(e) {
  241. this.patName = e.target.value.replace(/[`~!@#$%^&)(*_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im,'')
  242. },
  243. changeVal() {
  244. const { type, value } = this;
  245. if (type == 103) {
  246. this.value = value.replace(/[^\d]/g, "");
  247. } else if (type == 102 || type == 101 || type == 104) {
  248. this.value = value.replace(/[^\w\.\/]/ig, "");
  249. }
  250. },
  251. defaultWaring(msg) {
  252. this.showType = "fail";
  253. this.failMsg = msg;
  254. this.submit = true;
  255. let timer = setTimeout(() => {
  256. this.submit = false;
  257. clearTimeout(timer);
  258. }, 2000);
  259. },
  260. showSubmit(flg){
  261. this.submit = flg;
  262. },
  263. handleDepart(){
  264. const { type, value,patName,allow,hospitalNum,hospitalName,code,hospitalList } = this;
  265. if(allow){
  266. return
  267. }
  268. if (value&&patName) {
  269. this.allow = true
  270. let timer = setTimeout(() => {
  271. if (type == 102) {
  272. if (!jgpattern.test(value) || value.length > 20) {//验证不通过
  273. this.defaultWaring("请输入正确的病历号");
  274. this.allow = false;
  275. return;
  276. }
  277. } else if (type == 101) {//身份证
  278. if (!identify.test(value) || value.length > 18) {//验证不通过
  279. this.defaultWaring("请输入正确的身份证号");
  280. this.allow = false;
  281. return;
  282. }
  283. } else if (type == 104) {//市民卡号只能输入数字字母
  284. if (!jgpattern.test(value)||value.length!=9) {//验证不通过
  285. this.defaultWaring("请输入正确的9位市民卡号");
  286. this.allow = false;
  287. return;
  288. }
  289. }
  290. if(!this.code){
  291. this.defaultWaring("医院编码必填");
  292. this.allow = false;
  293. return;
  294. }
  295. this.$store.commit('handleToggleShow', true);
  296. const param = {
  297. patientInfo: value,
  298. patientInfoType: type,
  299. hospitalCode:code,
  300. hospitalName:hospitalList.length>0&&hospitalList[0].hospitalName||'',
  301. patientName:patName,
  302. sonHospitalCode: code==hospitalNum?'':hospitalNum||'',
  303. sonHospitalName: code==hospitalNum?'':hospitalName||''
  304. };
  305. api.signIn(param).then(res => {
  306. let result = res.data;
  307. if (result.code == 0) {
  308. // result.data.splice(0,1);//测试只有一条数据
  309. localStorage.setItem('loginData',JSON.stringify(result.data))//保存登陆信息,扫码进入徐删除该参数
  310. if (result.data.length > 1) {
  311. this.$router.push({
  312. name: "Department",
  313. params: { result: result.data }
  314. });
  315. this.allow = false
  316. } else if (result.data.length == 1) {
  317. let msg = result.data[0];
  318. let params = {
  319. hospitalCode: msg.hospitalCode,
  320. hospitalDeptCode: msg.hospitalDeptCode,
  321. doctorCode: msg.doctorCode||'',
  322. patientCode: msg.patientCode||'',
  323. recordId: msg.recordId||'',
  324. sonHospitalCode:msg.sonHospitalCode||'',
  325. time:msg.recordTime&&(new Date((msg.recordTime).replace(/\-/g, "/"))).getTime()||''
  326. };
  327. localStorage.setItem('loginParam',JSON.stringify(params))//保存登陆信息,扫码进入删除该参数
  328. this.$router.push({
  329. path: "/home",
  330. query: params
  331. });
  332. this.allow = false
  333. } else {
  334. this.message.title = '温馨提示'
  335. this.message.text = '暂无今日挂号信息,可更换登录方式再次尝试。'
  336. this.showTip = true
  337. }
  338. clearTimeout(timer)
  339. } else {
  340. // if(res.msg.indexOf('暂无今日挂号信息') != -1){
  341. // this.message.title = '温馨提示'
  342. // this.message.text = '暂无今日挂号信息,可更换登录方式再次尝试。'
  343. // this.showTip = true
  344. // }else{
  345. // this.defaultWaring(res.data.msg);
  346. // }
  347. this.allow = false
  348. this.defaultWaring(res.data.msg||"网络异常请稍后重试");
  349. clearTimeout(timer)
  350. }
  351. this.$store.commit('handleToggleShow', false);
  352. }).catch(() => {
  353. this.allow = false
  354. clearTimeout(timer)
  355. this.$store.commit('handleToggleShow', false);
  356. this.defaultWaring("网络异常请稍后重试");
  357. });
  358. }, 200);
  359. }
  360. }
  361. },
  362. components: {
  363. Submit,
  364. Tiptoast,
  365. Loading
  366. }
  367. };
  368. </script>
  369. <style lang="less" scoped>
  370. @import "../less/index.less";
  371. .login {
  372. height: 100%;
  373. width: 100%;
  374. position: absolute;
  375. background: #colors[btn];
  376. padding: 0rem 0.6rem;
  377. box-sizing: border-box;
  378. .top {
  379. .img {
  380. width: 1.6rem;
  381. height: 1.6rem;
  382. background-color: #fff;
  383. margin: .8rem auto 0 auto;
  384. border-radius: 50%;
  385. overflow: hidden;
  386. padding:6px;
  387. img {
  388. width: 100%;
  389. }
  390. }
  391. h4 {
  392. font-size: 0.42rem;
  393. text-align: center;
  394. color: #fff;
  395. margin-top: 0.4rem;
  396. margin-bottom: 0.5rem;
  397. font-weight: normal;
  398. }
  399. }
  400. .main {
  401. width: 100%;
  402. // height: 5.34rem;
  403. background: #fff;
  404. border-radius: 0.2rem;
  405. padding: 0.6rem 0.6rem;
  406. box-sizing: border-box;
  407. font-size: 0.3rem;
  408. .iptWrap {
  409. width: 100%;
  410. height: 0.88rem;
  411. background: rgba(242, 242, 245, 1);
  412. border-radius: 0.1rem;
  413. padding: 0.23rem 0.3rem;
  414. box-sizing: border-box;
  415. }
  416. .iptWrapS{
  417. margin-top: 0.3rem;
  418. }
  419. .choose {
  420. position: relative;
  421. p {
  422. width: 100%;
  423. position: relative;
  424. img {
  425. position: absolute;
  426. right: 0;
  427. top: 0;
  428. width: 0.4rem;
  429. height: 0.4rem;
  430. }
  431. }
  432. .slideType {
  433. box-sizing: border-box;
  434. position: absolute;
  435. z-index: 10;
  436. width: 100%;
  437. top: 0.88rem;
  438. left: 0;
  439. box-shadow: 0px 4px 20px 0px rgba(102, 102, 102, 0.18);
  440. border-radius: 0.1rem;
  441. background-color: #fff;
  442. padding: 0.1rem 0.3rem 0 0.3rem;
  443. box-sizing: border-box;
  444. font-size: 0.28rem;
  445. li {
  446. border-bottom: 1px solid #f5f5f5;
  447. height: .88rem;
  448. line-height: .88rem;
  449. box-sizing: border-box;
  450. }
  451. }
  452. }
  453. .number {
  454. margin: 0.3rem 0 0.6rem 0;
  455. .input {
  456. float: left;
  457. color: rgba(51, 51, 51, 1);
  458. height: 0.42rem;
  459. line-height: 0.42rem;
  460. width: 100%;
  461. font-size: .3rem;
  462. background-color: transparent;
  463. }
  464. }
  465. .numberIpt {
  466. margin: 0.3rem 0 0.3rem 0;
  467. }
  468. .btn {
  469. width: 100%;
  470. height: 0.88rem;
  471. line-height: 0.88rem;
  472. text-align: center;
  473. background: #colors[btn];
  474. border-radius: 0.2rem;
  475. color: #fff;
  476. font-size: 0.32rem;
  477. font-weight: 500;
  478. }
  479. .btnDis {
  480. opacity: 0.3;
  481. }
  482. .btnClick {
  483. opacity: 1;
  484. }
  485. }
  486. .tip {
  487. color: #fff;
  488. font-size: 0.24rem;
  489. margin-top: 0.5rem;
  490. }
  491. }
  492. </style>