瀏覽代碼

Merge branch 'feature/im-0915'

# Conflicts:
#	components/default/RightBar.vue
wangdy 8 年之前
父節點
當前提交
063e7281b2
共有 5 個文件被更改,包括 126 次插入20 次删除
  1. 19 19
      components/default/RightBar.vue
  2. 87 0
      components/store/common/StoreHeader.vue
  3. 1 1
      nuxt.config.js
  4. 6 0
      store/chat.js
  5. 13 0
      store/chat/tab.js

+ 19 - 19
components/default/RightBar.vue

@@ -3,7 +3,7 @@
     <div class="right-bar">
       <ul class="right-bar-center">
         <li class="right-bar-item" @mouseenter="loadCarCount()">
-          <a @click="goCart" class="title">
+          <a @click="goCart" class="title" target="_blank">
             <i class="iconfont icon-shopping-cart icon-xlg"></i>
           </a>
           <div class="sidebar-menu"><a @click="goCart" title="我的购物车" target="_blank">我的购物车<em><span>(<span v-text="cartCount.count || 0"></span>)</span></em></a></div>
@@ -26,14 +26,14 @@
             <p>周一至周五 9:00-18:00</p>
           </div>
         </li>
-        <!--<li class="right-bar-item contact-menu">-->
-          <!--<a href="javascript:void(0)" class="title" @click="goWebChat">-->
-            <!--<i class="fa fa-comments-o" aria-hidden="true" style="color: #FFFFFF;">-->
-            <!--</i>-->
-            <!--<i class="remind-point" v-if="user.logged && chatCount>0"></i>-->
-          <!--</a>-->
-          <!--<div class="sidebar-menu" title="优软互联"><a @click="goWebChat">优软互联<span v-if="user.logged">({{chatCount}})</span></a></div>-->
-        <!--</li>-->
+        <li class="right-bar-item contact-menu">
+          <a href="javascript:void(0)" class="title" @click="goWebChat">
+            <i class="fa fa-comments-o" aria-hidden="true" style="color: #FFFFFF;">
+            </i>
+            <i class="remind-point" v-if="user.logged && chatCount>0"></i>
+          </a>
+          <div class="sidebar-menu" title="优软互联"><a @click="goWebChat">优软互联<span v-if="user.logged">({{chatCount}})</span></a></div>
+        </li>
       </ul>
       <ul class="right-bar-bottom">
         <li class="right-bar-item" @mouseenter="loadHistorys()">
@@ -113,15 +113,15 @@
         return this.$store.state.chat.tab.tab.data
       }
     },
-//    mounted () {
-//      this.$nextTick(() => {
-//        this.getChatCount()
-//        // 刷新统计信息
-//        setInterval(() => {
-//          this.getChatCount()
-//        }, 10000)
-//      })
-//    },
+    mounted () {
+      this.$nextTick(() => {
+        this.getChatCount()
+        // 刷新统计信息
+        setInterval(() => {
+          this.getChatCount()
+        }, 10000)
+      })
+    },
     methods: {
       listenPage: function (p) {
         this.page = p
@@ -236,7 +236,7 @@
         this.$http.post('http://im.ubtob.com/api/chat/infos?condition=chat_info', obj)
           .then(response => {
             if (response.data.success) {
-              newTab.location.href = 'http://192.168.253.121:20220/chat/visit?gid=' + response.data.content
+              newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + response.data.content
             }
           })
       },

+ 87 - 0
components/store/common/StoreHeader.vue

@@ -21,6 +21,10 @@
                   <span v-else-if="storeInfo.type == 'AGENCY'">&nbsp;<img src="/images/store/icon/icon-agent.png"/></span>
                   <span v-else-if="storeInfo.type == 'DISTRIBUTION'">&nbsp;<img src="/images/store/icon/icon-distribution.png"/></span>
                   <span v-else-if="storeInfo.type == 'CONSIGNMENT'">&nbsp;<img src="/images/store/icon/consignment.png"/></span>
+                  <span class="link-seller">
+                    <img src="/images/all/songguo.png">
+							      <a @click="goWebChat()" class="contact_btn">联系卖家</a>
+                  </span>
                 </div>
               </div>
               <div class="clearfix"></div>
@@ -87,6 +91,9 @@ export default {
     },
     isFocus () {
       return this.$store.state.shop.storeInfo.focusList.data
+    },
+    tab () {
+      return this.$store.state.chat.tab.tab.data
     }
   },
   methods: {
@@ -108,6 +115,68 @@ export default {
         this.$store.dispatch('shop/StoreFocus', {storeName: name, storeid: id})
         this.isFocus = true
       }
+    },
+    goWebChat: function () {
+      if (!this.user.logged) {
+        this.$http.get('/login/page').then(response => {
+          if (response.data) {
+            this.$router.push('/auth/login')
+          }
+        })
+      } else {
+        // 获得窗口的垂直位置
+        let iTop = (window.screen.availHeight - 30 - 780) / 2
+        // 获得窗口的水平位置
+        let iLeft = (window.screen.availWidth - 10 - 1030) / 2
+        if (this.tab.close) {
+          this.tab.close()
+        }
+        let newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
+        newTab.close()
+        newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
+        this.$store.dispatch('chat/setChatTab', {tab: newTab})
+        this.$http.get('/basic/enterprise/' + this.storeInfo.enUU + '/info')
+          .then(response => {
+            let obj = {}
+            obj.userPhone = this.user.data.userTel
+            obj.userType = 'ENTERPRISE'
+            this.user.data.enterprises.forEach(function (item, index) {
+              if (item.current) {
+                obj.enUU = item.uu
+                obj.enterprise = {enUU: item.uu, name: item.enName}
+              }
+            })
+            obj.otherEnUU = response.data.uu
+            obj.otherUserType = 'STORE'
+            obj.otherEnterprise = {enUU: response.data.uu, name: response.data.enName}
+            obj.type = 'CHAT'
+            if (!(/^1\d{10}$/).test(response.data.enTel)) {
+              this.$http.get('/basic/enterprise/' + response.data.uu + '/admin').then(response => {
+                console.log(response)
+                obj.toPhone = response.data.userTel
+                console.log(obj)
+                this.openWebChat(newTab, obj)
+              }, err => {
+                console.log(err)
+                this.$message.error('暂无卖家管理员手机号!')
+              })
+            } else {
+              obj.toPhone = response.data.enTel
+              console.log(obj)
+              this.openWebChat(newTab, obj)
+            }
+          }, err => {
+            console.log(err)
+          })
+      }
+    },
+    openWebChat: function (newTab, obj) {
+      this.$http.post('http://im.ubtob.com/api/chat/infos?condition=chat_info', obj)
+        .then(response => {
+          if (response.data.success) {
+            newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + response.data.content
+          }
+        })
     }
   }
 }
@@ -388,4 +457,22 @@ export default {
 		position: relative;
 		top: -9px;
 	}
+  .icon-style >span {
+    margin-right: 5px;
+  }
+  .icon-style .link-seller {
+    cursor: pointer;
+  }
+  .icon-style .link-seller img {
+    top: -2px;
+  }
+  .icon-style .link-seller a {
+    font-size: 12px;
+    color: #fff;
+    line-height: 20px;
+    height: 20px;
+    padding: 0 7px;
+    background: #ef7f03;
+    border-radius: 2px;
+  }
 </style>

+ 1 - 1
nuxt.config.js

@@ -1,6 +1,6 @@
 const path = require('path')
 const isProdMode = Object.is(process.env.NODE_ENV, 'production')
-const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://10.10.100.107:8081/platform-b2c/' : 'http://192.168.253.60:9090/platform-b2c/')
+const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://10.10.100.107:8081/platform-b2c/' : 'http://192.168.253.121:8887/b2c-im/')
 
 module.exports = {
   router: {

+ 6 - 0
store/chat.js

@@ -0,0 +1,6 @@
+export const actions = {
+  setChatTab ({ commit }, params = {}) {
+    console.log(params)
+    commit('tab/GET_TABLE_SUCCESS', params.tab)
+  }
+}

+ 13 - 0
store/chat/tab.js

@@ -0,0 +1,13 @@
+export const state = () => ({
+  tab: {
+    fetching: false,
+    data: []
+  }
+})
+
+export const mutations = {
+  GET_TABLE_SUCCESS (state, result) {
+    state.tab.fetching = false
+    state.tab.data = result
+  }
+}