123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <template>
- <div class="navbar">
- <hamburger
- id="hamburger-container"
- :is-active="sidebar.opened"
- class="hamburger-container"
- @toggleClick="toggleSideBar"
- />
- <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
- <div class="right-menu">
- <template v-if="device !== 'mobile'">
- <i
- v-if="isShow"
- class="el-icon-message-solid right-menu-item hover-effect shake"
- @click="openNotice"
- style="height: 50px; width: 40px; line-height: 52px; font-size: 22px"
- />
- <screenfull id="screenfull" class="right-menu-item hover-effect" />
- <!-- <el-tooltip content="Global Size" effect="dark" placement="bottom">
- <size-select id="size-select" class="right-menu-item hover-effect" />
- </el-tooltip> -->
- </template>
- <el-dropdown
- class="avatar-container right-menu-item hover-effect"
- trigger="click"
- >
- <div class="avatar-wrapper">
- <img :src="avatar + '?imageView2/1/w/80/h/80'" class="user-avatar" />
- <i class="el-icon-caret-bottom" />
- </div>
- <el-dropdown-menu slot="dropdown">
- <router-link to="/person/my-message">
- <el-dropdown-item>我的信息</el-dropdown-item>
- </router-link>
- <router-link to="/person/change-phone">
- <el-dropdown-item>更换手机号</el-dropdown-item>
- </router-link>
- <router-link to="/person/change-password">
- <el-dropdown-item>修改密码</el-dropdown-item>
- </router-link>
- <el-dropdown-item divided @click.native="logout">
- <span style="display: block">退出登录</span>
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- <el-dialog
- title="系统公告"
- :center="true"
- align="left"
- top="8vh"
- width="800px"
- @close="submit"
- :close-on-click-modal="false"
- :visible.sync="showModel"
- element-loading-text="拼命加载中"
- element-loading-spinner="el-icon-loading"
- element-loading-background="rgba(0, 0, 0, 0.8)"
- append-to-body
- >
- <el-card style="margin-top: -20px">
- <el-row :gutter="10" v-if="activeMsg !== null">
- <el-col :span="24">
- <div style="padding: 0 0 22px 0">
- <el-alert
- :closable="false"
- show-icon
- center
- class="my-el-alert"
- :title="activeMsg.module"
- :type="activeMsg.sys_type === 'VER' ? 'success' : 'warning'"
- ></el-alert>
- </div>
- <el-form
- :size="'mini'"
- label-position="left"
- label-width="82px"
- class="demo-table-expand"
- style="padding-left: 25px"
- >
- <el-row>
- <el-col :span="12" v-if="activeMsg.sys_type === 'VER'">
- <el-form-item label="版本编号:">
- <p style="margin: 0">{{ activeMsg.version }}</p>
- </el-form-item></el-col
- >
- <el-col :span="activeMsg.sys_type === 'VER' ? 12 : 24">
- <el-form-item
- :label="
- activeMsg.sys_type === 'VER' ? '更新时间:' : '预计时间:'
- "
- >
- <p style="margin: 0">
- {{ activeMsg.addtime }}
- </p></el-form-item
- ></el-col
- >
- <el-col :span="24"
- ><el-form-item label="更新内容:">
- <p
- style="margin: 0"
- v-html="activeMsg.system"
- ></p></el-form-item
- ></el-col>
- <el-col :span="24" style="text-align: right">
- <el-checkbox
- v-model="checked"
- class="fl"
- style="padding-top: 5px"
- >我已知晓,后续不再提示!</el-checkbox
- >
- <el-button @click="submit" type="primary" plain
- >关闭
- </el-button>
- </el-col>
- </el-row>
- </el-form>
- </el-col>
- </el-row>
- </el-card>
- </el-dialog>
- </div>
- </template>
- <script>
- import { mapGetters } from "vuex";
- import asyncRequest from "@/apis/service/system/updates";
- import resToken from "@/mixins/resToken";
- import { getNotice, setNotice } from "@/utils/auth";
- export default {
- computed: {
- ...mapGetters(["sidebar", "avatar", "device"]),
- },
- mixins: [resToken],
- data() {
- return {
- showModel: false,
- loading: false,
- isShow: true,
- statsTime: 0,
- endTime: 0,
- checked: false,
- lastNotice: null, //最后一次提示时间
- parmValue: {
- type: "",
- page: 1, // 页码
- size: 15, // 每页显示条数
- },
- activeMsg: null, //消息展示对象
- };
- },
- mounted() {
- this.openNotice(1);
- },
- methods: {
- async openNotice(type) {
- if (getNotice() && getNotice().length > 0) {
- this.lastNotice = JSON.parse(getNotice());
- } else {
- this.lastNotice = null;
- }
- console.log(this.lastNotice);
- this.loading = true;
- const { code, data } = await asyncRequest.list(this.parmValue);
- if (code === 0) {
- const { list, count } = data;
- if (count !== 0) {
- this.activeMsg = list[0];
- this.isShow = true;
- if (this.lastNotice + "" !== "null") {
- const { type, addtime, sys_type } = this.activeMsg;
- if (
- addtime === this.lastNotice.addtime &&
- sys_type === this.lastNotice.sys_type
- ) {
- if (type === "1") {
- this.checked = true;
- } else {
- this.checked = false;
- }
- } else {
- this.checked = false;
- }
- } else {
- this.page_set_notice();
- this.checked = false;
- }
- if (type === 1) {
- this.typeShow();
- } else {
- this.showModel = true;
- }
- } else {
- this.$message.warning("暂无信息推送!");
- }
- } else if (code >= 100 && code <= 104) {
- await this.logout();
- } else {
- this.activeMsg = null;
- this.isShow = false;
- }
- this.loading = false;
- },
- typeShow() {
- let nowtime = new Date().valueOf();
- if (this.activeMsg.sys_type === "VER") {
- this.statsTime = new Date(this.activeMsg.addtime).valueOf();
- this.endTime = this.statsTime + 1000 * 60 * 60 * 24 * 7;
- if (
- nowtime > this.statsTime &&
- nowtime < this.endTime &&
- !this.checked
- ) {
- this.showModel = true;
- } else {
- this.showModel = false;
- }
- } else {
- this.statsTime = 0;
- this.endTime = new Date(this.activeMsg.addtime).valueOf();
- if (nowtime < this.endTime && !this.checked) {
- this.showModel = true;
- } else {
- this.showModel = false;
- }
- }
- },
- toggleSideBar() {
- this.$store.dispatch("app/toggleSideBar");
- },
- async logout() {
- await this.$store.dispatch("user/logout");
- this.$router.push(`/login?redirect=${this.$route.fullPath}`);
- },
- submit() {
- this.page_set_notice();
- this.showModel = false;
- },
- //保存提交结果
- page_set_notice() {
- const { sys_type, addtime } = this.activeMsg;
- let model = {
- type: this.checked ? "1" : "0",
- sys_type: sys_type,
- addtime: addtime,
- };
- setNotice(JSON.stringify(model));
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- @keyframes shake {
- /* 水平抖动,核心代码 */
- 10%,
- 90% {
- transform: translate3d(-1px, 0, 0);
- }
- 20%,
- 80% {
- transform: translate3d(+2px, 0, 0);
- }
- 30%,
- 70% {
- transform: translate3d(-4px, 0, 0);
- }
- 40%,
- 60% {
- transform: translate3d(+4px, 0, 0);
- }
- 50% {
- transform: translate3d(-4px, 0, 0);
- }
- }
- .shake {
- animation: shake 800ms ease-in-out;
- }
- .navbar {
- height: 50px;
- overflow: hidden;
- position: relative;
- background: #fff;
- min-width: 1000px;
- box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
- .hamburger-container {
- line-height: 46px;
- height: 100%;
- float: left;
- cursor: pointer;
- transition: background 0.3s;
- -webkit-tap-highlight-color: transparent;
- &:hover {
- background: rgba(0, 0, 0, 0.025);
- }
- }
- .breadcrumb-container {
- float: left;
- width: 500px;
- //min-width: calc(1200px - 200px - 150px);
- }
- .errLog-container {
- display: inline-block;
- vertical-align: top;
- }
- .right-menu {
- float: right;
- height: 100%;
- line-height: 50px;
- &:focus {
- outline: none;
- }
- .right-menu-item {
- display: inline-block;
- padding: 0 8px;
- height: 100%;
- font-size: 18px;
- color: #5a5e66;
- vertical-align: text-bottom;
- &.hover-effect {
- cursor: pointer;
- transition: background 0.3s;
- &:hover {
- background: rgba(0, 0, 0, 0.025);
- }
- }
- }
- .avatar-container {
- margin-right: 30px;
- .avatar-wrapper {
- margin-top: 5px;
- position: relative;
- .user-avatar {
- cursor: pointer;
- width: 40px;
- height: 40px;
- border-radius: 10px;
- }
- .el-icon-caret-bottom {
- cursor: pointer;
- position: absolute;
- right: -20px;
- top: 25px;
- font-size: 12px;
- }
- }
- }
- }
- }
- </style>
|