xiongzhu 4 年之前
父節點
當前提交
70d4fe035c
共有 7 個文件被更改,包括 175 次插入21 次删除
  1. 1 0
      package.json
  2. 6 0
      src/router.js
  3. 147 0
      src/views/conversations.vue
  4. 8 10
      src/views/leaveMessage.vue
  5. 2 5
      src/views/snd/sndDetail.vue
  6. 6 6
      src/views/snd/subSnd.js
  7. 5 0
      yarn.lock

+ 1 - 0
package.json

@@ -24,6 +24,7 @@
     "babel-plugin-import": "^1.13.3",
     "cordova-plugin-android-notch": "^1.0.3",
     "core-js": "^2.6.5",
+    "dayjs": "^1.10.4",
     "ip": "^1.1.5",
     "photoswipe": "^4.1.3",
     "probe-image-size": "^6.0.0",

+ 6 - 0
src/router.js

@@ -246,6 +246,12 @@ const router = new Router({
             name: 'search',
             component: () => import(/* webpackChunkName: "search" */ '@/views/search.vue'),
             meta: { statusBar: 'dark' }
+        },
+        {
+            path: '/conversations',
+            name: 'conversations',
+            component: () => import(/* webpackChunkName: "conversations" */ '@/views/conversations.vue'),
+            meta: { statusBar: 'dark' }
         }
     ]
 });

+ 147 - 0
src/views/conversations.vue

@@ -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>

+ 8 - 10
src/views/leaveMessage.vue

@@ -45,16 +45,14 @@ export default {
             }
             this.$toast.loading();
             this.$http
-                .post(
-                    '/message/save',
-                    {
-                        orgName: this.userInfo.orgName,
-                        userName: this.userInfo.contactName,
-                        userPhone: this.userInfo.contactPhone,
-                        description: this.content
-                    },
-                    { body: 'json' }
-                )
+                .post('/conversation/create', {
+                    sndId: this.$route.query.id,
+                    orgName: this.userInfo.orgName,
+                    contactName: this.userInfo.contactName,
+                    contactPhone: this.userInfo.contactPhone,
+                    email: this.userInfo.email,
+                    content: this.content
+                })
                 .then(res => {
                     this.$toast.clear();
                     this.showDialog = true;

+ 2 - 5
src/views/snd/sndDetail.vue

@@ -68,7 +68,7 @@ import { mapState } from 'vuex';
 export default {
     data() {
         return {
-            detail: { resSnDPropertyList: [] },
+            detail: { resSnDPropertyList: [], orgInfo: {} },
             type: '',
             collected: false
         };
@@ -76,10 +76,7 @@ export default {
     created() {
         this.type = this.$route.query.type;
         this.$http.get(`resourceSupplyAndDemand/get/${this.$route.query.id}`).then(res => {
-            this.detail = {
-                ...res.resourceSupplyAndDemand,
-                orgInfo: res.orgInfo
-            };
+            this.detail = res;
         });
         this.$http.get(`/collect/get/${this.$route.query.id}`).then(res => {
             this.collected = res;

+ 6 - 6
src/views/snd/subSnd.js

@@ -74,14 +74,14 @@ export default {
             if (this.sort) {
                 data.sort = this.sort;
             }
-            data.query.resSnDPropertyList = this.filters
+            this.filters
                 .filter(i => i.value > -1)
-                .map(i => {
-                    return `name:${i.name},value:${i.text}`;
-                })
-                .join(';');
+                .forEach(i => {
+                    data.query.property = data.query.property || {};
+                    data.query.property[i.name] = i.text;
+                });
             this.$http
-                .get('/resourceSupplyAndDemand/all', data)
+                .post('/resourceSupplyAndDemand/allDTO', data, { body: 'json' })
                 .then(res => {
                     if (res.first) {
                         this.list = [];

+ 5 - 0
yarn.lock

@@ -2761,6 +2761,11 @@ date-fns@^1.27.2:
   resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c"
   integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==
 
+dayjs@^1.10.4:
+  version "1.10.4"
+  resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.4.tgz#8e544a9b8683f61783f570980a8a80eaf54ab1e2"
+  integrity sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw==
+
 de-indent@^1.0.2:
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"