<template>
  <div class="home">
    <a-alert :message="message" type="info" />
    <!-- 重置密码 -->
    <a-modal
      class="resetPwdModal"
      title="重置密码"
      width="60%"
      centered
      :footer="null"
      :closable="false"
      :maskClosable="false"
      :destroyOnClose="true"
      @cancel="openResetPwd=false"
      v-model="openResetPwd">
      <ResetPwd />
    </a-modal>
    <!-- 新产品上线提醒 -->
    <a-modal
      class="newProductTips"
      title="新产品上线提醒"
      width="60%"
      centered
      :footer="null"
      :maskClosable="false"
      :destroyOnClose="true"
      @cancel="openNewProduct=false"
      v-model="openNewProduct">
      <newProduct></newProduct>
    </a-modal>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import ResetPwd from '@/views/user/ResetPwd.vue'
import newProduct from '@/views/productManagement/newProduct/modal.vue'

export default {
  name: 'Home',
  components: { ResetPwd, newProduct },
  data () {
    return {
      message: '欢迎登录' + process.env.VUE_APP_PRO_NAME,
      openResetPwd: false, //  重置密码是否显示
      openNewProduct: false
    }
  },
  computed: {
    ...mapGetters(['mustChangePwd'])
  },
  created () {
  },
  methods: {
    hasNewProduct () {
      this.openNewProduct = true
    }
  },
  beforeRouteEnter (to, from, next) {
    next(vm => {
      //  判断登录用户是否重置过密码（首次登陆需强制重置密码）
      if (vm.mustChangePwd == 0) {
        vm.openResetPwd = false
      } else {
        vm.openResetPwd = true
      }
      // 判断是否有新产品上线
      vm.hasNewProduct()
    })
  }
}
</script>
<style scoped>
  .home {
    /* width: 900px;
    margin: 0 auto;
    padding: 25px 0; */
  }
</style>
