|
|
@@ -10,35 +10,39 @@
|
|
|
"van-sidebar": "../native/vant/sidebar/index",
|
|
|
"van-sidebar-item": "../native/vant/sidebar-item/index"
|
|
|
},
|
|
|
-'disableScroll': false
|
|
|
+'disableScroll': true
|
|
|
}
|
|
|
</config>
|
|
|
<template>
|
|
|
- <div class="container" :style="`padding-top:${barHeight}px`">
|
|
|
- <van-sticky :offset-top="0" :style="`height:${barHeight}px`">
|
|
|
+ <div class="container" :style="{ paddingTop: barHeight + 'px' }">
|
|
|
+ <van-sticky :offset-top="0">
|
|
|
<div class="navBar" :style="narStyle">
|
|
|
<van-icon name="arrow-left" @click="navigateBack" :size="24" color="#000" />
|
|
|
|
|
|
<van-search
|
|
|
:focus="focus"
|
|
|
left-icon="http://imttech.oss-cn-hangzhou.aliyuncs.com/micro/search.png"
|
|
|
- :value="searchKey"
|
|
|
+ :value="search"
|
|
|
@search="confirm"
|
|
|
shape="round"
|
|
|
placeholder="搜索..."
|
|
|
@change="changeSearch"
|
|
|
:maxlength="60"
|
|
|
@focus="focus = true"
|
|
|
- @clear="clearSearch"
|
|
|
@blur="blurSearch"
|
|
|
/>
|
|
|
|
|
|
<scroll-view
|
|
|
- v-if="searchKey && focus"
|
|
|
+ v-if="searchKey"
|
|
|
scroll-y
|
|
|
class="popupPage"
|
|
|
:style="`height: calc(100vh - ${barHeight}px + 30rpx)`"
|
|
|
>
|
|
|
+ <div class="popuptext top" @click="goNext(searchKey)">
|
|
|
+ 搜索“
|
|
|
+ <span> {{ searchKey }}</span>
|
|
|
+ ”相关的产品
|
|
|
+ </div>
|
|
|
<div class="popuptext top" @click="goVendor(searchKey)">
|
|
|
搜索“
|
|
|
<span> {{ searchKey }}</span>
|
|
|
@@ -51,172 +55,69 @@
|
|
|
</div>
|
|
|
<div
|
|
|
class="popuptext"
|
|
|
- v-html="getImport(item)"
|
|
|
+ v-html="getImport(item, searchKey)"
|
|
|
v-for="(item, index) in matchList"
|
|
|
:key="index"
|
|
|
@click="goNext(item)"
|
|
|
></div>
|
|
|
</scroll-view>
|
|
|
-
|
|
|
- <scroll-view
|
|
|
- v-else-if="focus"
|
|
|
- scroll-y
|
|
|
- class="content"
|
|
|
- :style="`height: calc(100vh - ${barHeight}px + 30rpx)`"
|
|
|
- >
|
|
|
- <div class="history" v-if="historys.length > 0">
|
|
|
- <div class="histroy-title">
|
|
|
- <div class="histroy-title-text">搜索历史</div>
|
|
|
- <van-button plain size="small" @click="del" color="#BCC1CC">清空记录</van-button>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="history-list">
|
|
|
- <div class="tags" @click="goNext(item)" v-for="(item, index) in historys" :key="index">
|
|
|
- {{ item }}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="history">
|
|
|
- <div class="histroy-title">
|
|
|
- <div class="histroy-title-text">热门搜索</div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="history-list">
|
|
|
- <div class="tags" @click="goNext(item)" v-for="(item, index) in hots" :key="index">
|
|
|
- {{ item }}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </scroll-view>
|
|
|
</div>
|
|
|
</van-sticky>
|
|
|
+ <div class="content">
|
|
|
+ <div class="history" v-if="historys.length > 0">
|
|
|
+ <div class="histroy-title">
|
|
|
+ <div class="text">搜索历史</div>
|
|
|
+ <van-button plain size="small" @click="del" color="#BCC1CC">清空记录</van-button>
|
|
|
+ </div>
|
|
|
|
|
|
- <van-dialog id="van-dialog" />
|
|
|
-
|
|
|
- <div class="main" id="main">
|
|
|
- <van-sticky v-if="searchType !== 'information'" :container="main" :offset-top="barHeight">
|
|
|
- <filter-sort-bar
|
|
|
- :sort="sort"
|
|
|
- :showType="showType"
|
|
|
- @showFilter="showFilter"
|
|
|
- @changeSort="changeSort"
|
|
|
- @changeShowType="changeShowType"
|
|
|
- :pageType="searchType"
|
|
|
- :changeShow="false"
|
|
|
- >
|
|
|
- <span slot="filter1">
|
|
|
- <product-category-filter
|
|
|
- size="small"
|
|
|
- v-model="categoryIds"
|
|
|
- @input="refreash"
|
|
|
- ></product-category-filter>
|
|
|
- </span>
|
|
|
- <span slot="filter2">
|
|
|
- <country-filter
|
|
|
- size="small"
|
|
|
- v-model="continent"
|
|
|
- :country.sync="countries"
|
|
|
- @input="refreash"
|
|
|
- ></country-filter>
|
|
|
- </span>
|
|
|
- <span slot="filter3">
|
|
|
- <product-brand-filter
|
|
|
- v-if="searchType === 'product'"
|
|
|
- size="small"
|
|
|
- v-model="brand"
|
|
|
- @input="refreash"
|
|
|
- ></product-brand-filter>
|
|
|
- <enterprise-type-filter
|
|
|
- v-else
|
|
|
- size="small"
|
|
|
- v-model="enterpriseType"
|
|
|
- @input="refreash"
|
|
|
- ></enterprise-type-filter>
|
|
|
- </span>
|
|
|
- </filter-sort-bar>
|
|
|
- </van-sticky>
|
|
|
-
|
|
|
- <sort-list
|
|
|
- :empty="empty"
|
|
|
- emptyText="敬请期待"
|
|
|
- :loading="loading"
|
|
|
- :finish="finish"
|
|
|
- :top="searchType === 'information' ? '0px' : '172rpx'"
|
|
|
- >
|
|
|
- <div class="product-list" v-if="showType === 'grid'">
|
|
|
- <div class="clo-2" v-for="item in list" :key="item.id">
|
|
|
- <product-grid :info="item" v-if="searchType === 'product'"></product-grid>
|
|
|
- <vendor-grid :info="item" v-else-if="searchType === 'vendor'"></vendor-grid>
|
|
|
+ <div class="history-list">
|
|
|
+ <div class="tags" @click="goNext(item)" v-for="(item, index) in historys" :key="index">
|
|
|
+ {{ item }}
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="product-list2" v-else>
|
|
|
- <div v-for="item in list" :key="item.id" class="item">
|
|
|
- <product-row :info="item" v-if="searchType === 'product'"></product-row>
|
|
|
- <vendor-row :info="item" v-else-if="searchType === 'vendor'"></vendor-row>
|
|
|
- <news-row :info="item" v-else></news-row>
|
|
|
+ </div>
|
|
|
+ <div class="history">
|
|
|
+ <div class="histroy-title">
|
|
|
+ <div class="text">热门搜索</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="history-list">
|
|
|
+ <div class="tags" @click="goNext(item)" v-for="(item, index) in hots" :key="index">
|
|
|
+ {{ item }}
|
|
|
</div>
|
|
|
</div>
|
|
|
- </sort-list>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+ <van-dialog id="van-dialog" />
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
import { mapState } from 'vuex';
|
|
|
import Dialog from '../native/vant/dialog/dialog';
|
|
|
import { matchingName } from '../utils/commont';
|
|
|
-import cnchar from '../native/cnchar.min.js';
|
|
|
-import searchList from '../mixins/searchList';
|
|
|
-import FilterSortBar from '../components/bar/FilterSortBar';
|
|
|
-import SortList from '../components/SortList';
|
|
|
-import ProductGrid from '../components/product/GridNormal';
|
|
|
-import ProductRow from '../components/product/RowNormal.vue';
|
|
|
-import ProductBrandFilter from '../components/filter/ProductBrand';
|
|
|
-import ProductCategoryFilter from '../components/filter/ProductCategory';
|
|
|
-import CountryFilter from '../components/filter/Country';
|
|
|
-
|
|
|
-import VendorGrid from '../components/vendor/Grid.vue';
|
|
|
-import VendorRow from '../components/vendor/Row';
|
|
|
-import EnterpriseTypeFilter from '../components/filter/EnterpriseType';
|
|
|
-
|
|
|
-import NewsRow from '../components/News/Row.vue';
|
|
|
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
menuButtonInfo: {},
|
|
|
- search: '',
|
|
|
+ searchKey: '',
|
|
|
+ searchShow: '',
|
|
|
activeKey: 0,
|
|
|
categories: [],
|
|
|
left: null,
|
|
|
historys: [],
|
|
|
focus: false,
|
|
|
hots: ['信息通信', '3D打印', '机床', '机加工', '电子器件', '高精度打印机', '量具仪具'],
|
|
|
- matchList: [],
|
|
|
- searchType: 'product',
|
|
|
- categoryIds: '',
|
|
|
- countries: '',
|
|
|
- continent: '',
|
|
|
- brand: '',
|
|
|
- url: '/product/show',
|
|
|
- tagIds: '',
|
|
|
- applicationField: '',
|
|
|
- main: null,
|
|
|
- ratio: 1,
|
|
|
- vendorInfoId: '',
|
|
|
- defaultCategoryId: '',
|
|
|
- enterpriseType: '',
|
|
|
- showType: 'row',
|
|
|
- first: true
|
|
|
+ matchList: []
|
|
|
};
|
|
|
},
|
|
|
- mixins: [searchList],
|
|
|
computed: {
|
|
|
- ...mapState(['barTop', 'barHeight']),
|
|
|
+ ...mapState(['barTop', 'barHeight', 'barInfo']),
|
|
|
narStyle() {
|
|
|
- if (this.menuButtonInfo.top) {
|
|
|
+ if (this.barInfo.top) {
|
|
|
return {
|
|
|
- padding: this.menuButtonInfo.top + 'px ' + (10 + this.menuButtonInfo.width) + 'px 15px 15px',
|
|
|
- height: this.menuButtonInfo.height + 'px'
|
|
|
+ padding: this.barInfo.top + 'px ' + (10 + this.barInfo.width) + 'px 15px 15px',
|
|
|
+ height: this.barInfo.height + 'px'
|
|
|
};
|
|
|
} else {
|
|
|
return {};
|
|
|
@@ -285,7 +186,16 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
- this.menuButtonInfo = wx.getMenuButtonBoundingClientRect();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.focus = true;
|
|
|
+ if (this.search) {
|
|
|
+ this.changeSearch({
|
|
|
+ detail: this.search
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }, 100);
|
|
|
},
|
|
|
onLoad() {
|
|
|
this.getHistory();
|
|
|
@@ -295,9 +205,6 @@ export default {
|
|
|
},
|
|
|
onReady() {
|
|
|
this.left = wx.createSelectorQuery().select('#left');
|
|
|
- this.$nextTick(() => {
|
|
|
- this.focus = true;
|
|
|
- });
|
|
|
},
|
|
|
methods: {
|
|
|
confirm(e) {
|
|
|
@@ -334,48 +241,43 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
goNext(info, changeType = true) {
|
|
|
- this.first = false;
|
|
|
- console.log(info);
|
|
|
- this.focus = false;
|
|
|
- this.searchKey = info;
|
|
|
var historys = [...this.historys];
|
|
|
historys.splice(0, 0, info);
|
|
|
historys = [...new Set(historys)];
|
|
|
- historys.slice(0, 20);
|
|
|
+ historys = historys.slice(0, 10);
|
|
|
var _this = this;
|
|
|
wx.setStorage({
|
|
|
key: 'searchHistory',
|
|
|
data: JSON.stringify(historys),
|
|
|
success(res) {
|
|
|
_this.getHistory();
|
|
|
- if (changeType) {
|
|
|
- _this.changeInfo('vendor');
|
|
|
- }
|
|
|
- _this.$nextTick(() => {
|
|
|
- _this.submitSearch();
|
|
|
+
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pagesHome/SearchList?search=' + info,
|
|
|
+ success: () => {
|
|
|
+ _this.search = info;
|
|
|
+ _this.focus = false;
|
|
|
+ }
|
|
|
});
|
|
|
- // wx.redirectTo({
|
|
|
- // url: '/pagesHome/SearchList?search=' + info
|
|
|
- // });
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
goVendor(info) {
|
|
|
- this.first = false;
|
|
|
- this.changeInfo('vendor');
|
|
|
- this.focus = false;
|
|
|
- this.searchKey = info;
|
|
|
- this.$nextTick(() => {
|
|
|
- this.submitSearch();
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pagesHome/VendorList?search=' + info,
|
|
|
+ success: () => {
|
|
|
+ this.search = info;
|
|
|
+ this.focus = false;
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
goInformation(info) {
|
|
|
- this.first = false;
|
|
|
- this.changeInfo('information');
|
|
|
- this.focus = false;
|
|
|
- this.searchKey = info;
|
|
|
- this.$nextTick(() => {
|
|
|
- this.submitSearch();
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pagesHome/InformationList?search=' + info,
|
|
|
+ success: () => {
|
|
|
+ this.search = info;
|
|
|
+ this.focus = false;
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
getHistory() {
|
|
|
@@ -411,9 +313,6 @@ export default {
|
|
|
},
|
|
|
changeSearch(e) {
|
|
|
this.searchKey = e.detail;
|
|
|
- if (!this.focus) {
|
|
|
- return;
|
|
|
- }
|
|
|
if (e.detail) {
|
|
|
matchingName(e.detail).then(res => {
|
|
|
let searchstr = e.detail.toLowerCase();
|
|
|
@@ -438,11 +337,9 @@ export default {
|
|
|
this.submitSearch();
|
|
|
},
|
|
|
blurSearch() {
|
|
|
- if (!this.first) {
|
|
|
- setTimeout(() => {
|
|
|
- this.focus = false;
|
|
|
- }, 500);
|
|
|
- }
|
|
|
+ setTimeout(() => {
|
|
|
+ this.focus = false;
|
|
|
+ }, 500);
|
|
|
}
|
|
|
},
|
|
|
onReachBottom() {
|
|
|
@@ -450,19 +347,6 @@ export default {
|
|
|
this.page++;
|
|
|
this.getData();
|
|
|
}
|
|
|
- },
|
|
|
- components: {
|
|
|
- FilterSortBar,
|
|
|
- SortList,
|
|
|
- ProductRow,
|
|
|
- ProductGrid,
|
|
|
- ProductBrandFilter,
|
|
|
- ProductCategoryFilter,
|
|
|
- CountryFilter,
|
|
|
- EnterpriseTypeFilter,
|
|
|
- VendorGrid,
|
|
|
- VendorRow,
|
|
|
- NewsRow
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
@@ -486,24 +370,6 @@ export default {
|
|
|
position: relative;
|
|
|
}
|
|
|
|
|
|
-.product-list {
|
|
|
- display: flex;
|
|
|
- flex-wrap: wrap;
|
|
|
- padding: 0 10px;
|
|
|
- .clo-2 {
|
|
|
- width: 50%;
|
|
|
- padding: 6px;
|
|
|
- box-sizing: border-box;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-.product-list2 {
|
|
|
- padding: 10px 16px;
|
|
|
- .item + .item {
|
|
|
- margin-top: 16px;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
// .top {
|
|
|
// position: relative;
|
|
|
// .text {
|