lrf 2 年之前
父节点
当前提交
c184c6eb77
共有 2 个文件被更改,包括 31 次插入16 次删除
  1. 5 10
      src/layout/header/notice.vue
  2. 26 6
      src/views/index.vue

+ 5 - 10
src/layout/header/notice.vue

@@ -15,8 +15,7 @@ export default {
   components: {},
   data: function () {
     return {
-      notice: [],
-      total: 0,
+      notice: 0,
     };
   },
   computed: {
@@ -36,24 +35,20 @@ export default {
     async getNotRead() {
       const res = await this.cnr(this.user.shop._id);
       if (this.$checkRes(res)) {
-        console.log(res.data);
         this.$set(this, `notice`, res.data);
-        // this.$set(this, `total`, res.data.length);
       }
     },
     channel() {
-      if (!this.user.lab_id) return;
+      const shop_id = _.get(this.user, 'shop._id');
+      if (!shop_id) return;
       this.$stomp({
-        [`/exchange/lab-notice/${this.user.lab_id}`]: this.onMessage,
-      });
-      this.$stomp({
-        [`/exchange/lab-notice-fresh/${this.user.lab_id}`]: this.getNotRead,
+        [`/exchange/shopMsg/${shop_id}`]: this.onMessage,
       });
     },
     onMessage(message) {
       this.$notify.info({
         title: '新消息',
-        message: '您有新的消息,请注意查收!',
+        message: '您有新的消息,请注意及时处理!',
         position: 'bottom-right',
       });
       this.getNotRead();

+ 26 - 6
src/views/index.vue

@@ -62,16 +62,24 @@
             </el-col>
           </el-col>
           <el-col :span="11">
-            <el-card class="box-card" @click.native="toUrl('sMarkOrder')"><card-1 :list="data.sMarkOrder"></card-1></el-card>
+            <el-card class="box-card" @click.native="toUrl('sMarkOrder')">
+              <card-1 :list="data.sMarkOrder"></card-1>
+            </el-card>
           </el-col>
           <el-col :span="11">
-            <el-card class="box-card" @click.native="toUrl('sAfterSale')"><card-2 :list="data.sAfterSale"></card-2></el-card>
+            <el-card class="box-card" @click.native="toUrl('sAfterSale')">
+              <card-2 :list="data.sAfterSale"></card-2>
+            </el-card>
           </el-col>
           <el-col :span="11" style="display: none">
-            <el-card class="box-card"><card-3></card-3> </el-card>
+            <el-card class="box-card">
+              <card-3></card-3>
+            </el-card>
           </el-col>
           <el-col :span="11" style="display: none">
-            <el-card class="box-card"><card-4></card-4></el-card>
+            <el-card class="box-card">
+              <card-4></card-4>
+            </el-card>
           </el-col>
         </el-col>
       </el-col>
@@ -80,7 +88,7 @@
 </template>
 
 <script>
-import * as echarts from 'echarts';
+const _ = require('lodash');
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions } = createNamespacedHelpers('todo');
 
@@ -101,11 +109,23 @@ export default {
   computed: {
     ...mapState(['user']),
   },
-  mounted() {},
+  mounted() {
+    this.initMsgConn();
+  },
   async created() {
     await this.search();
   },
   methods: {
+    initMsgConn() {
+      const shop_id = _.get(this.user, 'shop._id');
+      if (!shop_id) return;
+      this.$stomp({
+        [`/exchange/shopMsg/${shop_id}`]: this.onMessage,
+      });
+    },
+    onMessage(data) {
+      console.log(_.get(data, 'body'));
+    },
     ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
     async search({ skip = 0, limit = this.$limit, ...info } = {}) {
       info.shop = this.user.shop.id;