YY 2 лет назад
Родитель
Сommit
43b2ef3ac8
3 измененных файлов с 23 добавлено и 16 удалено
  1. 9 7
      src/layout/Header.vue
  2. 10 9
      src/layout/header/notice.vue
  3. 4 0
      src/store/module/shop/shopNotice.js

+ 9 - 7
src/layout/Header.vue

@@ -15,10 +15,10 @@
             <span>{{ siteInfo.zhTitle }}-管理中心</span>
           </el-col>
           <el-col :span="16" class="right">
-            <!-- <notice v-if="user.lab_id"></notice> -->
-            <el-badge :value="1000" class="item" type="danger">
+            <notice></notice>
+            <!-- <el-badge :value="1000" class="item" type="danger">
               <i class="el-icon-message-solid" @click="toJump()"></i>
-            </el-badge>
+            </el-badge> -->
             <i class="el-icon-refresh" v-if="$dev_env" @click="toRefresh()"></i>
             <i class="el-icon-user-solid"></i>
             <span>{{ user.name || '游客' }}</span>
@@ -39,7 +39,9 @@ import bus from './bus';
 export default {
   name: 'Header',
   props: {},
-  components: {},
+  components: {
+    notice: () => import('./header/notice.vue'),
+  },
   data: function () {
     return { collapse: false, siteInfo: siteInfo, options: {} };
   },
@@ -65,9 +67,9 @@ export default {
     toRefresh() {
       this.$emit('refresh');
     },
-    toJump() {
-      this.$router.push({ path: `/selfShop/notice` });
-    },
+    // toJump() {
+    //   this.$router.push({ path: `/selfShop/notice` });
+    // },
   },
   computed: {
     ...mapState(['user']),

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

@@ -1,6 +1,6 @@
 <template>
   <span>
-    <el-badge :value="total" class="notice__badge">
+    <el-badge :value="notice" class="notice__badge">
       <i class="el-icon-message-solid notice__icon" @click="toNotice()"></i>
     </el-badge>
   </span>
@@ -8,14 +8,14 @@
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions } = createNamespacedHelpers('notice');
+const { mapActions } = createNamespacedHelpers('shopNotice');
 export default {
   name: 'notice',
   props: {},
   components: {},
-  data: function() {
+  data: function () {
     return {
-      list: [],
+      notice: [],
       total: 0,
     };
   },
@@ -29,15 +29,16 @@ export default {
     this.channel();
   },
   methods: {
-    ...mapActions(['notRead']),
+    ...mapActions(['cnr']),
     toNotice() {
-      this.$router.push('/system/notice/view');
+      this.$router.push({ path: `/selfShop/notice` });
     },
     async getNotRead() {
-      const res = await this.notRead({ lab_id: this.user.lab_id });
+      const res = await this.cnr(this.user.shop._id);
       if (this.$checkRes(res)) {
-        this.$set(this, `list`, res.data);
-        this.$set(this, `total`, res.data.length);
+        console.log(res.data);
+        this.$set(this, `notice`, res.data);
+        // this.$set(this, `total`, res.data.length);
       }
     },
     channel() {

+ 4 - 0
src/store/module/shop/shopNotice.js

@@ -30,6 +30,10 @@ const actions = {
     const res = await this.$axios.$post(`${api.url}/rtas`, payload);
     return res;
   },
+  async cnr({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.url}/cnr/${payload}`);
+    return res;
+  },
   async fetch({ commit }, payload) {
     const res = await this.$axios.$get(`${api.url}/${payload}`);
     return res;