Преглед изворни кода

新增优软互联登录状态下显示聊天消息数量

yangc пре 8 година
родитељ
комит
eba9ebee20
3 измењених фајлова са 28 додато и 7 уклоњено
  1. 1 0
      components/common/buyOrCar/buyComponent.vue
  2. 26 6
      components/default/RightBar.vue
  3. 1 1
      nuxt.config.js

+ 1 - 0
components/common/buyOrCar/buyComponent.vue

@@ -20,6 +20,7 @@
           })
         } else {
           if (this.item) {
+            console.log(this.item)
             // this.$emit('buyAction', [{uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty}])
             if (isBuy) {
               // this.$store.dispatch('user/getBuyInfo', [{uuid: item.uuid, batchCode: item.batchCode, number: item.minBuyQty}])

+ 26 - 6
components/default/RightBar.vue

@@ -3,10 +3,10 @@
     <div class="right-bar">
       <ul class="right-bar-center">
         <li class="right-bar-item">
-          <a href="/user#/cart" class="title" target="_blank">
+          <a @click="goCart" class="title" target="_blank">
             <i class="iconfont icon-shopping-cart icon-xlg"></i>
           </a>
-          <div class="sidebar-menu"><a href="/user#/cart" title="我的购物车" target="_blank">我的购物车<em><span>(<span v-text="cartCount.count || 0"></span>)</span></em></a></div>
+          <div class="sidebar-menu"><a @click="goCart" title="我的购物车" target="_blank">我的购物车<em><span>(<span v-text="cartCount.count || 0"></span>)</span></em></a></div>
         </li>
         <li class="right-bar-item">
           <el-button type="text" @click="dialogVisible = true">
@@ -29,11 +29,11 @@
           </div>
         </li>
         <li class="right-bar-item contact-menu">
-          <a href="javascript:void(0)" class="title" @click="goWebChat">
+          <a href="javascript:void(0)" class="title" @click="goWebChat" @mouseenter="getChatCount">
             <i class="fa fa-comments-o" aria-hidden="true" style="font-size: 18px;color: #FFFFFF;">
             </i>
           </a>
-          <div class="sidebar-menu" title="优软互联"><a @click="goWebChat">优软互联</a><em><!-- ngIf: userInfo --></em></div>
+          <div class="sidebar-menu" title="优软互联"><a @click="goWebChat">优软互联<span v-if="user.logged">({{chatCount}})</span></a></div>
         </li>
       </ul>
       <ul class="right-bar-bottom">
@@ -86,7 +86,8 @@
         dialogImageUrl: '',
         page: 1,
         count: 3,
-        currentPage: 1
+        currentPage: 1,
+        chatCount: -1
       }
     },
     created () {
@@ -152,8 +153,19 @@
         this.$store.dispatch('user/deleteHistory', {id: id})
         this.loadHistorys()
       },
+      goCart: function () {
+        if (!this.user.logged) {
+          this.$http.get('/login/page').then(response => {
+            if (response.data) {
+              this.$router.push('/auth/login')
+            }
+          })
+        } else {
+          window.location.href = '/user#/cart'
+        }
+      },
       goWebChat: function () {
-        if (!this.$store.state.option.user.logged) {
+        if (!this.user.logged) {
           this.$http.get('/login/page').then(response => {
             if (response.data) {
               this.$router.push('/auth/login')
@@ -182,6 +194,14 @@
               console.log(err)
             })
         }
+      },
+      getChatCount: function () {
+        if (this.user.logged) {
+          axios.get('http://im.ubtob.com/api/chat/message', {params: {enUU: this.enterprise.uu, operate: 'count_unread', phone: this.user.data.userTel}})
+            .then(response => {
+              this.chatCount = response.data.count
+            })
+        }
       }
     }
   }

+ 1 - 1
nuxt.config.js

@@ -109,5 +109,5 @@ module.exports = {
     ssr: false
   }],
   /* TODO 暂时代理到商城测试版,之后再做出调整 */
-  proxyTable: ['/api/**', '/search/**', '/user/**', '/login/**', '/logout/**', '/static/**', '/vendor**', '/user**', '/trade/**', '/recommendation/**', '/store-service/**', '/basic/**', '/logout**', '/operation/**', '/help**', '/product**', '/platform-b2c**']
+  proxyTable: ['/api/**', '/search/**', '/user/**', '/login/**', '/logout/**', '/static/**', '/vendor**', '/user**', '/trade/**', '/recommendation/**', '/store-service/**', '/basic/**', '/logout**', '/operation/**', '/help**', '/product**', '/platform-b2c**', '/store**']
 }