index的副本.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <template>
  2. <div class="zh_login">
  3. <div class="zh_login_logo"><img src="../../../static/img/logo-2.png" /><div>服务热线:010-53932350</div></div>
  4. <div class="zh_login_box">
  5. <div class="zh_login_in">
  6. <div class="zh_login_from" v-if="this.confirm == 1">
  7. <div class="zh_login_h">确认登陆</div>
  8. <el-form ref="loginForm" :model="loginForm" auto-complete="on" label-position="left">
  9. <el-form-item class="zh_txt">
  10. <el-input
  11. v-model="loginForm.iphoneNumber"
  12. placeholder="请输入手机号"
  13. name="iphoneNumber"
  14. type="text"
  15. auto-complete="on"
  16. :disabled="true"
  17. />
  18. </el-form-item>
  19. <div class="zh_tips"><span></span></div>
  20. <el-form-item prop="verificationCode" class="zh_txt">
  21. <el-input
  22. :type="passwordType"
  23. v-model="loginForm.verificationCode"
  24. placeholder="请输入验证码"
  25. name="verificationCode"
  26. auto-complete="on"
  27. @keyup.enter.native="handleLogin"
  28. style="width: 60%;float: left"
  29. />
  30. <el-button type="primary" style="width: 40%;float: left" @click="getMessageAgain">{{innerText}}</el-button>
  31. </el-form-item>
  32. <div class="zh_tips"><span></span></div>
  33. <div class="zh_goPwd"></div>
  34. <el-button type="primary" class="zh_loginBtn" @click.native.prevent="getCheckCode('ruleForm')">确认</el-button>
  35. <div class="zh_tips"></div>
  36. </el-form>
  37. <el-dialog :title="$t('login.thirdparty')" :visible.sync="showDialog" append-to-body>
  38. {{ $t('login.thirdpartyTips') }}
  39. <social-sign />
  40. </el-dialog>
  41. </div>
  42. <div class="zh_login_from" v-if="this.confirm != 1">
  43. <div class="zh_login_h">登录远程诊断平台</div>
  44. <el-form ref="loginForm" :model="loginForm" :rules="loginRules" auto-complete="on" label-position="left">
  45. <el-form-item prop="username" class="zh_txt">
  46. <el-input
  47. v-model="loginForm.username"
  48. :placeholder="$t('请输入用户名')"
  49. name="username"
  50. type="text"
  51. auto-complete="on"
  52. />
  53. </el-form-item>
  54. <div class="zh_tips"><span></span></div>
  55. <el-form-item prop="password" class="zh_txt">
  56. <el-input
  57. :type="passwordType"
  58. v-model="loginForm.password"
  59. :placeholder="$t('请输入密码')"
  60. name="password"
  61. auto-complete="on"
  62. @keyup.enter.native="handleLogin" />
  63. </el-form-item>
  64. <div class="zh_tips"><span></span></div>
  65. <div class="zh_goPwd">忘记密码请联系管理员</div>
  66. <el-button type="primary" class="zh_loginBtn" @click.native.prevent="handleLogin">登录</el-button>
  67. <div class="zh_tips"></div>
  68. <div class="zh_reg">随时随地远程诊断,<a href="####">申请试用</a></div>
  69. </el-form>
  70. <el-dialog :title="$t('login.thirdparty')" :visible.sync="showDialog" append-to-body>
  71. {{ $t('login.thirdpartyTips') }}
  72. <social-sign />
  73. </el-dialog>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="zh_login_footer">
  78. <!-- <p>北京中世康恺科技有限公司</p> -->
  79. <p>京ICP备 17059019号 &copy;2018-2019</p>
  80. </div>
  81. </div>
  82. </template>
  83. <script>
  84. import { isvalidUsername } from '@/utils/validate'
  85. import { setMenuData } from '@/utils/index'
  86. import LangSelect from '@/components/LangSelect'
  87. import SocialSign from './socialsignin'
  88. import Axios from 'axios'
  89. import qs from 'qs'
  90. import {loginRequest,checkCode,messageAgain} from '@/api/request'
  91. export default {
  92. components: { LangSelect, SocialSign, Axios, qs },
  93. name: 'login',
  94. data() {
  95. // 设置默认显示中文
  96. this.$store.dispatch('setLanguage', 'zh')
  97. const validateUsername = (rule, value, callback) => {
  98. // if (!isvalidUsername(value)) {
  99. // callback(new Error('请输入您的用户名'))
  100. // } else {
  101. // callback()
  102. // }
  103. if (!isvalidUsername) {
  104. callback(new Error('请输入用户名'))
  105. } else {
  106. callback()
  107. }
  108. }
  109. const validatePassword = (rule, value, callback) => {
  110. if (value.length < 6) {
  111. callback(new Error('请输入您的密码'))
  112. } else {
  113. callback()
  114. }
  115. }
  116. const validateiphoneNumberd = (rule, value, callback) => {
  117. if (value.length < 6) {
  118. callback(new Error('请输入您的手机号'))
  119. } else {
  120. callback()
  121. }
  122. }
  123. const validateverificationCode = (rule, value, callback) => {
  124. if (value.length < 3) {
  125. callback(new Error('请输入您的验证码'))
  126. } else {
  127. callback()
  128. }
  129. }
  130. return {
  131. isShow: true,
  132. confirm: 0,
  133. innerText:'获取验证码',
  134. loginForm: {
  135. username: '',
  136. password: '',
  137. iphoneNumber:'',
  138. verificationCode:''
  139. },
  140. loginRules: {
  141. username: [{ required: true, trigger: 'blur', validator: validateUsername,type: 'string' }],
  142. password: [{ required: true, trigger: 'blur', validator: validatePassword,type: 'string' }],
  143. iphoneNumber: [{ required: true, trigger: 'blur', validator: validateiphoneNumberd,type: 'string' }],
  144. verificationCode: [{ required: true, trigger: 'blur', validator: validateverificationCode,type: 'string' }],
  145. },
  146. passwordType: 'password',
  147. loading: false,
  148. showDialog: false,
  149. rulse: {
  150. username: [
  151. { required: true, message: '请输入用户名', trigger: 'blur',type: 'string' }
  152. ],
  153. password: [
  154. { required: true, message: '请输入密码', trigger: 'blur',type: 'string' }
  155. ],
  156. iphoneNumber:[
  157. { required: true, message: '请输入手机号', trigger: 'blur',type: 'string' }
  158. ],
  159. verificationCode:[
  160. { required: true, message: '请输入验证码', trigger: 'blur',type: 'string' }
  161. ]
  162. },
  163. showLogin: false,
  164. phone:'',
  165. handleId:''
  166. }
  167. },
  168. methods: {
  169. showPwd() {
  170. if (this.passwordType === 'password') {
  171. this.passwordType = ''
  172. } else {
  173. this.passwordType = 'password'
  174. }
  175. var v = document.getElementById('ps')
  176. if (this.isShow) {
  177. v.type = 'text'
  178. this.isShow = false
  179. } else {
  180. v.type = 'password'
  181. this.isShow = true
  182. }
  183. },
  184. //重新发送验证码
  185. getMessageAgain(){
  186. messageAgain({
  187. handle_id: this.handleId
  188. }).then(data => {
  189. if (data.code == '0000'){
  190. this.handleId = data.handle_id
  191. let timer=null;
  192. clearInterval(timer);//这句话至关重要
  193. let time=60;
  194. let that=this;//习惯
  195. timer=setInterval(function(){
  196. if(time<=0){
  197. that.innerText="";
  198. that.innerText="点击重新发送";
  199. that.disabled=false;
  200. clearInterval(timer)
  201. console.log(timer)
  202. }else {
  203. that.disabled=true;
  204. that.innerText="";
  205. that.innerText="剩余时间"+(time)+"秒";
  206. time--;
  207. }
  208. },1000);
  209. }
  210. }).catch(err =>{
  211. this.$message.error(err.message);
  212. })
  213. },
  214. _needChangePassword(data) {
  215. if(data && data['pregPwd'] == 0) {
  216. this.$message({
  217. message: '密码复杂度过低,请修改密码!最低8位并且包含大小写字母、数字与特殊字符',
  218. type: 'error'
  219. })
  220. this.$router.push({ path: '/my/setpassword' })
  221. return true
  222. }
  223. return false
  224. },
  225. //验证码·
  226. getCheckCode(){
  227. var that = this
  228. this.$refs.loginForm.validate(valid => {
  229. var formObj = this
  230. if (valid) {
  231. console.log(this.handleId)
  232. checkCode(
  233. {
  234. handle_id: this.handleId,
  235. code: this.loginForm.verificationCode
  236. }
  237. ).then(data => {
  238. if (data.code === '0000') {
  239. var loginUser = data.info
  240. loginUser.avatar = ''
  241. loginUser.sessionid = data.sessionid
  242. loginUser.isAdmin = data.info.is_admin
  243. setMenuData('loginUser', JSON.stringify(loginUser))
  244. console.log(33333)
  245. // 登录成功·
  246. // 登录成功后,将远程、本地、患者菜单分开
  247. var localSysPlatMenuArr = []
  248. var remoteSysPlatMenuArr = []
  249. var patientSysPlatMenuArr = []
  250. if (loginUser.permission && loginUser.permission != null) {
  251. // 64022a6a4b32abae(本地) 814dc08e8183952d(远程)
  252. for (var i = 0; i < loginUser.permission.length; i++) {
  253. var upns = loginUser.permission[i]
  254. //本院报告
  255. if (upns.id === '80ddb7d09ebc44b4') {
  256. localSysPlatMenuArr.push(upns)
  257. }
  258. //远程诊断
  259. if (upns.id === '0aa9d7b2fdf7268e') {
  260. remoteSysPlatMenuArr.push(upns)
  261. }
  262. //患者登记
  263. if (upns.id === '0eac42ef01de23ff'){
  264. patientSysPlatMenuArr.push(upns)
  265. }
  266. }
  267. }
  268. // 将本地菜单或远程菜单或患者登记,放入缓存
  269. setMenuData('localSysPlatMenuArr', JSON.stringify(localSysPlatMenuArr))
  270. setMenuData('remoteSysPlatMenuArr', JSON.stringify(remoteSysPlatMenuArr))
  271. setMenuData('patientSysPlatMenuArr', JSON.stringify(patientSysPlatMenuArr))
  272. console.log('测试缓存',remoteSysPlatMenuArr)
  273. // 默认显示本地系统
  274. var locSign = null
  275. if ((typeof locSign === 'undefined') || locSign == null) {
  276. if (localSysPlatMenuArr.length > 0) {
  277. setMenuData('sys_plat_sign', 'local')
  278. console.log('router local --> ' + localSysPlatMenuArr[0].url)
  279. if(!that._needChangePassword(data))
  280. that.$router.push({ path: localSysPlatMenuArr[0].url })
  281. } else if (remoteSysPlatMenuArr.length > 0) {
  282. setMenuData('sys_plat_sign', 'remote')
  283. console.log('router remote --> ' + remoteSysPlatMenuArr[0].url)
  284. if(!that._needChangePassword(data))
  285. that.$router.push({ path: remoteSysPlatMenuArr[0].url })
  286. } else if (patientSysPlatMenuArr.length > 0) {
  287. setMenuData('sys_plat_sign', 'patient')
  288. console.log('router patient --> ' + patientSysPlatMenuArr[0].url)
  289. if(!that._needChangePassword(data))
  290. that.$router.push({ path: patientSysPlatMenuArr[0].url })
  291. } else {
  292. // 无菜单权限
  293. that.$message.error('该用户暂无可用权限')
  294. }
  295. }
  296. } else {
  297. // 登录失败
  298. // alert("登录失败");
  299. console.log('login fail!')
  300. formObj.loading = false
  301. formObj.$message({
  302. message: '验证码输入错误',
  303. type: 'error'
  304. })
  305. }
  306. return true
  307. }).catch(error => {
  308. this.$message.error(error.message);
  309. })
  310. }else{
  311. console.log('error submit!!')
  312. return false
  313. }
  314. })
  315. },
  316. getTime(){
  317. },
  318. handleLogin() {
  319. var that = this
  320. this.$refs.loginForm.validate(valid => {
  321. if (valid) {
  322. var formObj = this
  323. loginRequest(
  324. {
  325. userName: this.loginForm.username,
  326. pwd: this.loginForm.password
  327. }
  328. ).then(data => {
  329. if (data.code === '0000') {
  330. var loginUser = data.info
  331. if (data.phone !='') {
  332. this.confirm = 1
  333. this.loginForm.iphoneNumber = data.phone
  334. this.handleId = data.handle_id
  335. let timer=null;
  336. clearInterval(timer);//这句话至关重要
  337. let time=60;
  338. let that=this;//习惯
  339. timer=setInterval(function(){
  340. if(time<=0){
  341. that.innerText="";
  342. that.innerText="点击重新发送";
  343. that.disabled=false;
  344. clearInterval(timer)
  345. console.log(timer)
  346. }else {
  347. that.disabled=true;
  348. that.innerText="";
  349. that.innerText="剩余时间"+(time)+"秒";
  350. time--;
  351. }
  352. },1000);
  353. that.$message({
  354. message: '请输入用户登录验证码 ',
  355. type: 'warn'
  356. })
  357. return
  358. }
  359. if (data.sessionid) {
  360. loginUser.avatar = ''
  361. loginUser.sessionid = data.sessionid
  362. loginUser.isAdmin = data.info.is_admin
  363. setMenuData('loginUser', JSON.stringify(loginUser))
  364. console.log(33333)
  365. }
  366. // 登录成功
  367. // 登录成功后,将远程、本地、患者菜单分开
  368. var localSysPlatMenuArr = []
  369. var remoteSysPlatMenuArr = []
  370. var patientSysPlatMenuArr = []
  371. if (loginUser.permission && loginUser.permission != null) {
  372. // 64022a6a4b32abae(本地) 814dc08e8183952d(远程)
  373. for (var i = 0; i < loginUser.permission.length; i++) {
  374. var upns = loginUser.permission[i]
  375. //本院报告
  376. if (upns.id === '80ddb7d09ebc44b4') {
  377. localSysPlatMenuArr.push(upns)
  378. }
  379. //远程诊断
  380. if (upns.id === '0aa9d7b2fdf7268e') {
  381. remoteSysPlatMenuArr.push(upns)
  382. }
  383. //患者登记
  384. if (upns.id === '0eac42ef01de23ff'){
  385. patientSysPlatMenuArr.push(upns)
  386. }
  387. }
  388. }
  389. // 将本地菜单或远程菜单或患者登记,放入缓存
  390. setMenuData('localSysPlatMenuArr', JSON.stringify(localSysPlatMenuArr))
  391. setMenuData('remoteSysPlatMenuArr', JSON.stringify(remoteSysPlatMenuArr))
  392. setMenuData('patientSysPlatMenuArr', JSON.stringify(patientSysPlatMenuArr))
  393. console.log('测试缓存',remoteSysPlatMenuArr)
  394. // 默认显示本地系统
  395. var locSign = null
  396. if ((typeof locSign === 'undefined') || locSign == null) {
  397. if (localSysPlatMenuArr.length > 0) {
  398. setMenuData('sys_plat_sign', 'local')
  399. console.log('router local --> ' + localSysPlatMenuArr[0].url)
  400. if(!that._needChangePassword(data))
  401. that.$router.push({ path: localSysPlatMenuArr[0].url })
  402. } else if (remoteSysPlatMenuArr.length > 0) {
  403. setMenuData('sys_plat_sign', 'remote')
  404. console.log('router remote --> ' + remoteSysPlatMenuArr[0].url)
  405. if(!that._needChangePassword(data))
  406. that.$router.push({ path: remoteSysPlatMenuArr[0].url })
  407. } else if (patientSysPlatMenuArr.length > 0) {
  408. setMenuData('sys_plat_sign', 'patient')
  409. console.log('router patient --> ' + patientSysPlatMenuArr[0].url)
  410. if(!that._needChangePassword(data))
  411. that.$router.push({ path: patientSysPlatMenuArr[0].url })
  412. } else {
  413. // 无菜单权限
  414. that.$message.error('该用户暂无可用权限')
  415. }
  416. }
  417. } else {
  418. // 登录失败
  419. // alert("登录失败");
  420. console.log('login fail!')
  421. if (this.handleId != ''){
  422. formObj.loading = false
  423. }else{
  424. formObj.loading = true
  425. }
  426. formObj.$message({
  427. message: '登录失败,用户名或密码不正确 ',
  428. type: 'error'
  429. })
  430. }
  431. return true
  432. })
  433. .catch(function(error) {
  434. that.$message.error(error.message);
  435. })
  436. if (this.handleId != ''){
  437. this.loading = false
  438. return false
  439. }else{
  440. this.loading = true
  441. return true
  442. }
  443. } else {
  444. console.log('error submit!!')
  445. return false
  446. }
  447. })
  448. },
  449. afterQRScan() {
  450. // const hash = window.location.hash.slice(1)
  451. // const hashObj = getQueryObject(hash)
  452. // const originUrl = window.location.origin
  453. // history.replaceState({}, '', originUrl)
  454. // const codeMap = {
  455. // wechat: 'code',
  456. // tencent: 'code'
  457. // }
  458. // const codeName = hashObj[codeMap[this.auth_type]]
  459. // if (!codeName) {
  460. // alert('第三方登录失败')
  461. // } else {
  462. // this.$store.dispatch('LoginByThirdparty', codeName).then(() => {
  463. // this.$router.push({ path: '/' })
  464. // })
  465. // }
  466. }
  467. },
  468. }
  469. </script>
  470. <style rel="stylesheet/scss" lang="scss">
  471. /* 修复input 背景不协调 和光标变色 */
  472. /* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
  473. $bg:#283443;
  474. $light_gray:#eee;
  475. $cursor: #fff;
  476. @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  477. .login-container .el-input input{
  478. color: $cursor;
  479. &::first-line {
  480. color: $light_gray;
  481. }
  482. }
  483. }
  484. /* reset element-ui css */
  485. .login-container {
  486. .el-input {
  487. display: inline-block;
  488. height: 47px;
  489. width: 85%;
  490. input {
  491. background: transparent;
  492. border: 0px;
  493. -webkit-appearance: none;
  494. border-radius: 0px;
  495. padding: 12px 5px 12px 15px;
  496. color: $light_gray;
  497. height: 47px;
  498. caret-color: $cursor;
  499. &:-webkit-autofill {
  500. -webkit-box-shadow: 0 0 0px 1000px $bg inset !important;
  501. -webkit-text-fill-color: $cursor !important;
  502. }
  503. }
  504. }
  505. .el-form-item {
  506. border: 1px solid rgba(255, 255, 255, 0.1);
  507. background: rgba(0, 0, 0, 0.1);
  508. border-radius: 5px;
  509. color: #454545;
  510. }
  511. }
  512. </style>
  513. <style rel="stylesheet/scss" lang="scss" scoped>
  514. $bg:#2d3a4b;
  515. $dark_gray:#889aa4;
  516. $light_gray:#eee;
  517. .login-container {
  518. position: fixed;
  519. height: 100%;
  520. width: 100%;
  521. background-color: $bg;
  522. .login-form {
  523. position: absolute;
  524. left: 0;
  525. right: 0;
  526. width: 520px;
  527. max-width: 100%;
  528. padding: 35px 35px 15px 35px;
  529. margin: 120px auto;
  530. }
  531. .tips {
  532. font-size: 14px;
  533. color: #fff;
  534. margin-bottom: 10px;
  535. span {
  536. &:first-of-type {
  537. margin-right: 16px;
  538. }
  539. }
  540. }
  541. .svg-container {
  542. padding: 6px 5px 6px 15px;
  543. color: $dark_gray;
  544. vertical-align: middle;
  545. width: 30px;
  546. display: inline-block;
  547. }
  548. .title-container {
  549. position: relative;
  550. .title {
  551. font-size: 26px;
  552. color: $light_gray;
  553. margin: 0px auto 40px auto;
  554. text-align: center;
  555. font-weight: bold;
  556. }
  557. .set-language {
  558. color: #fff;
  559. position: absolute;
  560. top: 5px;
  561. right: 0px;
  562. }
  563. }
  564. .show-pwd {
  565. position: absolute;
  566. right: 10px;
  567. top: 7px;
  568. font-size: 16px;
  569. color: $dark_gray;
  570. cursor: pointer;
  571. user-select: none;
  572. }
  573. .thirdparty-button {
  574. position: absolute;
  575. right: 35px;
  576. bottom: 28px;
  577. }
  578. }
  579. .zh_login{ width:100%; height:710px; position:fixed; left:0; top:50%; margin-top:-365px; }
  580. .zh_login_logo{ max-width:960px; height:36px; padding:18px 20px 16px; margin:auto; }
  581. .zh_login_logo img{ height:36px; float:left; }
  582. .zh_login_logo div{ float:right; line-height:36px; font-size:1rem; color:#999; }
  583. .zh_login_box{ width:100%; height:370px; padding:100px 0; background:url(../../../static/img/banner.png) no-repeat center #D6E3E9; }
  584. .zh_login_in{ max-width:960px; padding:0 20px; margin:auto; }
  585. .zh_login_in .zh_login_from{ width:280px; float:right; padding:30px; background-color:#FFF; box-shadow:0 0 4px #BBB; border-radius:3px; }
  586. .zh_login_in .zh_login_from .zh_login_h{ margin-bottom:25px; font-size:1.2rem; color:#666; }
  587. .zh_login_in .zh_login_from .zh_txt{ height:36px; font-size:1rem; box-shadow:0 0 3px #EEE; border-radius:0px; margin-bottom:0; margin-top:5px; }
  588. .zh_login_in .zh_login_from .zh_txt input{ width:90%; height:34px; margin-top:1px; line-height:36px; padding:0 5%; box-shadow: none; border:none; font-size:1rem; -webkit-appearance:none; outline:none; }
  589. .zh_login_in .zh_login_from .zh_txt input::placeholder{ color:#BBB; }
  590. .zh_login_in .zh_login_from .zh_tips{ height:15px; line-height:20px; }
  591. .zh_login_in .zh_login_from .zh_tips span{ font-size:.8rem; color:#F00; }
  592. .zh_login_in .zh_login_from .zh_goPwd{ text-align:right; height:30px; text-align:right; font-size:.8rem; color:#AAA; }
  593. .zh_login_in .zh_login_from .zh_loginBtn{ width:100%; height:40px; background-color:#334154; border:none; color:#FFF; font-size:1rem; box-shadow:0 0 4px #334154; border-radius:3px; cursor:pointer; }
  594. .zh_login_in .zh_login_from .zh_reg{ height:40px; line-height:40px; text-align:center; font-size:.9rem; color:#999; background:linear-gradient(#FDFDFD, #F0F0F0) #CCC; border:1px solid #DDD; box-shadow:0 0 3px #EEE; border-radius:3px; }
  595. .zh_login_in .zh_login_from .zh_reg a{ color:#0BD0D8; text-decoration:none; }
  596. .zh_login_in .zh_login_from .zh_reg a:hover{ text-decoration:underline; }
  597. .zh_login_footer{ max-width:960px; margin:15px auto; }
  598. .zh_login_footer p{ font-size:.8rem; color:#999; text-align:center; line-height:180%; }
  599. </style>