123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <template>
- <div class="pagecontent overflow" v-loading="loading"
- style="background-image: linear-gradient(to bottom right, rgb(240, 248, 253), rgb(225, 241, 252));">
- <div class="content">
- <div class="p-3 text-center ">
- <div class="mt-4">
- <img :src="logo" alt="" width="50" height="50">
- </div>
- <div class="text-center font-bold text-dark mt-4">
- 医生登录
- </div>
- <div class="text-center font-bold text-dark mt-3 text-center">
- <el-form size="mini" ref="form" :model="formInline" class="px-3 " :rules="rules">
- <el-form-item prop="username">
- <el-input prefix-icon="el-icon-user" v-model="formInline.username" placeholder="请输入账号" />
- </el-form-item>
- <el-form-item prop="password">
- <el-input type="password" prefix-icon="el-icon-lock" v-model="formInline.password" placeholder="请输入密码" />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="handleLogin" class="text-center mx-auto w-100">登录</el-button>
- </el-form-item>
- </el-form>
- </div>
- <div class="fs-10 text-gry mt-5">
- <Footer />
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Footer from '../../components/footer/index.vue'
- import { isPassword } from '@/utils/validate.js'
- import logo from '@/assets/logo.png'
- import { mapActions } from 'vuex'
- import { ipcRenderer } from 'electron'
- export default {
- name: "Login",
- components: {
- Footer
- },
- data() {
- const validateUsername = (rule, value, callback) => {
- if ('' === value) callback(new Error('手机号不能为空'))
- else callback()
- }
- const validatePassword = (rule, value, callback) => {
- if (!isPassword(value)) callback(new Error('密码不能少于6位'))
- else callback()
- }
- let formInline = process.env.NODE_ENV == "development" ? {
- username: '18812312312', password: '123456' //'cxsrmyyyljkjtfhfy@202098'
- } : {
- username: localStorage.getItem('useraccount') || '',
- password: localStorage.getItem('password') || '',
- }
- return {
- formInline,
- logo,
- rules: {
- username: [
- {
- required: true,
- trigger: 'blur',
- validator: validateUsername,
- },
- ],
- password: [
- {
- required: true,
- trigger: 'blur',
- validator: validatePassword,
- },
- ],
- }, loading: false
- }
- },
- computed: {
- },
- created() {
- },
- methods: {
- onSubmit() {
- // this.$router.push('/userlist')
- // this.$api.login()
- },
- ...mapActions({
- logout: 'user/logout',
- login: 'user/login',
- getUserInfo: 'user/getUserInfo',
- getHospitalInfo: 'user/getHospitalInfo',
- findVisitSum: 'patient/findVisitSum'
- }),
- handleRoute() {
- return this.redirect === '/404' || this.redirect === '/403'
- ? '/'
- : '/home' //this.redirect
- },
- handleLogin() {
- let t = this
- t.loading = true
- t.$refs.form.validate(async (valid) => {
- if (valid)
- try {
- await t.login(t.formInline).then(() => {
- localStorage.setItem('username', t.formInline.username)
- localStorage.setItem('password', t.formInline.password)
- localStorage.setItem('useraccount', t.formInline.username)
- // ipcRenderer.send('setTray', { type: 'login' })
- try {
- Promise.all([
- t.getUserInfo(),
- t.$api.getHospitalInfo(),
- t.findVisitSum()
- ]).then((resall) => {
- let timer = setInterval(() => {
- t.findVisitSum().then((res)=>{
- if(res.code==401){
- clearInterval(timer)
- t.logout().then(() => {
- t.$router.push('/home/login')
- ipcRenderer.send('removeTray')
- }).catch((e) => {
- console.log(e)
- })
- }
- })
- }, process.env.NODE_ENV == "development"?1000 * 10:1000 * 60)
- t.$router.push('patientlist')
- ipcRenderer.send('setTray', { type: 'user', data: resall[0] });
- })
- } finally {
- t.loading = false
- }
- }).catch((e) => {
- console.log(127,e)
- })
- } finally {
- this.loading = false
- }
- })
- },
- },
- }
- </script>
- <style lang="less" scoped>
- .content {
- margin: 5px;
- height: calc(100vh -8px);
- border-radius: 5px;
- }
- </style>
|