Browse Source

立即入驻判断卖家状态及搜索热词调整

yangc 8 years ago
parent
commit
f8b5e99cbb
5 changed files with 90 additions and 14 deletions
  1. 24 5
      components/main/Search.vue
  2. 15 7
      components/provider/NewStore.vue
  3. 23 1
      components/provider/Suppliers.vue
  4. 14 0
      store/floor.js
  5. 14 1
      store/index.js

+ 24 - 5
components/main/Search.vue

@@ -37,12 +37,15 @@
     <div class="search-hot">
       <ul class="list-untyled">
         <li class="item item-first">热门搜索</li>
-        <li class="item" v-for="w in hotBrand">
+        <li class="item" v-for="w in hotBrand" v-if="ifFloorsHotSearchInValid">
           <nuxt-link :to="'/product/brand/' + w.uuid" target="_blank">{{ w.nameEn }}</nuxt-link>
         </li>
-        <li class="item" v-for="w in hotDevice">
+        <li class="item" v-for="w in hotDevice" v-if="ifFloorsHotSearchInValid">
           <nuxt-link :to="'/product/component/' + w.uuid" target="_blank">{{ w.code }}</nuxt-link>
         </li>
+        <li class="item" v-if="!ifFloorsHotSearchInValid && index > 0" v-for="(w, index) in hotSearchData.items">
+          <a :href="w.hrefUrl" target="_blank">{{w.body}}</a>
+        </li>
       </ul>
     </div>
   </div>
@@ -77,6 +80,22 @@
           this.associate.show &&
           this.similarKeywords.data &&
           (this.similarKeywords.data.brand || this.similarKeywords.data.component || this.similarKeywords.data.kind)
+      },
+      hotSearchData () {
+        let list = this.$store.state.floor.list_v3.data
+        let obj = {}
+        if (list && list.length > 0) {
+          obj = list.find(item => item.floorNumber === 2) || {}
+        }
+        return obj
+      },
+      ifFloorsHotSearchInValid () {
+        let obj = this.hotSearchData
+        if (obj.items && obj.items.length) {
+          let result = obj.items.find(item => !item.body || item.body === '') || true
+          return result !== true
+        }
+        return true
       }
     },
     watch: {
@@ -163,8 +182,6 @@
     },
     created () {
       this.$store.dispatch('resetSearchKeywords')
-      this.$store.dispatch('loadHotSearchDevice')
-      this.$store.dispatch('loadHotSearchBrand')
     }
   }
 </script>
@@ -208,7 +225,9 @@
       margin-top:5px;
       .item {
         display: inline-block;
-        width:22%;
+        max-width:22%;
+        text-align: center;
+        vertical-align: middle;
         font-size: $font-size-small;
         padding-right: $pad;
         a{

+ 15 - 7
components/provider/NewStore.vue

@@ -50,18 +50,26 @@ export default {
     },
     storeCount () {
       return this.$store.state.provider.storeCms.storeCount.data
+    },
+    enterprise () {
+      let ens = this.user.data.enterprises
+      if (ens && ens.length) {
+        return ens.find(item => item.current) || {enName: '个人账户'}
+      } else {
+        return {enName: '个人账户'}
+      }
     }
   },
   methods: {
     goStoreApply: function () {
-      if (!this.user.logged) {
-        this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
-          if (response.data) {
-            window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
-          }
-        })
+      if (this.user.logged) {
+        if (this.enterprise && this.enterprise.isVendor === 313) {
+          window.location.href = '/vendor#/store-apply'
+        } else {
+          this.$router.push('/register-saler')
+        }
       } else {
-        window.location.href = '/vendor#/store-apply'
+        this.$router.push('/auth/login')
       }
     }
   }

+ 23 - 1
components/provider/Suppliers.vue

@@ -15,7 +15,7 @@
         </td>
         <td width="150" style="vertical-align: middle"><span>入驻商家:</span><span class="text-message">{{stores ? stores.totalElements : 0}}</span><span>家</span></td>
         <td width="150" style="vertical-align: middle;">
-          <a href="/vendor#/store-apply" style="width: 100px; height: 30px; display: inline-block;"><button class="btn btn-primary" style="margin-left: 6px;">立即入驻</button></a>
+          <a @click="goStoreApply" style="width: 100px; height: 30px; display: inline-block;"><button class="btn btn-primary" style="margin-left: 6px;">立即入驻</button></a>
         </td>
       </tr>
       </thead>
@@ -73,6 +73,17 @@ export default {
   computed: {
     stores () {
       return this.$store.state.provider.stores.storeList.data
+    },
+    user () {
+      return this.$store.state.option.user
+    },
+    enterprise () {
+      let ens = this.user.data.enterprises
+      if (ens && ens.length) {
+        return ens.find(item => item.current) || {enName: '个人账户'}
+      } else {
+        return {enName: '个人账户'}
+      }
     }
   },
   methods: {
@@ -108,6 +119,17 @@ export default {
       this.pageParams.keyword = this.keyword === '' ? null : this.keyword
 
       this.pageCommodity(this.pageParams)
+    },
+    goStoreApply: function () {
+      if (this.user.logged) {
+        if (this.enterprise && this.enterprise.isVendor === 313) {
+          window.location.href = '/vendor#/store-apply'
+        } else {
+          this.$router.push('/register-saler')
+        }
+      } else {
+        this.$router.push('/auth/login')
+      }
     }
   }
 }

+ 14 - 0
store/floor.js

@@ -2,6 +2,10 @@ export const state = () => ({
   list: {
     fetching: false,
     data: []
+  },
+  list_v3: {
+    fetching: false,
+    data: []
   }
 })
 export const mutations = {
@@ -14,5 +18,15 @@ export const mutations = {
   GET_LIST_SUCCESS (state, result) {
     state.list.fetching = false
     state.list.data = result
+  },
+  REQUEST_NEWLIST (state) {
+    state.list_v3.fetching = true
+  },
+  GET_NEWLIST_FAILURE (state) {
+    state.list_v3.fetching = false
+  },
+  GET_NEWLIST_SUCCESS (state, result) {
+    state.list_v3.fetching = false
+    state.list_v3.data = result
   }
 }

+ 14 - 1
store/index.js

@@ -41,7 +41,10 @@ export const actions = {
     return Promise.all([
       // 全局数据
       store.dispatch('loadUserInfo'),
-      store.dispatch('loadProductCounts', { _status: 'actived' })
+      store.dispatch('loadProductCounts', { _status: 'actived' }),
+      store.dispatch('loadHotSearchDevice'),
+      store.dispatch('loadHotSearchBrand'),
+      store.dispatch('loadNewFloors')
     ])
   },
   // 获取用户信息
@@ -81,6 +84,16 @@ export const actions = {
         commit('carousel/GET_BANNER_FAILURE', err)
       })
   },
+  // 获取新楼层配置
+  loadNewFloors ({ commit }) {
+    commit('floor/REQUEST_NEWLIST')
+    return axios.get('/api/floors/home-v3')
+      .then(response => {
+        commit('floor/GET_NEWLIST_SUCCESS', response.data)
+      }, err => {
+        commit('floor/GET_NEWLIST_FAILURE', err)
+      })
+  },
   // 获取子器件类目
   loadProductKinds ({ commit }, params = {}) {
     let id = params.id