wangcz 7 жил өмнө
parent
commit
80258e2a4d

+ 4 - 10
components/main/Search.vue

@@ -65,11 +65,8 @@
     <div class="search-hot" v-if="SelectItem">
       <ul class="list-untyled">
         <li class="item item-first">热门搜索</li>
-        <li class="item" v-for="w in hotBrand" v-if="ifFloorsHotSearchInValid">
-          <nuxt-link :to="`/search?w=${w.nameEn}&type=brand`">{{ w.nameEn }}</nuxt-link>
-        </li>
-        <li class="item" v-for="w in hotDevice" v-if="ifFloorsHotSearchInValid">
-          <nuxt-link :to="`/search?w=${w.code}&type=component`">{{ w.code }}</nuxt-link>
+        <li class="item" v-for="w in hotDeviceBrand" v-if="ifFloorsHotSearchInValid">
+          <nuxt-link :to="{path: w.detailsLink}">{{ w.title }}</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>
@@ -107,11 +104,8 @@
       }
     },
     computed: {
-      hotDevice () {
-        return this.$store.state.hotSearchDevice.hot.data
-      },
-      hotBrand () {
-        return this.$store.state.hotSearchBrand.hot.data
+      hotDeviceBrand () {
+        return this.$store.state.hotSearch.hot.data
       },
       similarKeywords () {
         let list = []

+ 0 - 0
store/hotSearchBrand.js → store/hotSearch.js


+ 0 - 18
store/hotSearchDevice.js

@@ -1,18 +0,0 @@
-export const state = () => ({
-  hot: {
-    fetching: false,
-    data: []
-  }
-})
-export const mutations = {
-  REQUEST_HOT (state) {
-    state.hot.fetching = true
-  },
-  GET_HOT_FAILURE (state) {
-    state.hot.fetching = false
-  },
-  GET_HOT_SUCCESS (state, result) {
-    state.hot.fetching = false
-    state.hot.data = result
-  }
-}

+ 12 - 23
store/index.js

@@ -60,8 +60,7 @@ export const actions = {
     return Promise.all([
       // 全局数据
       store.dispatch('loadUserInfo'),
-      store.dispatch('loadHotSearchDevice'),
-      store.dispatch('loadHotSearchBrand')
+      store.dispatch('loadHotSearch')
     ])
   },
   // 获取用户信息
@@ -136,6 +135,17 @@ export const actions = {
       })
   },
 
+  // 获取首页加载热门搜索列表
+  loadHotSearch({ commit }) {
+    commit('hotSearch/REQUEST_HOT')
+    return axios.get('/cmsApi?method=queryContentPage&module=index_hotModels&orderBy=order_number%20ASC')
+      .then(response => {
+        commit('hotSearch/GET_HOT_SUCCESS', response.data)
+      }, err => {
+        commit('hotSearch/GET_HOT_FAILURE', err)
+      })
+  },
+
   // 获取楼层配置和特价信息
   loadNewFloors({ commit }, params = {}) {
     commit('floor/REQUEST_NEWLIST')
@@ -422,27 +432,6 @@ export const actions = {
         commit('help/GET_DETAIL_FAILURE', err)
       })
   },
-
-  // 获取最多搜索量的 器件
-  loadHotSearchDevice({ commit }) {
-    commit('hotSearchDevice/REQUEST_HOT')
-    return axios.get('/api/product/component/mostSearchComponent')
-      .then(response => {
-        commit('hotSearchDevice/GET_HOT_SUCCESS', response.data)
-      }, err => {
-        commit('hotSearchDevice/GET_HOT_FAILURE', err)
-      })
-  },
-  // 获取最多搜索量的 品牌
-  loadHotSearchBrand({ commit }) {
-    commit('hotSearchBrand/REQUEST_HOT')
-    return axios.get('/api/product/brand/mostSearchBrands')
-      .then(response => {
-        commit('hotSearchBrand/GET_HOT_SUCCESS', response.data)
-      }, err => {
-        commit('hotSearchBrand/GET_HOT_FAILURE', err)
-      })
-  },
   // 获取用户开店信息
   loadStoreStatus({ commit }, params = {}) {
     commit('option/REQUEST_STORE_STATUS')