messageCenter.vue 7.6 KB

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