管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2022-12-03 693c63dd4ea80db16f97c569df851a0f6fcf7906
src/components/login.vue
@@ -155,6 +155,7 @@
import { getPerms } from '../api/api';
import validCode from './verificationCode.vue';
import { mapActions } from 'vuex';
import moment from 'moment';
export default {
  components: { validCode },
@@ -208,16 +209,18 @@
    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('/');
                  }
@@ -241,6 +244,16 @@
        }
      });
    },
    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() {},
};