| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- <template>
- <!-- 消息中心 -->
- <el-drawer
- :close-on-press-escape="true"
- style="margin-top: 50px"
- :visible.sync="drawer"
- :modal="false"
- :show-close="false"
- size="90%">
- <div>
- <el-col :span="6" class="left-list">
- <div class="tabs">
- <el-badge :value="unreadNum" class="item">
- <a :class="switchMessageType=='unread'?'active':''" @click="switchMessage('unread')">未读信息</a>
- </el-badge>
- <el-badge class="item">
- <a :class="switchMessageType=='read'?'active':''" @click="switchMessage('read')">已读信息</a>
- </el-badge>
- </div>
- <ul class="message-list" v-if="switchMessageType == 'unread'">
- <li class="list-item" v-for="item in unreadList" :key="item.id" @click="toReading(item)">
- <p class="item-info">
- <span class="name">{{item.title}}</span>
- <span class="time">{{item.sendtime}}</span>
- </p>
- <p>{{item.atext}}</p>
- </li>
- </ul>
- <ul class="message-list" v-if="switchMessageType == 'read'">
- <li class="list-item" v-for="item in readList" :key="item.id" @click="toReading(item)">
- <p class="item-info">
- <span class="name">{{item.title}}</span>
- <span class="time">{{item.sendtime}}</span>
- </p>
- <p>{{item.atext}}</p>
- </li>
- </ul>
- </el-col>
- <el-col :span="18">
- <el-row class="title">
- <strong>客服满意度调查!</strong>
- <i @click="handleClose" class="el-icon-close"></i>
- </el-row>
- <el-row class="messageBox" v-if="nomessage">
- <ul>
- <li><p>发件人:{{unreadListOne.admin_name}}</p></li>
- <li><p>收件人:{{userName}}</p></li>
- <li><p>时 间:{{unreadListOne.sendtime}}</p></li>
- </ul>
- <div class="message-content">{{unreadListOne.atext}}</div>
- </el-row>
- <el-row class="messageBox" v-if="nomessage == false">
- <ul>
- <li><p>发件人:{{messageBox.admin_name}}</p></li>
- <li><p>收件人:{{userName}}</p></li>
- <li><p>时 间:{{messageBox.sendtime}}</p></li>
- </ul>
- <div class="message-content">{{messageBox.atext}}</div>
- </el-row>
- </el-col>
- </div>
- </el-drawer>
- </template>
- <script>
- export default {
- name: "messageCenter",
- data() {
- return {
- drawer: false,
- switchMessageType: "unread",
- nomessage:true,
- userID:null,
- userName:null,
- //已读列表
- readList:[],
- //未读列表
- unreadList:[],
- //未读第一个
- unreadListOne:[],
- //未读数量
- unreadNum:null,
- // 详情
- messageBox:[],
- }
- },
- computed: {
- get_drawer() {
- return this.$store.getters.get_drawer;
- },
- },
- watch: {
- get_drawer(data) {
- console.log(data)
- this.drawer = data;
- this.userID = this.$store.getters.get_user_info.id;
- this.userName = this.$store.getters.get_user_info.user_name;
- this.readnotice();
- this.unreadnotice();
- },
- },
- methods: {
- handleClose() {
- this.$store.dispatch("SET_DRAWER", false);
- },
- switchMessage(num) {
- this.switchMessageType = num;
- },
- // 已读信息
- readnotice(){
- let str = "readnotice" + "customer-service" + "index" + this.time + "service";
- let obj = {
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- apiToken: this.$md5(str),
- userToken: this.token
- },
- user_id: this.userID
- };
- this.post("api/service/index/readnotice", obj).then(res => {
- console.log(res)
- if(res.data.code === 1){
- console.log("已读",res.data.data)
- this.readList = res.data.data;
- }
- });
- },
- // 未读信息
- unreadnotice(){
- let str = "unreadnotice" + "customer-service" + "index" + this.time + "service";
- let obj = {
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- apiToken: this.$md5(str),
- userToken: this.token
- },
- user_id: this.userID
- };
- this.post("api/service/index/unreadnotice", obj).then(res => {
- console.log(res)
- if(res.data.code === 1){
- console.log("未读",res.data.data)
- this.unreadList = res.data.data;
- this.unreadListOne = res.data.data[0];
- console.log(this.unreadListOne,'第一个')
- this.unreadNum = res.data.data.length;
- }
- });
- },
- // 点击显示当前详细内容
- toReading(item){
- console.log(item);
- this.nomessage = false;
- this.messageBox = item;
- }
- },
- }
- </script>
- <style lang="less" scoped>
- .left-list {
- border-right: 1px solid #D5E5FF;
- height: 100vh;
- }
- .tabs {
- display: flex;
- justify-content: space-around;
- height: 48px;
- line-height: 48px;
- border-bottom: 1px solid #D5E5FF;
- a {
- font-size: 14px;
- cursor: pointer;
- }
- a.active {
- color: #5399F5;
- border-bottom: 2px solid #5399F5;
- }
- }
- .message-list {
- margin: 0;
- /* 奇数背景色 */
- .list-item:nth-of-type(odd) {
- background: #F6F8FF;
- }
- /* 偶数背景色 */
- .list-item:nth-of-type(even) {
- background: #fff;
- }
- .list-item {
- padding: 10px 20px;
- p {
- color: #666;
- font-size: 14px;
- overflow: hidden;
- text-overflow:ellipsis;
- white-space: nowrap;
- }
- }
- .item-info {
- margin-bottom: 10px;
- display: flex;
- justify-content: space-between;
- span {
- font-size: 14px;
- color: #666;
- }
- span.time {
- color: #999;
- }
- }
- }
- .title {
- padding: 0 10px;
- height: 48px;
- line-height: 48px;
- border-bottom: 1px solid #D5E5FF;
- i {
- margin-top: 15px;
- font-size: 18px;
- cursor: pointer;
- float: right;
- }
- }
- .messageBox {
- padding: 15px 20px;
- li {
- margin: 10px 0;
- p {
- font-size: 14px;
- color: #999999;
- }
- }
- .message-content {
- margin-top: 20px;
- background: #F5F5F5;
- border: 1px solid #EEEEEE;
- padding: 20px;
- font-size: 14px;
- color: #666;
- line-height: 1.8;
- }
- }
- </style>
- <style>
- .left-list .el-badge__content.is-fixed {
- position: absolute;
- top: 12px !important;
- right: 10px !important;
- }
- .el-drawer__container {
- outline: none !important;
- }
- .el-drawer__header {
- padding: 0 !important;
- height: 10px !important;
- margin-bottom: 0 !important;
- }
- </style>
|