<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div>首页</div>
</template>

<script>


import {mapGetters} from "vuex";
import {doEncrypt, doDecryptStr,doSign,doVerifySignature,userinfoEncrypt,userinfoDecrypt} from '@/utils/smutil'

export default {
  // computed: {
  //   ...mapGetters([
  //     'userinfo'
  //   ])
  // },
  name: "User",
  data() {
    return{
    }
  },
  created() {
    this.getCurrentUser()
  },
  methods: {
    /** 获取当前用户的最后修改密码时间 */
    getCurrentUser() {
      this.$axios.get('/sysUserController/getCurrentUser').then((res) => {
        // 用户信息+菜单权限加密存储
        let encryptUserInfo = userinfoEncrypt(JSON.stringify(res.data))
        // this.$store.dispatch('user/changeSetting',encryptUserInfo)
        sessionStorage.setItem('active',encryptUserInfo)
        var user = res.data.sysUser
        if (user.lastUpdatePwdTime==null){
            this.$message({
              type: 'warning',
              message: '需要修改初始密码!'
            });
          this.$router.push("/user/profile")
        }
        else{
          var dateBegin = new Date(user.lastUpdatePwdTime);
          var dateEnd = new Date();
          var dateDiff = dateEnd.getTime() - dateBegin.getTime(); //时间差的毫秒数
          var dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000)); //计算出相差天数
          if (dayDiff>=30){
            this.$message({
              type: 'warning',
              message: '密码超过30天需要修改!'
            })
            this.$router.push("/user/profile")
          }
        }
      }).catch((error) => {
        this.$message.error('获取数据出错' + error)
      })
    }
  }
}
</script>

<style scoped>
#tunnelinfo {
  padding-left: 20px;
}
</style>
