Login.vue 10 KB

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