Login.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div class="login">
  3. <div class="top">
  4. <div class="img"><img src="../images/check.png" alt=""></div>
  5. <h4>欢迎使用智能预问诊</h4>
  6. </div>
  7. <div class="main">
  8. <div class="iptWrap choose">
  9. <p @click="handleShow">{{name}} <img src="../images/down.png" /></p>
  10. <div class="slideType" v-if="show">
  11. <ul>
  12. <li @click="handleType('手机号',103)">手机号</li>
  13. <li @click="handleType('身份证号',101)">身份证号</li>
  14. <li @click="handleType('病历号',102)">病历号</li>
  15. <li @click="handleType('市民卡号',104)" style="border:0 none">市民卡号</li>
  16. </ul>
  17. </div>
  18. </div>
  19. <div class="iptWrap number">
  20. <input @blur="blur" :maxlength="type==103?11:type==101?18:type==102?7:type==104?9:30" v-model="value" @input="changeVal" :type="type==101||type==104?'text':'tel'" class="input" type="text" :placeholder="'请输入'+name" >
  21. </div>
  22. <div :class="['btn',value?'btnClick':'btnDis']" @click="handleDepart">进入预问诊</div>
  23. </div>
  24. <div class="tip">
  25. 注:建议您可先输入病情情况,方便医生提前了解情况
  26. </div>
  27. <Submit
  28. v-if="submit"
  29. :showType="showType"
  30. :fail="failMsg"
  31. @showSubmit="showSubmit"
  32. ></Submit>
  33. </div>
  34. </template>
  35. <script>
  36. import {phoneTest,identify,jgpattern} from '@utils/tools.js';
  37. import Submit from '../common/Submit';
  38. import api from '@utils/api.js';
  39. export default {
  40. name: "Login",
  41. data(){
  42. return {
  43. showType: 'fail',
  44. failMsg:'',
  45. submit:false,
  46. show:false,
  47. type:'103',
  48. name:'手机号',
  49. value:''
  50. }
  51. },
  52. methods:{
  53. handleType(name,type){
  54. let tmpType=this.type
  55. if(tmpType != type){
  56. this.name = name
  57. this.type = type
  58. this.value = ''
  59. }
  60. this.show = false
  61. },
  62. handleShow(){
  63. const {show} = this
  64. this.show = !show
  65. },
  66. blur(){
  67. document.activeElement.scrollIntoViewIfNeeded(true);
  68. setTimeout(()=>{
  69. document.activeElement.scrollIntoViewIfNeeded(true);
  70. },300)
  71. },
  72. changeVal(){
  73. document.activeElement.scrollIntoViewIfNeeded(true);
  74. const {type,value} = this
  75. if(type == 102||type == 103){
  76. this.value=value.replace(/[^\d]/g,'')
  77. }else if(type == 101 || type == 104){
  78. this.value=value.replace(/[\u4e00-\u9fa5]/g,'')
  79. }
  80. },
  81. defaultWaring(msg){
  82. this.$store.commit('handleToggleShow', false);
  83. this.showType = 'fail'
  84. this.failMsg = msg
  85. this.submit = true
  86. let timer = setTimeout(() => {
  87. this.submit = false
  88. clearTimeout(timer)
  89. }, 2000);
  90. },
  91. showSubmit(flg) {
  92. this.submit = flg
  93. },
  94. handleDepart(){
  95. const {type,value} = this
  96. if(value){
  97. if(type == 103){
  98. console.log(phoneTest.test(value))
  99. if(!phoneTest.test(value)){//验证不通过
  100. this.defaultWaring('请输入正确的11位手机号码')
  101. return
  102. }
  103. }else if(type == 101){//身份证
  104. if(!identify.test(value)){//验证不通过
  105. this.defaultWaring('请输入正确的身份证号')
  106. return
  107. }
  108. }else if(type == 104){//病历号只能输入数字字母
  109. if(!jgpattern.test(value)){//验证不通过
  110. this.defaultWaring('请输入正确的市民卡号')
  111. return
  112. }
  113. }
  114. const param = {
  115. "patientInfo": this.value,
  116. "patientInfoType": this.type
  117. }
  118. api.signIn(param).then((res) => {
  119. const result = res.data;
  120. if (result.code == 0) {
  121. if(result.data.length>1){
  122. this.$router.push({
  123. name:'Department',
  124. params:{"result":result.data}
  125. })
  126. }else if(result.data.length==1){
  127. let msg = result.data[0]
  128. let params = {
  129. hospitalCode:msg.hospitalCode,
  130. hospitalDeptCode:msg.hospitalDeptCode,
  131. doctorCode:msg.doctorCode,
  132. patientCode:msg.patientCode,
  133. recordId:msg.recordId
  134. }
  135. this.$router.push({
  136. path:'/',
  137. query:params
  138. })
  139. }else{
  140. }
  141. }else{
  142. this.defaultWaring(res)
  143. }
  144. }).catch(()=>{
  145. this.defaultWaring('网络异常请稍后重试')
  146. })
  147. }
  148. }
  149. },
  150. components:{
  151. Submit
  152. }
  153. }
  154. </script>
  155. <style lang="less" scoped>
  156. .login {
  157. height: 100%;
  158. width: 100%;
  159. position: fixed;
  160. background:linear-gradient(180deg,rgba(79,79,255,1) 0%,rgba(79,137,255,1) 100%);
  161. padding: .3rem .6rem;
  162. box-sizing: border-box;
  163. .top {
  164. .img {
  165. width: 1.6rem;
  166. height: 1.6rem;
  167. background-color: red;
  168. margin: 1rem auto 0 auto;
  169. img {
  170. width: 100%;
  171. }
  172. }
  173. h4 {
  174. font-size: .42rem;
  175. text-align: center;
  176. color: #fff;
  177. margin-top: 0.5rem;
  178. margin-bottom: .8rem;
  179. font-weight: normal;
  180. }
  181. }
  182. .main {
  183. width:100%;
  184. height:5.34rem;
  185. background:#fff;
  186. border-radius:.2rem;
  187. padding: .8rem .6rem;
  188. box-sizing: border-box;
  189. font-size: .3rem;
  190. .iptWrap {
  191. width:100%;
  192. height:.88rem;
  193. background:rgba(242,242,245,1);
  194. border-radius:.1rem;
  195. padding: .23rem .3rem;
  196. box-sizing: border-box;
  197. }
  198. .choose {
  199. position: relative;
  200. p {
  201. width: 100%;
  202. position: relative;
  203. img {
  204. position: absolute;
  205. right: 0;
  206. top: 0;
  207. width: .4rem;
  208. height: .4rem;
  209. }
  210. }
  211. .slideType {
  212. box-sizing: border-box;
  213. position: absolute;
  214. z-index: 10;
  215. width: 100%;
  216. top: 0.88rem;
  217. left: 0;
  218. box-shadow:0px 4px 20px 0px rgba(102,102,102,0.18);
  219. border-radius:.1rem;
  220. background-color: #fff;
  221. padding: .1rem .3rem 0 .3rem;
  222. box-sizing: border-box;
  223. font-size: .28rem;
  224. li {
  225. border-bottom: 1px solid #F5F5F5;
  226. height: .6rem;
  227. line-height: .6rem;
  228. box-sizing: border-box;
  229. }
  230. }
  231. }
  232. .number {
  233. margin: .3rem 0 .8rem 0;
  234. .input{
  235. float: left;
  236. color:rgba(51,51,51,1);
  237. height:.42rem;
  238. line-height:.42rem;
  239. width: 100%;
  240. background-color: transparent;
  241. }
  242. }
  243. .btn {
  244. width:100%;
  245. height:.88rem;
  246. line-height:.88rem;
  247. text-align: center;
  248. background:linear-gradient(270deg,rgba(79,139,255,1) 0%,rgba(79,79,255,1) 100%);
  249. border-radius:.44rem;
  250. color: #fff;
  251. font-size: .32rem;
  252. font-weight: 500;
  253. }
  254. .btnDis {
  255. opacity: 0.3;
  256. }
  257. .btnClick {
  258. opacity:1;
  259. }
  260. }
  261. .tip {
  262. color: #fff;
  263. font-size: .24rem;
  264. margin-top: .6rem;
  265. }
  266. }
  267. </style>