|
|
@@ -0,0 +1,147 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <nav-bar @click-left="$router.go(-1)" title="消息中心">
|
|
|
+ <div slot="right">全部已读</div>
|
|
|
+ </nav-bar>
|
|
|
+ <div class="list">
|
|
|
+ <div class="conversation-item" v-for="item in conversations" :key="item.sessionId" @click="detail(item)">
|
|
|
+ <img class="icon" :src="item.icon" />
|
|
|
+ <div class="info">
|
|
|
+ <div class="title">
|
|
|
+ <div class="text">{{ item.title }}</div>
|
|
|
+ <div class="time" v-if="item.relativeTime">{{ item.relativeTime }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="msg" v-if="item.type === 'PUBLISH' || item.type === 'DOCKING' || item.type === 'SYS'">
|
|
|
+ {{ item.lastMessage }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="dot" v-if="item.unread > 0 && (item.type === 'LIKE' || item.type === 'COMMENT')"></div>
|
|
|
+ <div class="badge" :class="{ lg: item.unread > 9 }" v-else-if="item.unread > 0">
|
|
|
+ {{ Math.min(item.unread, 99) }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import dayjs from 'dayjs';
|
|
|
+import relativeTime from 'dayjs/plugin/relativeTime';
|
|
|
+import zh from 'dayjs/locale/zh-cn';
|
|
|
+dayjs.locale('zh-cn');
|
|
|
+dayjs.extend(relativeTime);
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ conversations: []
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getData();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getData() {
|
|
|
+ this.$http.get('/conversation/my').then(res => {
|
|
|
+ res.forEach(i => {
|
|
|
+ if (i.lastUpdate) {
|
|
|
+ i.relativeTime = dayjs().to(dayjs(i.lastUpdate, 'YYYY-MM-DD HH:mm:ss'));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.conversations = res;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ detail(item) {
|
|
|
+ this.$http.get('/message/readAll', {
|
|
|
+ sessionId: item.sessionId
|
|
|
+ });
|
|
|
+ this.$set(item, 'unread', 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="less" scoped>
|
|
|
+/deep/ .nav-bar-right {
|
|
|
+ word-break: keep-all;
|
|
|
+ font-size: 14px;
|
|
|
+ color: @text3;
|
|
|
+ &:active {
|
|
|
+ color: fade(@text3, 60%);
|
|
|
+ }
|
|
|
+}
|
|
|
+.conversation-item {
|
|
|
+ .flex();
|
|
|
+ height: 90px;
|
|
|
+ position: relative;
|
|
|
+ padding: 0 16px;
|
|
|
+ &:active {
|
|
|
+ background: shade(white, 5%);
|
|
|
+ }
|
|
|
+ &::after {
|
|
|
+ .setBottomLine();
|
|
|
+ left: 16px;
|
|
|
+ right: 16px;
|
|
|
+ }
|
|
|
+ .icon {
|
|
|
+ width: 48px;
|
|
|
+ height: 48px;
|
|
|
+ min-width: 48px;
|
|
|
+ border-radius: 24px;
|
|
|
+ object-fit: cover;
|
|
|
+ }
|
|
|
+ .info {
|
|
|
+ .flex-col();
|
|
|
+ margin-left: 10px;
|
|
|
+ flex-basis: 0;
|
|
|
+ flex-grow: 1;
|
|
|
+ .title {
|
|
|
+ font-size: 16px;
|
|
|
+ color: black;
|
|
|
+ line-height: 24px;
|
|
|
+ .flex();
|
|
|
+ .text {
|
|
|
+ flex-basis: 0;
|
|
|
+ flex-grow: 1;
|
|
|
+ .ellipsisLn(1);
|
|
|
+ }
|
|
|
+ .time {
|
|
|
+ margin-left: 8px;
|
|
|
+ color: @text4;
|
|
|
+ font-size: 13px;
|
|
|
+ word-break: keep-all;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .msg {
|
|
|
+ .ellipsis();
|
|
|
+ font-size: 13px;
|
|
|
+ color: @text3;
|
|
|
+ line-height: 24px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .badge {
|
|
|
+ position: absolute;
|
|
|
+ bottom: 24px;
|
|
|
+ right: 16px;
|
|
|
+ height: 18px;
|
|
|
+ .flex();
|
|
|
+ justify-content: center;
|
|
|
+ background: @prim;
|
|
|
+ color: white;
|
|
|
+ font-size: 12px;
|
|
|
+ border-radius: 9px;
|
|
|
+ width: 18px;
|
|
|
+ &.lg {
|
|
|
+ width: 24px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .dot {
|
|
|
+ width: 8px;
|
|
|
+ height: 8px;
|
|
|
+ border-radius: 4px;
|
|
|
+ position: absolute;
|
|
|
+ right: 16px;
|
|
|
+ bottom: 0;
|
|
|
+ top: 0;
|
|
|
+ margin: auto;
|
|
|
+ background: @prim;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|