Prechádzať zdrojové kódy

账号首次登录需重置密码后使用

chenrui 4 rokov pred
rodič
commit
5f37563788
3 zmenil súbory, kde vykonal 42 pridanie a 4 odobranie
  1. 1 0
      src/store/getters.js
  2. 6 0
      src/store/modules/user.js
  3. 35 4
      src/views/Home.vue

+ 1 - 0
src/store/getters.js

@@ -5,6 +5,7 @@ const getters = {
   token: state => state.user.token,
   avatar: state => state.user.avatar,
   nickname: state => state.user.name,
+  mustChangePwd: state => state.user.mustChangePwd,
   welcome: state => state.user.welcome,
   roles: state => state.user.roles,
   userInfo: state => state.user.info,

+ 6 - 0
src/store/modules/user.js

@@ -7,6 +7,7 @@ const user = {
   state: {
     token: '',
     name: '',
+    mustChangePwd: null,
     welcome: '',
     avatar: '',
     roles: { permissionList: [] },
@@ -31,6 +32,9 @@ const user = {
     },
     SET_INFO: (state, info) => {
       state.info = info
+    },
+    SET_MUSTCHANGEPWD: (state, status) => {
+      state.mustChangePwd = status
     }
   },
 
@@ -48,6 +52,7 @@ const user = {
               Vue.ls.set('hasError', 0)
               commit('SET_TOKEN', res.access_token)
               commit('SET_NAME', { name: users.userNameCN, welcome: welcome() })
+              commit('SET_MUSTCHANGEPWD', users.mustChangePwd)
               Vue.ls.set('rolesAccess', { permissionList: users.permCodes }, 7 * 24 * 60 * 60 * 1000)
               commit('SET_AVATAR', res.avatar ? res.avatar : '')
               // 记住密码
@@ -88,6 +93,7 @@ const user = {
           resolve(error)
         }).finally(() => {
           commit('SET_NAME', { name: '', welcome: '' })
+          commit('SET_MUSTCHANGEPWD', '')
           commit('SET_AVATAR', '')
           commit('SET_TOKEN', '')
           commit('SET_ROLES', { permissionList: [] })

+ 35 - 4
src/views/Home.vue

@@ -1,21 +1,52 @@
 <template>
   <div class="home">
     <a-alert message="欢迎登录智享亿家运营系统" type="info" showIcon />
+    <!-- 重置密码 -->
+    <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>
  </div>
 </template>
 
 <script>
+  import { mapGetters } from 'vuex'
+  import ResetPwd from '@/views/user/ResetPwd.vue'
 export default {
   name: 'Home',
-  components: { 
-  },
+  components: { ResetPwd },
   data () {
-    return {}
+    return {
+      openResetPwd: false //  重置密码是否显示
+    }
+  },
+  computed: {
+    ...mapGetters(['mustChangePwd'])
   },
   created () {
   },
   methods: { 
-  }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {
+      //  判断登录用户是否重置过密码(首次登陆需强制重置密码)
+      if (vm.mustChangePwd == 0) {
+        vm.openResetPwd = false
+      } else {
+        vm.openResetPwd = true
+      }
+      console.log(vm.mustChangePwd, '-------是否需要重置密码')
+    })
+  },
 }
 </script>
 <style scoped>