Commit 983cc2d9 by tang

feat: 个人中心入口

parent 34708a5f
<template>
<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 v-else type="primary" style="padding: 9px 30px;margin-right: 6px" size="small" @click="handleExit">退出登录
</el-button>
......@@ -32,11 +33,12 @@ export default {
handleToLogin() {
this.$router.push({path: "/login"});
},
handleExit(){
handleExit() {
localStorage.removeItem('loginInfo')
localStorage.removeItem('TOKEN')
localStorage.removeItem('gs-user')
this.$router.push({path: "/"});
// this.$router.push({path: "/"})
location.href = '/'
this.user = null
}
},
......
......@@ -15,37 +15,60 @@
</div> -->
<div class="top-banner-item tb-hover">咨询电话:400-7000-690</div>
<div class="top-banner-item">
<img src="../../assets/image/head/wx.png" alt="" />
<img src="../../assets/image/head/wx.png" alt=""/>
<a
class="tb-hover"
target="_blank"
:href="`${urls.ancc}gs1cnweixin.aspx`"
>官方微信</a
class="tb-hover"
target="_blank"
:href="`${urls.ancc}gs1cnweixin.aspx`"
>官方微信</a
>
</div>
<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
>官方微博</a
>
</div>
<div class="top-banner-item tb-hover" @click="handelSearch">
<img src="../../assets/image/head/search.png" alt="" />
<div class="top-banner-item tb-hover" @click="handleSearch">
<img src="../../assets/image/head/search.png" alt=""/>
</div>
<span @click="toAdmin" style="cursor: pointer;margin-left: 4px" v-if="user.username">{{ user.username }}</span>
</div>
</div>
</template>
<script>
import { mapState } from "vuex";
import {mapState} from "vuex";
export default {
name: "topBanner",
computed: {
...mapState(["urls"]),
},
created() {
this.user = localStorage.getItem('loginInfo') ? JSON.parse(localStorage.getItem('loginInfo')) : {}
console.log(this.user)
},
data() {
return {
user: {}
}
},
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({
path: "/Home/sousuo",
});
......@@ -61,6 +84,7 @@ export default {
color: #414345;
}
}
.top-banner {
height: 30px;
width: 100%;
......@@ -72,6 +96,7 @@ export default {
display: flex;
align-items: center;
justify-content: flex-end;
.tb-hover:hover {
cursor: pointer;
color: #0e2c6b;
......
......@@ -114,15 +114,17 @@ export default {
this.$api.user.login({
...this.userForm,
uuid: this.uuid
}).then(res => {
}).then(async res => {
console.log(res, !res.success)
if (!res.success) {
this.userLoginError = res.returnMsg || '用户名或密码不正确!'
this.showUserLoginError = true;
this.getCaptcha();
} else {
localStorage.setItem('loginInfo', JSON.stringify(res.data))
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) {
localStorage.setItem('gs-user', JSON.stringify({type: 'unVerify'}))
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