lilishop-ui/seller/src/views/Main.vue

187 lines
5.4 KiB
Vue
Raw Normal View History

2021-05-13 10:56:04 +08:00
<style lang="scss" scoped>
@import "./main.scss";
</style>
<template>
<div class="main">
<div class="sidebar-menu-con menu-bar">
<div class="logo-con">
<img src="../assets/logo.png" key="max-logo" />
</div>
<shrinkable-menu></shrinkable-menu>
</div>
<!-- 顶部标题栏主体 -->
<div class="main-header-con">
2021-05-13 10:56:04 +08:00
<div class="main-header">
<div :class="{'header-avator-con':navType!=4, 'header-avator-con nav4':navType == 4}">
<!-- 用户头像 -->
<div class="user-dropdown-menu-con">
<Row type="flex" justify="end" align="middle" class="user-dropdown-innercon">
<Dropdown transfer trigger="hover" @on-click="handleClickUserDropdown">
<div class="dropList">
<span class="main-user-name">{{ userInfo.storeName }}</span>
<Icon type="md-arrow-dropdown" />
<Avatar :src="userInfo.storeLogo" style="background: #fff;margin-left: 10px;"></Avatar>
</div>
<DropdownMenu slot="list">
2021-08-31 09:46:18 +08:00
<DropdownItem name="changePass">修改密码</DropdownItem>
<DropdownItem name="loginOut" divided>退出</DropdownItem>
2021-05-13 10:56:04 +08:00
</DropdownMenu>
</Dropdown>
</Row>
</div>
</div>
</div>
<!-- 已打开的页面标签 -->
<div class="tags-con">
<tags-page-opened :pageTagsList="pageTagsList"></tags-page-opened>
</div>
</div>
<div class="single-page-con">
<div class="single-page">
2021-07-31 15:49:54 +08:00
<!-- <keep-alive :include="cachePage"> -->
<!-- </keep-alive> -->
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
2021-05-13 10:56:04 +08:00
</keep-alive>
2021-07-31 15:49:54 +08:00
<router-view v-if="!$route.meta.keepAlive"></router-view>
2021-05-13 10:56:04 +08:00
</div>
</div>
<!-- 全局加载动画 -->
<circleLoading class="loading-position" v-show="loading" />
</div>
</template>
<script>
import shrinkableMenu from "./main-components/shrinkable-menu/shrinkable-menu.vue";
import tagsPageOpened from "./main-components/tags-page-opened.vue";
import circleLoading from "@/views/my-components/lili/circle-loading.vue";
import Cookies from "js-cookie";
import util from "@/libs/util.js";
export default {
components: {
shrinkableMenu,
tagsPageOpened,
2021-07-14 18:00:59 +08:00
circleLoading
2021-05-13 10:56:04 +08:00
},
data() {
return {
sliceNum: 5, // 展示nav数量
2021-07-31 15:49:54 +08:00
userInfo: {}, // 用户信息
2021-05-13 10:56:04 +08:00
navType: 1, // nav类型
};
},
computed: {
loading() {
return this.$store.state.app.loading;
},
pageTagsList() {
return this.$store.state.app.storeOpenedList; // 打开的页面的页面对象
},
cachePage() {
return this.$store.state.app.cachePage;
},
lang() {
return this.$store.state.app.lang;
},
mesCount() {
return 0;
},
},
methods: {
// 初始化方法
2021-05-13 10:56:04 +08:00
init() {
// 菜单
let pathArr = util.setCurrentPath(this, this.$route.name);
if (pathArr.length >= 2) {
this.$store.commit("addOpenSubmenu", pathArr[1].name);
}
let userInfo = JSON.parse(Cookies.get("userInfoSeller"));
2021-05-13 10:56:04 +08:00
this.userInfo = userInfo;
this.checkTag(this.$route.name);
let currWidth = document.body.clientWidth;
if (currWidth <= 1200) {
this.sliceNum = 2;
}
},
// 用户头像下拉
2021-05-13 10:56:04 +08:00
handleClickUserDropdown(name) {
if (name == "ownSpace") {
util.openNewPage(this, "personal-enter");
this.$router.push({
name: "personal-enter",
});
} else if (name == "changePass") {
util.openNewPage(this, "change_pass");
this.$router.push({
name: "change_pass",
});
} else if (name == "loginOut") {
Cookies.set("accessToken", "");
this.$store.commit("logout", this);
this.$store.commit("clearOpenedSubmenu");
this.setStore("accessToken", "");
this.setStore("refreshToken", "");
this.$router.push({ path: "/login" });
}
},
// 快捷页签选中状态
2021-05-13 10:56:04 +08:00
checkTag(name) {
let openpageHasTag = this.pageTagsList.some((item) => {
if (item.name == name) {
return true;
}
});
if (!openpageHasTag) {
// 解决关闭当前标签后再点击回退按钮会退到当前页时没有标签的问题
util.openNewPage(
this,
name,
this.$route.params || {},
this.$route.query || {}
);
}
},
// 宽度变化
2021-05-13 10:56:04 +08:00
resize() {
let currWidth = document.body.clientWidth;
let count = currWidth / 300;
if (count > 6) {
this.sliceNum = 6;
} else {
this.sliceNum = count;
}
},
},
watch: {
$route(to) {
this.$store.commit("setCurrentPageName", to.name);
let pathArr = util.setCurrentPath(this, to.name);
if (pathArr.length > 2) {
this.$store.commit("addOpenSubmenu", pathArr[1].name);
}
this.checkTag(to.name);
localStorage.currentPageName = to.name;
},
lang() {
util.setCurrentPath(this, this.$route.name); // 在切换语言时用于刷新面包屑
},
},
mounted() {
this.init();
let that = this;
this.resize();
window.addEventListener("resize", function () {
that.resize();
});
},
created() {
// 显示打开的页面的列表
this.$store.commit("setOpenedList");
},
};
</script>