|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="search-box"><!-- :class="{'search-box2': !SelectItem}"-->
|
|
|
+ <div class="search-box">
|
|
|
<div class="input-group">
|
|
|
<template v-if="!isPcb">
|
|
|
<div class="type">
|
|
@@ -8,10 +8,6 @@
|
|
|
<span class="type-item" :class="{active: newSearchType == 'store'}" @click="setNewSearchType('store')">卖家</span>
|
|
|
<span class="type-item" :class="{active: newSearchType == 'brand'}" @click="setNewSearchType('brand')">品牌</span>
|
|
|
</div>
|
|
|
- <!--<select v-model="searchType" class="form-control select-type select-adder" v-if="SelectItem">
|
|
|
- <option value="product">产品</option>
|
|
|
- <option value="store">店铺</option>
|
|
|
- </select>-->
|
|
|
<input v-model="keyword" type="text" class="search-input form-control input-primary"
|
|
|
:placeholder="placeholderByType"
|
|
|
@focus.stop.prevent="onFocus()"
|
|
@@ -46,31 +42,13 @@
|
|
|
:class="{'active': index==associate.activeIndex}"
|
|
|
@click.stop.prevent="onAssociateClick(v.value)">{{v.value}}
|
|
|
</li>
|
|
|
- <!-- <li v-if="similarKeywords.data.brand && similarKeywords.data.brand.length > 0" class="similar-title">品牌:</li>
|
|
|
- <li v-for="(k, index) in similarKeywords.data.brand" class="item"
|
|
|
- :class="{'active': index==associate.activeIndex}"
|
|
|
- @click.stop.prevent="onAssociateClick(isCnStart() ? k.nameCn : k.nameEn)">{{ isCnStart() ? k.nameCn : k.nameEn }}
|
|
|
- </li>
|
|
|
- <li v-if="similarKeywords.data.kind && similarKeywords.data.kind.length > 0" class="similar-title">物料名称:</li>
|
|
|
- <li v-for="(k, index) in similarKeywords.data.kind" class="item"
|
|
|
- :class="{'active': index==associate.activeIndex}"
|
|
|
- @click.stop.prevent="onAssociateClick(k.nameCn)">{{ k.nameCn }}
|
|
|
- </li>
|
|
|
- <li v-if="similarKeywords.data.component && similarKeywords.data.component.length > 0" class="similar-title">型号:</li>
|
|
|
- <li v-for="(k, index) in similarKeywords.data.component" class="item"
|
|
|
- :class="{'active': index==associate.activeIndex}"
|
|
|
- @click.stop.prevent="onAssociateClick(k.code)">{{ k.code }}
|
|
|
- </li>-->
|
|
|
</ul>
|
|
|
<div class="search-hot" v-if="SelectItem">
|
|
|
<ul class="list-untyled">
|
|
|
<li class="item item-first">热门搜索</li>
|
|
|
- <li class="item" v-for="w in hotDeviceBrand" v-if="ifFloorsHotSearchInValid">
|
|
|
+ <li class="item" v-for="w in hotDeviceBrand">
|
|
|
<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>
|
|
|
- </li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -105,7 +83,7 @@
|
|
|
},
|
|
|
computed: {
|
|
|
hotDeviceBrand () {
|
|
|
- return this.$store.state.hotSearch.hot.data
|
|
|
+ return this.$store.state.hotSearch.hot.data.data ? this.$store.state.hotSearch.hot.data.data : []
|
|
|
},
|
|
|
similarKeywords () {
|
|
|
let list = []
|
|
@@ -141,34 +119,6 @@
|
|
|
this.similarKeywords.result &&
|
|
|
this.similarKeywords.result.length
|
|
|
},
|
|
|
- hotSearchData () {
|
|
|
- let list = this.$store.state.floor.list_v3.data
|
|
|
- let obj = {}
|
|
|
- if (list && list.length) {
|
|
|
- for (let i = 0; i < list.length; i++) {
|
|
|
- if (list[i].floorNumber === 2) {
|
|
|
- obj = list[i]
|
|
|
- }
|
|
|
- }
|
|
|
-// obj = list.find(item => item.floorNumber === 2) || {}
|
|
|
- }
|
|
|
- return obj
|
|
|
- },
|
|
|
- ifFloorsHotSearchInValid () {
|
|
|
- let obj = this.hotSearchData
|
|
|
- let tmp = false
|
|
|
- if (obj.items && obj.items.length) {
|
|
|
- for (let i = 0; i < obj.items.length; i++) {
|
|
|
- if (!obj.items[i].body || obj.items[i].body === '') {
|
|
|
- tmp = obj.items[i]
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
-// let result = obj.items.find(item => !item.body || item.body === '') || true
|
|
|
- return tmp || true
|
|
|
- }
|
|
|
- return true
|
|
|
- },
|
|
|
placeholderByType () {
|
|
|
let type
|
|
|
switch (this.newSearchType) {
|
|
@@ -211,14 +161,6 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
-// onSelectTypeChange: function (e) {
|
|
|
-// let type = e.target[e.target.selectedIndex].innerHTML
|
|
|
-// if (type === '产品') {
|
|
|
-// this.searchType = 'product'
|
|
|
-// } else if (type === '店铺') {
|
|
|
-// this.searchType = 'store'
|
|
|
-// }
|
|
|
-// },
|
|
|
onFocus () {
|
|
|
this.associate.show = true
|
|
|
},
|
|
@@ -298,6 +240,7 @@
|
|
|
},
|
|
|
created () {
|
|
|
this.$store.dispatch('resetSearchKeywords')
|
|
|
+ this.$store.dispatch('loadHotSearch')
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
@@ -373,6 +316,9 @@
|
|
|
overflow: hidden;
|
|
|
text-overflow: ellipsis;
|
|
|
white-space: nowrap;
|
|
|
+ &:hover{
|
|
|
+ color: $red;
|
|
|
+ }
|
|
|
}
|
|
|
&.item-first {
|
|
|
width:12%;
|