master
parent
ef0137c3be
commit
9b1455c22d
@ -0,0 +1,17 @@
|
|||||||
|
import request from "@/utils/request";
|
||||||
|
|
||||||
|
export function getNotice(params){
|
||||||
|
return request({
|
||||||
|
url:'/api/merchant/home/get-notice',
|
||||||
|
method:'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toggleRead(data){
|
||||||
|
return request({
|
||||||
|
url:'/api/admin/merchant/toggle-read',
|
||||||
|
method:"post",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -1,140 +1,312 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<hamburger :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
|
<hamburger
|
||||||
|
:is-active="sidebar.opened"
|
||||||
<breadcrumb class="breadcrumb-container" />
|
class="hamburger-container"
|
||||||
|
@toggleClick="toggleSideBar"
|
||||||
<div class="right-menu">
|
/>
|
||||||
<el-dropdown class="avatar-container" trigger="click">
|
|
||||||
<div class="avatar-wrapper">
|
<breadcrumb class="breadcrumb-container" />
|
||||||
<img src="../../assets/face.jpg" class="user-avatar">
|
|
||||||
<i class="el-icon-caret-bottom" />
|
<div class="right-menu">
|
||||||
</div>
|
<el-dropdown
|
||||||
<el-dropdown-menu slot="dropdown" class="user-dropdown">
|
class="message-container"
|
||||||
<router-link to="/">
|
trigger="click"
|
||||||
<el-dropdown-item>
|
:hide-on-click="false"
|
||||||
系统首页
|
>
|
||||||
</el-dropdown-item>
|
<div class="message-wrapper">
|
||||||
</router-link>
|
<i class="el-icon-chat-dot-square" />
|
||||||
<router-link to="/info/password">
|
<span>消息中心</span>
|
||||||
<el-dropdown-item>
|
</div>
|
||||||
个人信息
|
<template v-slot:dropdown>
|
||||||
</el-dropdown-item>
|
<el-dropdown-menu class="message-dropdown">
|
||||||
</router-link>
|
<!-- <el-dropdown-item>
|
||||||
<el-dropdown-item divided @click.native="logout">
|
<Button
|
||||||
<span style="display:block;">退出</span>
|
:ghost="messageStatus !== 2"
|
||||||
</el-dropdown-item>
|
type="error"
|
||||||
</el-dropdown-menu>
|
size="small"
|
||||||
</el-dropdown>
|
shape="circle"
|
||||||
</div>
|
icon="ios-close"
|
||||||
</div>
|
@click.native="messageStatus = 2,getNotice()"
|
||||||
</template>
|
>未读</Button
|
||||||
|
>
|
||||||
<script>
|
<Button
|
||||||
import {
|
:ghost="messageStatus !== 1"
|
||||||
mapGetters
|
type="success"
|
||||||
} from 'vuex'
|
size="small"
|
||||||
import Breadcrumb from '@/components/Breadcrumb'
|
shape="circle"
|
||||||
import Hamburger from '@/components/Hamburger'
|
icon="ios-checkmark"
|
||||||
|
style="margin-left: 10px"
|
||||||
export default {
|
@click.native="messageStatus = 1,getNotice()"
|
||||||
components: {
|
>已读</Button
|
||||||
Breadcrumb,
|
>
|
||||||
Hamburger
|
</el-dropdown-item> -->
|
||||||
},
|
<template v-if="noticeData.length > 0">
|
||||||
computed: {
|
<template v-for="(item, index) in noticeData">
|
||||||
...mapGetters([
|
<el-dropdown-item :divided="!index">
|
||||||
'sidebar',
|
<div style="display: flex; align-items: center">
|
||||||
'avatar'
|
<div v-for="(value, key) in item.data">
|
||||||
])
|
{{item.created_at}} {{ key }} : {{ value }}
|
||||||
},
|
</div>
|
||||||
methods: {
|
<Button
|
||||||
toggleSideBar() {
|
style="margin-left: 10px;"
|
||||||
this.$store.dispatch('app/toggleSideBar')
|
size="small"
|
||||||
},
|
:type="item.read_at ? 'success' : 'primary'"
|
||||||
async logout() {
|
:icon="item.read_at ? 'md-checkmark' : 'ios-create-outline'"
|
||||||
await this.$store.dispatch('user/logout')
|
@click="toggleMessage(item)"
|
||||||
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
|
>{{ item.read_at ? "已读" : "标为已读" }}</Button
|
||||||
}
|
>
|
||||||
}
|
</div>
|
||||||
}
|
</el-dropdown-item>
|
||||||
</script>
|
</template>
|
||||||
|
</template>
|
||||||
<style lang="scss" scoped>
|
<template v-else>
|
||||||
.navbar {
|
<div style="min-width:200px;text-align: center;color: rgb(140,140,140);padding: 10px 0;">暂无通知</div>
|
||||||
height: 50px;
|
</template>
|
||||||
overflow: hidden;
|
</el-dropdown-menu>
|
||||||
position: relative;
|
</template>
|
||||||
background: #fff;
|
</el-dropdown>
|
||||||
box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
|
|
||||||
|
<el-dropdown class="avatar-container" trigger="click">
|
||||||
.hamburger-container {
|
<div class="avatar-wrapper">
|
||||||
line-height: 46px;
|
<img src="../../assets/face.jpg" class="user-avatar" />
|
||||||
height: 100%;
|
<i class="el-icon-caret-bottom" />
|
||||||
float: left;
|
</div>
|
||||||
cursor: pointer;
|
<el-dropdown-menu slot="dropdown" class="user-dropdown">
|
||||||
transition: background .3s;
|
<router-link to="/">
|
||||||
-webkit-tap-highlight-color: transparent;
|
<el-dropdown-item> 系统首页 </el-dropdown-item>
|
||||||
|
</router-link>
|
||||||
&:hover {
|
<el-dropdown-item divided @click.native="logout">
|
||||||
background: rgba(0, 0, 0, .025)
|
<span style="display: block">退出</span>
|
||||||
}
|
</el-dropdown-item>
|
||||||
}
|
</el-dropdown-menu>
|
||||||
|
</el-dropdown>
|
||||||
.breadcrumb-container {
|
</div>
|
||||||
float: left;
|
|
||||||
}
|
<!-- <el-drawer-->
|
||||||
|
<!-- size="36%"-->
|
||||||
.right-menu {
|
<!-- append-to-body-->
|
||||||
float: right;
|
<!-- :visible.sync="showDrawer"-->
|
||||||
height: 100%;
|
<!-- direction="rtl">-->
|
||||||
line-height: 50px;
|
<!-- <Table size="small" :loading="isLoading" :columns="columns" :data="noticeData"></Table>-->
|
||||||
|
<!-- </el-drawer>-->
|
||||||
&:focus {
|
</div>
|
||||||
outline: none;
|
</template>
|
||||||
}
|
|
||||||
|
<script>
|
||||||
.right-menu-item {
|
import { mapGetters } from "vuex";
|
||||||
display: inline-block;
|
import Breadcrumb from "@/components/Breadcrumb";
|
||||||
padding: 0 8px;
|
import Hamburger from "@/components/Hamburger";
|
||||||
height: 100%;
|
|
||||||
font-size: 18px;
|
import { getNotice, toggleRead } from "@/api/notice";
|
||||||
color: #5a5e66;
|
export default {
|
||||||
vertical-align: text-bottom;
|
components: {
|
||||||
|
Breadcrumb,
|
||||||
&.hover-effect {
|
Hamburger,
|
||||||
cursor: pointer;
|
},
|
||||||
transition: background .3s;
|
data() {
|
||||||
|
return {
|
||||||
&:hover {
|
// showDrawer:false,
|
||||||
background: rgba(0, 0, 0, .025)
|
// // messageType:'',
|
||||||
}
|
// message: {
|
||||||
}
|
// 余额不足: "MerchantBalance",
|
||||||
}
|
// 用户取消单: "OrderItemMemberCancel",
|
||||||
|
// 分发48小时未接收退回: "OrderItemMerchantAutoRecover",
|
||||||
.avatar-container {
|
// 商家取消订单: "OrderItemMerchantCancel",
|
||||||
margin-right: 30px;
|
// 商家退回订单: "OrderItemMerchantReturn",
|
||||||
|
// },
|
||||||
.avatar-wrapper {
|
|
||||||
margin-top: 5px;
|
//isLoading:false,
|
||||||
position: relative;
|
noticeData: [],
|
||||||
|
messageStatus: 2,
|
||||||
.user-avatar {
|
// columns:[
|
||||||
cursor: pointer;
|
// {
|
||||||
width: 40px;
|
// width: 160,
|
||||||
height: 40px;
|
// title:"阅读时间",
|
||||||
border-radius: 10px;
|
// key:"read_at"
|
||||||
}
|
// },
|
||||||
|
// {
|
||||||
.el-icon-caret-bottom {
|
// title:"内容",
|
||||||
cursor: pointer;
|
// render:(h,{row,column,index}) => {
|
||||||
position: absolute;
|
// let getContent = () => {
|
||||||
right: -20px;
|
// let keys = []
|
||||||
top: 25px;
|
// if(row?.data && typeof row.data === 'object') keys = Object.keys(row?.data)
|
||||||
font-size: 12px;
|
// return keys.map(item => {
|
||||||
}
|
// return h('span',{},`${item}:${row.data[item]}`)
|
||||||
}
|
// })
|
||||||
}
|
// console.log(keys)
|
||||||
}
|
// }
|
||||||
}
|
// return h('div',{},getContent())
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// title:"操作",
|
||||||
|
// width:120,
|
||||||
|
// render:(h,{row,column,index}) => {
|
||||||
|
// return h('Button',{
|
||||||
|
// props:row?.read_at ? {
|
||||||
|
// size:"small",
|
||||||
|
// type:'success',
|
||||||
|
// icon:'md-checkmark'
|
||||||
|
// } : {
|
||||||
|
// size:"small",
|
||||||
|
// type:'primary',
|
||||||
|
// icon:'ios-create-outline'
|
||||||
|
// },
|
||||||
|
// on:{
|
||||||
|
// ['click']:async () => {
|
||||||
|
// if(row?.read_at) return
|
||||||
|
//
|
||||||
|
// const res = await toggleRead({
|
||||||
|
// id:row.id
|
||||||
|
// })
|
||||||
|
// this.$message({
|
||||||
|
// type:'success',
|
||||||
|
// message:res?.msg || "成功"
|
||||||
|
// })
|
||||||
|
// this.messageClick(this.messageType)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// },row?.read_at ? '已读' : '标为已读')
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// ]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(["sidebar", "avatar"]),
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toggleMessage(item){
|
||||||
|
if(item.read_at) return
|
||||||
|
toggleRead({
|
||||||
|
id:item.id
|
||||||
|
}).then(res => {
|
||||||
|
this.$message({
|
||||||
|
type:'success',
|
||||||
|
message:res?.msg || "成功"
|
||||||
|
})
|
||||||
|
this.getNotice()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async getNotice() {
|
||||||
|
let res = await getNotice({
|
||||||
|
// read_state: this.messageStatus,
|
||||||
|
type:"MerchantBalance"
|
||||||
|
});
|
||||||
|
console.log(res);
|
||||||
|
this.noticeData = res.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleSideBar() {
|
||||||
|
this.$store.dispatch("app/toggleSideBar");
|
||||||
|
},
|
||||||
|
async logout() {
|
||||||
|
await this.$store.dispatch("user/logout");
|
||||||
|
this.$router.push(`/login?redirect=${this.$route.fullPath}`);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getNotice();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.navbar {
|
||||||
|
height: 50px;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
background: #fff;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-menu {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-container {
|
||||||
|
margin-right: 20px;
|
||||||
|
|
||||||
|
.message-wrapper {
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
padding: 0 6px;
|
||||||
|
& > i {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
& > span {
|
||||||
|
font-weight: 600;
|
||||||
|
|
||||||
|
padding-left: 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
Reference in new issue