登录后刷新官网

dev_2020-03-03
yujialong 3 years ago
parent edd6d4199a
commit 4dc723e653
  1. 19
      src/layouts/header/index.vue
  2. 1
      src/pages/account/login/index.vue

@ -18,16 +18,16 @@
<el-divider direction="vertical"></el-divider> <el-divider direction="vertical"></el-divider>
<a class="logout" @click="logout">退出</a> <a class="logout" @click="logout">退出</a>
</template> </template>
<router-link v-else class="login" to="/login" target="_blank"> <div v-else class="login" @click="toLogin">
<img src="@/assets/img/user.png" alt=""> <img src="@/assets/img/user.png" alt="">
<span>登录</span> <span>登录</span>
</router-link> </div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { mapState, mapActions } from "vuex"; import { mapState, mapMutations, mapActions } from "vuex";
import Setting from "@/setting"; import Setting from "@/setting";
import util from "@/libs/util"; import util from "@/libs/util";
import navbar from "../navbar"; import navbar from "../navbar";
@ -53,6 +53,9 @@ export default {
} }
}, },
methods: { methods: {
...mapMutations("user", [
'SET_CUSTOMERNAME'
]),
...mapActions("user", [ ...mapActions("user", [
"logout", "setTitle", "setLogoUrl", "setAvatar", "setUserName" "logout", "setTitle", "setLogoUrl", "setAvatar", "setUserName"
]), ]),
@ -66,9 +69,14 @@ export default {
}, },
getUserInfo() { getUserInfo() {
this.$get(this.api.queryUserInfoDetails).then(res => { this.$get(this.api.queryUserInfoDetails).then(res => {
let {userAvatars, userName} = res.result.hrUserInfo; const {userAvatars, userName} = res.result.hrUserInfo || {}
userAvatars && this.setAvatar(userAvatars); userAvatars && this.setAvatar(userAvatars);
this.setUserName(userName); this.setUserName(userName);
if (!userName && !this.customerName) {
this.$get(this.api.isClient).then(res => {
res.customerName && this.SET_CUSTOMERNAME(res.customerName)
}).catch(res => {})
}
}).catch(err => {}) }).catch(err => {})
}, },
toPersonal() { toPersonal() {
@ -83,6 +91,9 @@ export default {
this.$refs.nav.jump({ this.$refs.nav.jump({
index: this.isIndex ? '/index/list' : '/station/list' index: this.isIndex ? '/index/list' : '/station/list'
}) })
},
toLogin() {
window.open(this.$router.resolve('/login').href)
} }
} }
}; };

@ -155,6 +155,7 @@ export default {
setLogin() { setLogin() {
util.local.set(Setting.tokenKey, this.token, Setting.tokenExpires) util.local.set(Setting.tokenKey, this.token, Setting.tokenExpires)
util.successMsg('登录成功') util.successMsg('登录成功')
window.opener && window.opener.location.reload() //
const redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : "/station" const redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : "/station"
this.$router.replace(redirect) this.$router.replace(redirect)
}, },

Loading…
Cancel
Save