Login.vue 8.7 KB

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