| | |
| | | import { getPerms } from '../api/api'; |
| | | import validCode from './verificationCode.vue'; |
| | | import { mapActions } from 'vuex'; |
| | | import moment from 'moment'; |
| | | |
| | | export default { |
| | | components: { validCode }, |
| | |
| | | getCode(data) { |
| | | this.validCode = data; //在data中定义一个 validCode:'',用来记录验证码。 |
| | | }, |
| | | |
| | | submitForm(formName) { |
| | | this.$refs[formName].validate((valid) => { |
| | | if (valid) { |
| | | this.loading = true; |
| | | |
| | | this.login(this.loginForm) |
| | | .then((response) => { |
| | | this.setCookies(response); |
| | | getPerms().then((res) => { |
| | | if (res.code == 200) { |
| | | this.$store.commit('getPermsEntity', res.result); |
| | | |
| | | if (res.result.length != 0) { |
| | | this.$router.push('/'); |
| | | } |
| | |
| | | } |
| | | }); |
| | | }, |
| | | setCookies(res) { |
| | | var timeData = moment(res.result.expire).format('YYYY-MM-DD HH:mm:ss'); |
| | | var LfPrems = { |
| | | token: res.result.token, |
| | | uname: res.result.uname, |
| | | time: timeData, |
| | | }; |
| | | LfPrems = JSON.stringify(LfPrems); |
| | | localStorage.setItem('LFToken', LfPrems); |
| | | }, |
| | | }, |
| | | created() {}, |
| | | }; |