Login.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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">
  11. <p @click="handleShow">
  12. {{name}}
  13. <img src="../images/down.png" />
  14. </p>
  15. <div class="slideType" v-if="show">
  16. <ul>
  17. <!-- <li @click="handleType('手机号',103)">手机号</li> -->
  18. <li @click="handleType('身份证号',101)">身份证号</li>
  19. <li @click="handleType('病历号',102)">病历号</li>
  20. <li @click="handleType('市民卡号',104)" style="border:0 none">市民卡号</li>
  21. </ul>
  22. </div>
  23. </div>
  24. <div class="iptWrap number numberIpt">
  25. <input
  26. @focus="focus"
  27. @blur="blur"
  28. :maxlength="type==103?11:type==101?18:type==102?20:type==104?9:30"
  29. v-model="value"
  30. @input="changeVal"
  31. :type="type==101||type==104?'text':'tel'"
  32. class="input"
  33. type="text"
  34. :placeholder="'请输入'+name"
  35. />
  36. </div>
  37. <div class="iptWrap number">
  38. <input
  39. @blur="blur"
  40. @focus="focus"
  41. :maxlength="30"
  42. v-model="patName"
  43. @input="changeName"
  44. class="input"
  45. type="text"
  46. placeholder="请输入姓名"
  47. />
  48. </div>
  49. <div :class="['btn',value&&patName&&allow?'btnClick':'btnDis']" @click="handleDepart">进入预问诊</div>
  50. </div>
  51. <!-- <div class="tip">注:建议您可先输入病情情况,方便医生提前了解情况</div> -->
  52. <Submit v-if="submit" :showType="showType" :fail="failMsg" @showSubmit="showSubmit"></Submit>
  53. <Tiptoast
  54. :show="showTip"
  55. @close="close"
  56. :data="message"/>
  57. </div>
  58. </template>
  59. <script>
  60. import { phoneTest, identify, jgpattern,name } from "@utils/tools.js";
  61. import Submit from "../common/Submit";
  62. import Tiptoast from "../common/Tiptoast";
  63. import api from "@utils/api.js";
  64. import $ from "jquery";
  65. // let iscanscrollpage = false
  66. export default {
  67. name: "Login",
  68. data() {
  69. return {
  70. showTip: false,
  71. showType: "fail",
  72. failMsg: "",
  73. submit: false,
  74. show: false,
  75. type: "102",
  76. name: "病历号",
  77. patName:'',
  78. value: "",
  79. message:{
  80. title: "",
  81. text: ""
  82. },
  83. code:'',
  84. allow:true,
  85. he:'',
  86. };
  87. },
  88. created(){
  89. this.code = this.$route.query.hospitalCode||''
  90. },
  91. watch:{
  92. value(){
  93. },
  94. patName(){
  95. }
  96. },
  97. methods: {
  98. close() {
  99. this.showTip = false;
  100. },
  101. handleType(name, type) {
  102. let tmpType = this.type;
  103. if (tmpType != type) {
  104. this.name = name;
  105. this.type = type;
  106. this.value = "";
  107. }
  108. this.show = false;
  109. },
  110. handleShow() {
  111. const { show } = this;
  112. this.show = !show;
  113. },
  114. focus(){
  115. // iscanscrollpage = false;
  116. },
  117. blur() {
  118. // iscanscrollpage = true;
  119. // if(MobileDevice.getModels().join(' or ').indexOf('6') == -1){
  120. // document.activeElement.scrollIntoView({behavior: "smooth",block:'end'})
  121. // }
  122. },
  123. changeName() {
  124. // document.activeElement.scrollIntoViewIfNeeded(true);
  125. const { patName } = this;
  126. this.patName = patName.replace(/[`~!@#$%^&)(*_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/im,'')
  127. },
  128. changeVal() {
  129. // document.activeElement.scrollIntoViewIfNeeded(true);
  130. const { type, value } = this;
  131. if (type == 102 || type == 103) {
  132. this.value = value.replace(/[^\d]/g, "");
  133. } else if (type == 101 || type == 104) {
  134. this.value = value.replace(/[^\w\.\/]/ig, "");
  135. }
  136. },
  137. defaultWaring(msg) {
  138. this.$store.commit("handleToggleShow", false);
  139. this.showType = "fail";
  140. this.failMsg = msg;
  141. this.submit = true;
  142. let timer = setTimeout(() => {
  143. this.submit = false;
  144. clearTimeout(timer);
  145. }, 2000);
  146. },
  147. showSubmit(flg){
  148. this.submit = flg;
  149. },
  150. handleDepart(){
  151. const { type, value,patName,allow } = this;
  152. this.allow = false
  153. if (value&&patName&&allow) {
  154. let timer = setTimeout(() => {
  155. if (type == 102) {
  156. if (!jgpattern.test(value)) {//验证不通过
  157. this.defaultWaring("请输入正确的病历号");
  158. this.allow = true
  159. return;
  160. }
  161. } else if (type == 101) {//身份证
  162. if (!identify.test(value)) {//验证不通过
  163. this.defaultWaring("请输入正确的身份证号");
  164. this.allow = true
  165. return;
  166. }
  167. } else if (type == 104) {//市民卡号只能输入数字字母
  168. if (!jgpattern.test(value)||value.length!=9) {//验证不通过
  169. this.defaultWaring("请输入正确的9位市民卡号");
  170. this.allow = true
  171. return;
  172. }
  173. }
  174. if(!this.code){
  175. this.defaultWaring("医院编码必填");
  176. this.allow = true
  177. return;
  178. }
  179. const param = {
  180. patientInfo: this.value,
  181. patientInfoType: this.type,
  182. hospitalCode:this.code,
  183. patientName:patName
  184. };
  185. api
  186. .signIn(param)
  187. .then(res => {
  188. let result = res.data;
  189. if (result.code == 0) {
  190. // result.data.splice(0,1);//测试只有一条数据
  191. localStorage.setItem('loginData',JSON.stringify(result.data))//保存登陆信息,扫码进入徐删除该参数
  192. if (result.data.length > 1) {
  193. this.$router.push({
  194. name: "Department",
  195. params: { result: result.data }
  196. });
  197. } else if (result.data.length == 1) {
  198. let msg = result.data[0];
  199. let params = {
  200. hospitalCode: msg.hospitalCode,
  201. hospitalDeptCode: msg.hospitalDeptCode,
  202. doctorCode: msg.doctorCode,
  203. patientCode: msg.patientCode,
  204. recordId: msg.recordId,
  205. time:(new Date((msg.recordTime).replace(/\-/g, "/"))).getTime()
  206. };
  207. localStorage.setItem('loginParam',JSON.stringify(params))//保存登陆信息,扫码进入删除该参数
  208. this.$router.push({
  209. path: "/home",
  210. query: params
  211. });
  212. } else {
  213. this.message.title = '温馨提示'
  214. this.message.text = '暂无今日挂号信息,可更换登录方式再次尝试。'
  215. this.showTip = true
  216. }
  217. clearTimeout(timer)
  218. } else {
  219. if(res.msg.indexOf('暂无今日挂号信息') != -1){
  220. this.message.title = '温馨提示'
  221. this.message.text = '暂无今日挂号信息,可更换登录方式再次尝试。'
  222. this.showTip = true
  223. }else{
  224. this.defaultWaring(res.msg);
  225. }
  226. clearTimeout(timer)
  227. }
  228. })
  229. .catch(() => {
  230. this.allow = true
  231. clearTimeout(timer)
  232. this.defaultWaring("网络异常请稍后重试");
  233. });
  234. }, 200);
  235. }
  236. }
  237. },
  238. components: {
  239. Submit,
  240. Tiptoast
  241. }
  242. };
  243. </script>
  244. <style lang="less" scoped>
  245. @import "../less/index.less";
  246. .login {
  247. height: 100%;
  248. width: 100%;
  249. position: absolute;
  250. background: #colors[btn];
  251. padding: 0rem 0.6rem;
  252. box-sizing: border-box;
  253. .top {
  254. .img {
  255. width: 1.6rem;
  256. height: 1.6rem;
  257. background-color: #fff;
  258. margin: .8rem auto 0 auto;
  259. border-radius: 50%;
  260. overflow: hidden;
  261. padding:6px;
  262. img {
  263. width: 100%;
  264. }
  265. }
  266. h4 {
  267. font-size: 0.42rem;
  268. text-align: center;
  269. color: #fff;
  270. margin-top: 0.4rem;
  271. margin-bottom: 0.5rem;
  272. font-weight: normal;
  273. }
  274. }
  275. .main {
  276. width: 100%;
  277. // height: 5.34rem;
  278. background: #fff;
  279. border-radius: 0.2rem;
  280. padding: 0.6rem 0.6rem;
  281. box-sizing: border-box;
  282. font-size: 0.3rem;
  283. .iptWrap {
  284. width: 100%;
  285. height: 0.88rem;
  286. background: rgba(242, 242, 245, 1);
  287. border-radius: 0.1rem;
  288. padding: 0.23rem 0.3rem;
  289. box-sizing: border-box;
  290. }
  291. .choose {
  292. position: relative;
  293. p {
  294. width: 100%;
  295. position: relative;
  296. img {
  297. position: absolute;
  298. right: 0;
  299. top: 0;
  300. width: 0.4rem;
  301. height: 0.4rem;
  302. }
  303. }
  304. .slideType {
  305. box-sizing: border-box;
  306. position: absolute;
  307. z-index: 10;
  308. width: 100%;
  309. top: 0.88rem;
  310. left: 0;
  311. box-shadow: 0px 4px 20px 0px rgba(102, 102, 102, 0.18);
  312. border-radius: 0.1rem;
  313. background-color: #fff;
  314. padding: 0.1rem 0.3rem 0 0.3rem;
  315. box-sizing: border-box;
  316. font-size: 0.28rem;
  317. li {
  318. border-bottom: 1px solid #f5f5f5;
  319. height: .88rem;
  320. line-height: .88rem;
  321. box-sizing: border-box;
  322. }
  323. }
  324. }
  325. .number {
  326. margin: 0.3rem 0 0.6rem 0;
  327. .input {
  328. float: left;
  329. color: rgba(51, 51, 51, 1);
  330. height: 0.42rem;
  331. line-height: 0.42rem;
  332. width: 100%;
  333. font-size: .3rem;
  334. background-color: transparent;
  335. }
  336. }
  337. .numberIpt {
  338. margin: 0.3rem 0 0.3rem 0;
  339. }
  340. .btn {
  341. width: 100%;
  342. height: 0.88rem;
  343. line-height: 0.88rem;
  344. text-align: center;
  345. background: #colors[btn];
  346. border-radius: 0.2rem;
  347. color: #fff;
  348. font-size: 0.32rem;
  349. font-weight: 500;
  350. }
  351. .btnDis {
  352. opacity: 0.3;
  353. }
  354. .btnClick {
  355. opacity: 1;
  356. }
  357. }
  358. .tip {
  359. color: #fff;
  360. font-size: 0.24rem;
  361. margin-top: 0.5rem;
  362. }
  363. }
  364. </style>