Login.vue 8.1 KB

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