Преглед на файлове

Merge branch 'master' of http://git.cc-lotus.info/service-platform/web-website

wuhongyu преди 5 години
родител
ревизия
85a918ef88

+ 23 - 4
src/layout/enterprise/contextxx.vue

@@ -4,16 +4,18 @@
       <rooms :list="list" @toChat="toChat"></rooms>
     </template>
     <template v-else>
-      <chat :room="room" @toRoom="view = 'room'"></chat>
+      <chat :room="room" @toRoom="toRoom"></chat>
     </template>
   </div>
 </template>
 
 <script>
+import _ from 'lodash';
 import rooms from './parts/room.vue';
 import chat from './parts/chat.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions } = createNamespacedHelpers('personalroom');
+const { mapActions: personalChat } = createNamespacedHelpers('personalchat');
 export default {
   name: 'contextxx',
   props: {},
@@ -33,9 +35,13 @@ export default {
   },
   methods: {
     ...mapActions(['query', 'fetch']),
+    ...personalChat({ getChatList: 'query' }),
     async search() {
       let res = await this.query({ seller_id: this.user.uid });
-      if (this.$checkRes(res)) this.$set(this, `list`, res.data);
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.onMessage();
+      }
     },
     async toChat(data) {
       let res = await this.fetch(data.id);
@@ -44,13 +50,26 @@ export default {
         this.view = 'chat';
       }
     },
+    toRoom() {
+      this.view = 'room';
+      this.onMessage();
+    },
     channel() {
       this.$stomp({
         [`/exchange/chat_message/${this.user.uid}`]: this.onMessage,
       });
     },
-    onMessage(message) {
-      console.log(message);
+    async onMessage(message) {
+      let res = await this.getChatList({ status: 0, receiver_id: this.user.uid });
+      if (this.$checkRes(res)) {
+        let arr = this.list.map(i => {
+          i.needRead ? '' : (i.needRead = 0);
+          let findRes = res.data.filter(f => i.buyer_id == f.sender_id);
+          i.needRead = findRes.length || 0;
+          return i;
+        });
+        this.$set(this, `list`, arr);
+      }
     },
   },
   computed: {

+ 7 - 1
src/layout/enterprise/parts/chat.vue

@@ -52,12 +52,13 @@ export default {
     this.channel();
   },
   methods: {
-    ...personalChat(['create', 'query']),
+    ...personalChat(['create', 'query', 'update', 'isRead']),
     async search() {
       let res = await this.query({ personroom_id: this.room.id });
       if (this.$checkRes(res)) {
         this.$set(this, `talk`, res.data);
         this.turnBottom();
+        this.toAlreadyRead();
       }
     },
     async chatClick() {
@@ -103,6 +104,11 @@ export default {
         this.turnBottom();
       }
     },
+    async toAlreadyRead() {
+      let ids = this.talk.filter(f => f.status == 0 && f.receiver_id == this.user.uid);
+      ids = ids.map(i => i.id);
+      let res = await this.isRead({ ids, sender_id: this.room.buyer_id, receiver_id: this.user.uid, personroom_id: this.room.id });
+    },
   },
   watch: {
     room: {

+ 10 - 0
src/layout/enterprise/parts/room.vue

@@ -1,6 +1,16 @@
 <template>
   <div id="room">
     <el-table :data="list" border stripe :show-header="false" @row-click="toChat">
+      <el-table-column align="center">
+        <template v-slot="{ row }">
+          <template v-if="row.needRead == 0">
+            暂无未读消息
+          </template>
+          <template v-if="row.needRead > 0">
+            <span style="color:red">您有{{ row.needRead }}条未读消息 </span>
+          </template>
+        </template>
+      </el-table-column>
       <el-table-column prop="buyer_name" align="center"></el-table-column>
     </el-table>
   </div>

+ 1 - 1
src/store/index.js

@@ -17,7 +17,7 @@ import policieszhuanjia from './policieszhuanjia';
 import policiesjbxx from './policiesjbxx';
 import market from './market';
 import enterpriseproject from './enterpriseproject';
-import transaction from './transaction';
+import transaction from '@common/store/market/transaction';
 import marketproduct from './marketproduct';
 import markettype from './markettype';
 import tranaudit from './tranaudit';

+ 0 - 1
src/views/supermaket/supermarketdetail.vue

@@ -56,7 +56,6 @@ export default {
     ...mapSite(['showInfo']),
     ...mapEnterpriseproject({ list: 'query', fetch: 'fetch' }),
     ...transaction({ transactioncreate: 'create', transactionfetch: 'fetch' }),
-    ...transaction({ transactioncreate: 'create', transactionfetch: 'fetch' }),
     ...tranaudit({ tranauditcreate: 'create' }),
     // 查询站点信息
     async searchSite() {