beelink/src/components/Menu.vue

256 lines
7.7 KiB
Vue
Raw Normal View History

2020-09-25 07:13:39 +00:00
<template>
<div class="menu">
<div class="user" style="overflow: hidden;">
<div class="user" :class="{'seltop': selnum == 0}">
2020-11-18 06:28:21 +00:00
<!-- <img :src="userinfo.img" alt="" class="head"> -->
<a-avatar :size="85" shape="circle" class="head" :src="userinfo.img">
<template v-slot:icon><UserOutlined /></template>
</a-avatar>
2020-10-25 14:43:53 +00:00
<div class="name">{{userinfo.name}}</div>
2020-09-25 07:13:39 +00:00
</div>
</div>
2020-11-03 01:26:59 +00:00
<div class="list">
2020-11-02 06:35:22 +00:00
<div v-for="(i,j) in list" :key="j" style="overflow: hidden;" @click="routeto(j)">
2020-09-25 07:13:39 +00:00
<div class="item" :class="{'selitem': j == selnum, 'seltop': j == selnum - 1, 'selbottom': j == selnum + 1}">
<div class="route">
2020-10-30 09:01:35 +00:00
<img :src="j == selnum ? i.sleicon : i.icon" alt="" class="icon">
2020-10-30 03:46:29 +00:00
<div class="title">{{lan.$t(i.name)}}</div>
2020-09-25 07:13:39 +00:00
</div>
2020-10-30 09:01:35 +00:00
<img alt="" :src="j == selnum ? jiantous : jiantou" class="right">
2020-09-25 07:13:39 +00:00
</div>
</div>
<div style="overflow: hidden;">
<div class="item" :class="{'selbottom': selnum == list.length - 1}"></div>
</div>
2020-11-18 06:34:28 +00:00
<div class="item loginout" @click="visible = true">
2020-11-03 08:00:07 +00:00
<div class="route">
2020-10-10 06:34:23 +00:00
<img src="../static/images/tuichu.png" alt="" class="icon">
2020-09-25 07:13:39 +00:00
<div class="title">
2020-10-30 03:46:29 +00:00
{{lan.$t('tuichu')}}
2020-09-25 07:13:39 +00:00
</div>
</div>
</div>
</div>
2020-11-18 06:34:28 +00:00
<a-modal v-model:visible="visible" :title="lan.$t('tishi')" @ok="logout">
<p>{{lan.$t('querentuichu')}}</p>
</a-modal>
2020-09-25 07:13:39 +00:00
</div>
</template>
<style lang="scss" scoped>
.menu{
user-select: none;
width: 171px;
2020-09-25 08:34:20 +00:00
height: 100%;
2020-09-25 07:13:39 +00:00
display: flex;
flex-direction: column;
background: linear-gradient(0deg, #0EDCC2, #50DF98, #7EE278, #A2E562);
.user{
width: 100%;
height: 150px;
display: flex;
2020-09-25 07:46:03 +00:00
flex-shrink: 0;
2020-09-25 07:13:39 +00:00
flex-direction: column;
align-items: center;
justify-content: center;
.head{
width: 57px;
height: 57px;
margin-bottom: 15px;
border-radius: 50%;
}
.name{
font-size: 15rpx;
line-height: 1;
color: #fff;
}
}
.list{
position: relative;
display: flex;
height: 100%;
padding-left: 6px;
display: flex;
flex-direction: column;
.item{
display: flex;
align-items: center;
height: 50px;
padding: 0 18px;
justify-content: space-between;
2020-10-31 06:00:07 +00:00
cursor: pointer;
2020-11-02 06:35:22 +00:00
&:hover{
.route{
.title{
font-weight: bold;
}
}
}
2020-09-25 07:13:39 +00:00
.route{
display: flex;
.icon{
width: 15px;
height: 15px;
}
.title{
font-size: 13px;
color: #fff;
line-height: 1;
margin-left: 6px;
}
}
.right{
width: 5px;
height: 10px;
}
}
.loginout{
position: absolute;
bottom: 10px;
}
}
.seltop{
border-radius: 0 0 25px 0;
box-shadow: 0 0 0 30px #f5f5f5 ;
}
.selbottom{
border-radius: 0 25px 0 0;
box-shadow: 0 0 0 30px #f5f5f5 ;
}
.selitem{
border-radius: 25px 0 0 25px;
background-color: #F5F5F5;
.title{
color: #08AE98 !important;
font-weight: bold;
}
}
}
</style>
<script lang="ts">
2020-11-24 07:54:51 +00:00
import { logoutapi } from '@/api';
2020-10-30 06:49:01 +00:00
import { setToken } from '@/api/base';
2020-10-05 08:31:06 +00:00
import router from '@/router';
2020-10-10 02:19:38 +00:00
import store from '@/store';
2020-10-30 06:49:01 +00:00
import { saveValue } from '@/utils/common';
2020-10-30 03:46:29 +00:00
import { useI18n } from '@/utils/i18n';
2020-10-10 02:19:38 +00:00
import { computed, defineComponent, ref } from 'vue';
2020-10-10 06:34:23 +00:00
import { useRoute } from 'vue-router';
2020-09-25 07:13:39 +00:00
export default defineComponent({
setup(){
2020-10-30 03:46:29 +00:00
const lan: any = useI18n();
2020-09-25 07:13:39 +00:00
interface MenuItem {
icon: string;
2020-10-05 08:31:06 +00:00
sleicon: string;
2020-09-25 07:13:39 +00:00
name: string;
route: string;
}
2020-09-25 08:27:33 +00:00
// 左侧的列表数组
2020-09-25 07:13:39 +00:00
const list: Array<MenuItem> = [
{
2020-10-10 06:34:23 +00:00
icon: require("../static/images/wode1.png"),
2020-10-30 09:01:35 +00:00
sleicon: require("../static/images/wodedangan1.png"),
2020-10-30 03:46:29 +00:00
name: 'wodedangan',
2020-10-05 08:31:06 +00:00
route: "/mine/archives"
2020-09-25 07:13:39 +00:00
},
{
2020-10-10 06:34:23 +00:00
icon: require("../static/images/xiayig.png"),
2020-10-30 09:01:35 +00:00
sleicon:require("../static/images/shipin1.png"),
2020-10-30 03:46:29 +00:00
name: 'fabuzhibo',
2020-10-05 08:31:06 +00:00
route: "/mine/webcast"
2020-09-25 07:13:39 +00:00
},
{
2020-10-10 06:34:23 +00:00
icon: require("../static/images/shipin.png"),
2020-10-30 09:01:35 +00:00
sleicon: require("../static/images/zhibo1.png"),
2020-11-26 07:00:08 +00:00
name: 'shangchuanshipint',
2020-10-05 08:31:06 +00:00
route: "/mine/video"
2020-09-25 07:13:39 +00:00
},
{
2020-10-10 06:34:23 +00:00
icon: require("../static/images/yinhangka.png"),
2020-10-30 09:01:35 +00:00
sleicon: require("../static/images/qianbao1.png"),
2020-10-30 03:46:29 +00:00
name: 'wodeqianbao',
2020-10-05 08:31:06 +00:00
route: "/mine/wallet"
2020-09-25 07:13:39 +00:00
},
{
2020-10-10 06:34:23 +00:00
icon: require("../static/images/tongji.png"),
2020-10-30 09:01:35 +00:00
sleicon: require("../static/images/liebiao1.png"),
2020-10-30 03:46:29 +00:00
name: 'liebiaotongji',
2020-10-05 08:31:06 +00:00
route: "/mine/liststatistic"
2020-09-25 07:13:39 +00:00
},
{
2020-10-10 06:34:23 +00:00
icon: require("../static/images/bangzhu.png"),
2020-10-30 09:01:35 +00:00
sleicon: require("../static/images/guanyu1.png"),
2020-10-30 03:46:29 +00:00
name: 'guanyu',
2020-10-05 08:31:06 +00:00
route: "/mine/aboutus"
2020-09-25 07:13:39 +00:00
}
]
2020-09-25 08:27:33 +00:00
// 当前选中的index
2020-09-25 07:13:39 +00:00
const selnum = ref(0);
2020-10-10 02:19:38 +00:00
const userinfo = computed(() => store.state.userinfo)
2020-10-10 06:34:23 +00:00
// 设置当前路由
2020-11-06 14:46:40 +00:00
const routelist = [
["/mine/archives"],
['/mine/webcast'],
['/mine/video'],
['/mine/wallet', '/mine/cashout', '/mine/addaccount', '/mine/transaction', '/mine/transactionxq'],
['/mine/liststatistic'],
['/mine/aboutus']
]
for(const i in routelist){
for(const j in routelist[i]){
console.log(routelist[i][j]==useRoute().path)
if(routelist[i][j] == useRoute().path){
selnum.value = parseInt(i);
}
2020-10-10 06:34:23 +00:00
}
2020-11-06 14:46:40 +00:00
2020-10-10 06:34:23 +00:00
}
2020-09-25 08:27:33 +00:00
/**
* 跳转路由与赋值对应的下标
* @param index 选中的下标 方便赋值与跳转
*/
function routeto(index: number): void {
2020-09-25 07:13:39 +00:00
console.log(index)
selnum.value = index;
2020-10-05 08:31:06 +00:00
router.push({
path: list[index].route
})
2020-09-25 07:13:39 +00:00
}
2020-10-10 00:59:54 +00:00
2020-10-26 08:35:23 +00:00
function mouse(index: number): void {
console.log(index)
selnum.value = index;
}
2020-11-18 06:34:28 +00:00
const visible = ref(false);
2020-10-14 01:32:12 +00:00
function logout(): void{
2020-11-03 08:00:07 +00:00
console.log("退出")
2020-11-24 07:54:51 +00:00
logoutapi()
2020-10-14 01:32:12 +00:00
store.commit("login", false)
2020-10-30 06:49:01 +00:00
saveValue("token", "");
setToken();
2020-10-14 01:32:12 +00:00
router.replace("/");
}
2020-11-03 01:26:59 +00:00
2020-10-29 01:40:15 +00:00
2020-09-25 07:13:39 +00:00
return{
list,
routeto,
2020-10-10 02:19:38 +00:00
selnum,
2020-10-14 01:32:12 +00:00
userinfo,
2020-10-26 08:35:23 +00:00
logout,
2020-10-29 01:40:15 +00:00
mouse,
2020-10-30 09:01:35 +00:00
lan,
2020-11-18 06:34:28 +00:00
visible,
2020-10-30 09:01:35 +00:00
jiantou: require('../static/images/jiantou.png'),
jiantous: require('../static/images/kuozhan1.png')
2020-09-25 07:13:39 +00:00
}
}
})
</script>