Commit 983cc2d9 by tang

feat: 个人中心入口

parent 34708a5f
<template> <template>
<div class="header-btn move-btn"> <div class="header-btn move-btn">
<el-button v-if="!user" type="primary" style="padding: 9px 30px;margin-right: 6px" size="small" @click="handleToLogin">注册/登录 <el-button v-if="!user" type="primary" style="padding: 9px 30px;margin-right: 6px" size="small"
@click="handleToLogin">注册/登录
</el-button> </el-button>
<el-button v-else type="primary" style="padding: 9px 30px;margin-right: 6px" size="small" @click="handleExit">退出登录 <el-button v-else type="primary" style="padding: 9px 30px;margin-right: 6px" size="small" @click="handleExit">退出登录
</el-button> </el-button>
...@@ -32,11 +33,12 @@ export default { ...@@ -32,11 +33,12 @@ export default {
handleToLogin() { handleToLogin() {
this.$router.push({path: "/login"}); this.$router.push({path: "/login"});
}, },
handleExit(){ handleExit() {
localStorage.removeItem('loginInfo') localStorage.removeItem('loginInfo')
localStorage.removeItem('TOKEN') localStorage.removeItem('TOKEN')
localStorage.removeItem('gs-user') localStorage.removeItem('gs-user')
this.$router.push({path: "/"}); // this.$router.push({path: "/"})
location.href = '/'
this.user = null this.user = null
} }
}, },
......
...@@ -15,37 +15,60 @@ ...@@ -15,37 +15,60 @@
</div> --> </div> -->
<div class="top-banner-item tb-hover">咨询电话:400-7000-690</div> <div class="top-banner-item tb-hover">咨询电话:400-7000-690</div>
<div class="top-banner-item"> <div class="top-banner-item">
<img src="../../assets/image/head/wx.png" alt="" /> <img src="../../assets/image/head/wx.png" alt=""/>
<a <a
class="tb-hover" class="tb-hover"
target="_blank" target="_blank"
:href="`${urls.ancc}gs1cnweixin.aspx`" :href="`${urls.ancc}gs1cnweixin.aspx`"
>官方微信</a >官方微信</a
> >
</div> </div>
<div class="top-banner-item"> <div class="top-banner-item">
<img src="../../assets/image/head/xlwb.png" alt="" /> <img src="../../assets/image/head/xlwb.png" alt=""/>
<a class="tb-hover" target="_blank" href="https://weibo.com/gs1cn" <a class="tb-hover" target="_blank" href="https://weibo.com/gs1cn"
>官方微博</a >官方微博</a
> >
</div> </div>
<div class="top-banner-item tb-hover" @click="handelSearch"> <div class="top-banner-item tb-hover" @click="handleSearch">
<img src="../../assets/image/head/search.png" alt="" /> <img src="../../assets/image/head/search.png" alt=""/>
</div> </div>
<span @click="toAdmin" style="cursor: pointer;margin-left: 4px" v-if="user.username">{{ user.username }}</span>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { mapState } from "vuex"; import {mapState} from "vuex";
export default { export default {
name: "topBanner", name: "topBanner",
computed: { computed: {
...mapState(["urls"]), ...mapState(["urls"]),
}, },
created() {
this.user = localStorage.getItem('loginInfo') ? JSON.parse(localStorage.getItem('loginInfo')) : {}
console.log(this.user)
},
data() {
return {
user: {}
}
},
methods: { methods: {
handelSearch() { toAdmin() {
if (this.user.userType === 3 && this.user.levels === null) {
this.$router.push({path: '/MyManage/UnVerify/index'})
} else if (this.user.userType === 2) {
this.$router.push({path: '/MyManage/SystemMember/index'})
} else if (this.user.levels === 0) {
this.$router.push({path: '/MyManage/admin/check'})
} else if (this.user.levels === 1) {
this.$router.push({path: '/MyManage/admin/check'})
} else if (String(this.user.levels).length === 4) {
this.$router.push({path: '/MyManage/admin/check'})
}
},
handleSearch() {
this.$router.push({ this.$router.push({
path: "/Home/sousuo", path: "/Home/sousuo",
}); });
...@@ -61,6 +84,7 @@ export default { ...@@ -61,6 +84,7 @@ export default {
color: #414345; color: #414345;
} }
} }
.top-banner { .top-banner {
height: 30px; height: 30px;
width: 100%; width: 100%;
...@@ -72,6 +96,7 @@ export default { ...@@ -72,6 +96,7 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-end; justify-content: flex-end;
.tb-hover:hover { .tb-hover:hover {
cursor: pointer; cursor: pointer;
color: #0e2c6b; color: #0e2c6b;
......
...@@ -114,15 +114,17 @@ export default { ...@@ -114,15 +114,17 @@ export default {
this.$api.user.login({ this.$api.user.login({
...this.userForm, ...this.userForm,
uuid: this.uuid uuid: this.uuid
}).then(res => { }).then(async res => {
console.log(res, !res.success) console.log(res, !res.success)
if (!res.success) { if (!res.success) {
this.userLoginError = res.returnMsg || '用户名或密码不正确!' this.userLoginError = res.returnMsg || '用户名或密码不正确!'
this.showUserLoginError = true; this.showUserLoginError = true;
this.getCaptcha(); this.getCaptcha();
} else { } else {
localStorage.setItem('loginInfo', JSON.stringify(res.data))
localStorage.setItem('TOKEN', res.data.token) localStorage.setItem('TOKEN', res.data.token)
const memberInfo = await this.$api.myManage.memberInfo({id: res.data.id})
console.log(memberInfo)
localStorage.setItem('loginInfo', JSON.stringify({...res.data, ...memberInfo.data}))
if (res.data.userType === 3 && res.data.levels === null) { if (res.data.userType === 3 && res.data.levels === null) {
localStorage.setItem('gs-user', JSON.stringify({type: 'unVerify'})) localStorage.setItem('gs-user', JSON.stringify({type: 'unVerify'}))
this.$router.push({path: '/MyManage/UnVerify/index'}) this.$router.push({path: '/MyManage/UnVerify/index'})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment