messageCenter.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <!-- 消息中心 -->
  3. <el-drawer
  4. :close-on-press-escape="true"
  5. style="margin-top: 50px"
  6. :visible.sync="drawer"
  7. :modal="false"
  8. :show-close="false"
  9. size="90%">
  10. <div>
  11. <el-col :span="6" class="left-list">
  12. <div class="tabs">
  13. <el-badge :value="unreadNum" class="item">
  14. <a :class="switchMessageType=='unread'?'active':''" @click="switchMessage('unread')">未读信息</a>
  15. </el-badge>
  16. <el-badge class="item">
  17. <a :class="switchMessageType=='read'?'active':''" @click="switchMessage('read')">已读信息</a>
  18. </el-badge>
  19. </div>
  20. <ul class="message-list" v-if="switchMessageType == 'unread'">
  21. <li class="list-item" v-for="item in unreadList" :key="item.id" @click="toReading(item)">
  22. <p class="item-info">
  23. <span class="name">{{item.title}}</span>
  24. <span class="time">{{item.sendtime}}</span>
  25. </p>
  26. <p>{{item.atext}}</p>
  27. </li>
  28. </ul>
  29. <ul class="message-list" v-if="switchMessageType == 'read'">
  30. <li class="list-item" v-for="item in readList" :key="item.id" @click="toReading(item)">
  31. <p class="item-info">
  32. <span class="name">{{item.title}}</span>
  33. <span class="time">{{item.sendtime}}</span>
  34. </p>
  35. <p>{{item.atext}}</p>
  36. </li>
  37. </ul>
  38. </el-col>
  39. <el-col :span="18">
  40. <el-row class="title">
  41. <strong>客服满意度调查!</strong>
  42. <i @click="handleClose" class="el-icon-close"></i>
  43. </el-row>
  44. <el-row class="messageBox" v-if="nomessage">
  45. <ul>
  46. <li><p>发件人:{{unreadListOne.admin_name}}</p></li>
  47. <li><p>收件人:{{userName}}</p></li>
  48. <li><p>时 间:{{unreadListOne.sendtime}}</p></li>
  49. </ul>
  50. <div class="message-content">{{unreadListOne.atext}}</div>
  51. </el-row>
  52. <el-row class="messageBox" v-if="nomessage == false">
  53. <ul>
  54. <li><p>发件人:{{messageBox.admin_name}}</p></li>
  55. <li><p>收件人:{{userName}}</p></li>
  56. <li><p>时 间:{{messageBox.sendtime}}</p></li>
  57. </ul>
  58. <div class="message-content">{{messageBox.atext}}</div>
  59. </el-row>
  60. </el-col>
  61. </div>
  62. </el-drawer>
  63. </template>
  64. <script>
  65. export default {
  66. name: "messageCenter",
  67. data() {
  68. return {
  69. drawer: false,
  70. switchMessageType: "unread",
  71. nomessage:true,
  72. userID:null,
  73. userName:null,
  74. //已读列表
  75. readList:[],
  76. //未读列表
  77. unreadList:[],
  78. //未读第一个
  79. unreadListOne:[],
  80. //未读数量
  81. unreadNum:null,
  82. // 详情
  83. messageBox:[],
  84. }
  85. },
  86. computed: {
  87. get_drawer() {
  88. return this.$store.getters.get_drawer;
  89. },
  90. },
  91. watch: {
  92. get_drawer(data) {
  93. console.log(data)
  94. this.drawer = data;
  95. this.userID = this.$store.getters.get_user_info.id;
  96. this.userName = this.$store.getters.get_user_info.user_name;
  97. this.readnotice();
  98. this.unreadnotice();
  99. },
  100. },
  101. methods: {
  102. handleClose() {
  103. this.$store.dispatch("SET_DRAWER", false);
  104. },
  105. switchMessage(num) {
  106. this.switchMessageType = num;
  107. },
  108. // 已读信息
  109. readnotice(){
  110. let str = "readnotice" + "customer-service" + "index" + this.time + "service";
  111. let obj = {
  112. headers: {
  113. "Content-Type": "application/x-www-form-urlencoded",
  114. apiToken: this.$md5(str),
  115. userToken: this.token
  116. },
  117. user_id: this.userID
  118. };
  119. this.post("api/service/index/readnotice", obj).then(res => {
  120. console.log(res)
  121. if(res.data.code === 1){
  122. console.log("已读",res.data.data)
  123. this.readList = res.data.data;
  124. }
  125. });
  126. },
  127. // 未读信息
  128. unreadnotice(){
  129. let str = "unreadnotice" + "customer-service" + "index" + this.time + "service";
  130. let obj = {
  131. headers: {
  132. "Content-Type": "application/x-www-form-urlencoded",
  133. apiToken: this.$md5(str),
  134. userToken: this.token
  135. },
  136. user_id: this.userID
  137. };
  138. this.post("api/service/index/unreadnotice", obj).then(res => {
  139. console.log(res)
  140. if(res.data.code === 1){
  141. console.log("未读",res.data.data)
  142. this.unreadList = res.data.data;
  143. this.unreadListOne = res.data.data[0];
  144. console.log(this.unreadListOne,'第一个')
  145. this.unreadNum = res.data.data.length;
  146. }
  147. });
  148. },
  149. // 点击显示当前详细内容
  150. toReading(item){
  151. console.log(item);
  152. this.nomessage = false;
  153. this.messageBox = item;
  154. }
  155. },
  156. }
  157. </script>
  158. <style lang="less" scoped>
  159. .left-list {
  160. border-right: 1px solid #D5E5FF;
  161. height: 100vh;
  162. }
  163. .tabs {
  164. display: flex;
  165. justify-content: space-around;
  166. height: 48px;
  167. line-height: 48px;
  168. border-bottom: 1px solid #D5E5FF;
  169. a {
  170. font-size: 14px;
  171. cursor: pointer;
  172. }
  173. a.active {
  174. color: #5399F5;
  175. border-bottom: 2px solid #5399F5;
  176. }
  177. }
  178. .message-list {
  179. margin: 0;
  180. /* 奇数背景色 */
  181. .list-item:nth-of-type(odd) {
  182. background: #F6F8FF;
  183. }
  184. /* 偶数背景色 */
  185. .list-item:nth-of-type(even) {
  186. background: #fff;
  187. }
  188. .list-item {
  189. padding: 10px 20px;
  190. p {
  191. color: #666;
  192. font-size: 14px;
  193. overflow: hidden;
  194. text-overflow:ellipsis;
  195. white-space: nowrap;
  196. }
  197. }
  198. .item-info {
  199. margin-bottom: 10px;
  200. display: flex;
  201. justify-content: space-between;
  202. span {
  203. font-size: 14px;
  204. color: #666;
  205. }
  206. span.time {
  207. color: #999;
  208. }
  209. }
  210. }
  211. .title {
  212. padding: 0 10px;
  213. height: 48px;
  214. line-height: 48px;
  215. border-bottom: 1px solid #D5E5FF;
  216. i {
  217. margin-top: 15px;
  218. font-size: 18px;
  219. cursor: pointer;
  220. float: right;
  221. }
  222. }
  223. .messageBox {
  224. padding: 15px 20px;
  225. li {
  226. margin: 10px 0;
  227. p {
  228. font-size: 14px;
  229. color: #999999;
  230. }
  231. }
  232. .message-content {
  233. margin-top: 20px;
  234. background: #F5F5F5;
  235. border: 1px solid #EEEEEE;
  236. padding: 20px;
  237. font-size: 14px;
  238. color: #666;
  239. line-height: 1.8;
  240. }
  241. }
  242. </style>
  243. <style>
  244. .left-list .el-badge__content.is-fixed {
  245. position: absolute;
  246. top: 12px !important;
  247. right: 10px !important;
  248. }
  249. .el-drawer__container {
  250. outline: none !important;
  251. }
  252. .el-drawer__header {
  253. padding: 0 !important;
  254. height: 10px !important;
  255. margin-bottom: 0 !important;
  256. }
  257. </style>