|
|
@@ -8,7 +8,8 @@
|
|
|
@crnameFilterEvent="listenCrnameFilter"
|
|
|
@crnameFlagEvent="listenCrnameFlag"
|
|
|
></kind>-->
|
|
|
- <div class="search-result-type">
|
|
|
+ <brand-detail :supBrandObj="goods.brand" v-if="searchType == 'brand' && goods.brand"></brand-detail>
|
|
|
+ <div class="search-result-type" v-if="!goods.brands">
|
|
|
<span class="inline-block" :class="{active: resultType == 'current'}" @click="setResultType('current')">现货({{stockTotal}}条)</span>
|
|
|
<span class="inline-block" :class="{active: resultType == 'forward'}" @click="setResultType('forward')">期货({{futureTotal}}条)</span>
|
|
|
</div>
|
|
|
@@ -21,13 +22,20 @@
|
|
|
></good-list>
|
|
|
<forward-goods-list v-else></forward-goods-list>
|
|
|
</template>
|
|
|
- <template v-if="searchType == 'product'">
|
|
|
+ <template v-if="searchType == 'product' || searchType == 'store' || (searchType == 'brand' && goods.brand)">
|
|
|
<supplier-list></supplier-list>
|
|
|
</template>
|
|
|
+ <template v-if="searchType == 'brand' && !goods.brand">
|
|
|
+ <brand-list></brand-list>
|
|
|
+ </template>
|
|
|
+ <page :total="currentCount" :page-size="pageSize"
|
|
|
+ :current="nowPage" @childEvent="listenPage"></page>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
- import { GoodList, ResultTitle, ForwardGoodsList, SupplierList } from '~components/search'
|
|
|
+ import { GoodList, ResultTitle, ForwardGoodsList, SupplierList, BrandList } from '~components/search'
|
|
|
+ import { BrandDetail } from '~components/product'
|
|
|
+ import Page from '~components/common/page/pageComponent.vue'
|
|
|
// import DetailBrand from '~components/search/DetailBrand.vue'
|
|
|
export default{
|
|
|
layout: 'main',
|
|
|
@@ -56,7 +64,10 @@
|
|
|
ResultTitle,
|
|
|
GoodList,
|
|
|
ForwardGoodsList,
|
|
|
- SupplierList
|
|
|
+ SupplierList,
|
|
|
+ Page,
|
|
|
+ BrandList,
|
|
|
+ BrandDetail
|
|
|
// DetailBrand
|
|
|
},
|
|
|
watch: {
|
|
|
@@ -69,20 +80,37 @@
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
+ // 搜索类型
|
|
|
searchType () {
|
|
|
return this.$route.query.type || 'component'
|
|
|
},
|
|
|
+ // 搜索结果
|
|
|
goods () {
|
|
|
return this.$store.state.searchData.searchList.listNew.data
|
|
|
},
|
|
|
+ // 现货数量
|
|
|
stockTotal () {
|
|
|
- return this.goods.stock.total || 0
|
|
|
+ return this.goods.stock ? this.goods.stock.total : 0
|
|
|
},
|
|
|
+ // 期货数量
|
|
|
futureTotal () {
|
|
|
- return this.goods.futures.total || 0
|
|
|
+ return this.goods.futures ? this.goods.futures.total : 0
|
|
|
},
|
|
|
+ // 当前分页数
|
|
|
+ currentCount () {
|
|
|
+ if (this.goods.brands) {
|
|
|
+ return this.goods.total
|
|
|
+ } else {
|
|
|
+ return this.resultType === 'current' ? this.stockTotal : this.futureTotal
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 总数
|
|
|
count () {
|
|
|
- return this.stockTotal + this.futureTotal
|
|
|
+ if (this.goods.brands) {
|
|
|
+ return this.goods.total
|
|
|
+ } else {
|
|
|
+ return this.stockTotal + this.futureTotal
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -100,7 +128,7 @@
|
|
|
if (this.sorting === {}) {
|
|
|
this.sorting = {}
|
|
|
}
|
|
|
- this.$store.dispatch('searchData/searchForListNew', {count: this.pageSize, filter: this.filter, keyword: this.$route.query.w, page: this.nowPage, sorting: this.sorting, type: this.searchType})
|
|
|
+ return this.$store.dispatch('searchData/searchForListNew', {count: this.pageSize, filter: this.filter, keyword: this.$route.query.w, page: this.nowPage, sorting: this.sorting, type: this.searchType})
|
|
|
},
|
|
|
// reloadKind: function () {
|
|
|
// if (!this.filter.goods_kindId) {
|
|
|
@@ -124,7 +152,7 @@
|
|
|
// },
|
|
|
listenPage: function (nPage) {
|
|
|
this.nowPage = nPage
|
|
|
- this.reloadList()
|
|
|
+ return this.reloadList()
|
|
|
},
|
|
|
listenSort: function (sortType) {
|
|
|
this.sorting = sortType
|
|
|
@@ -227,7 +255,16 @@
|
|
|
// }
|
|
|
// },
|
|
|
setResultType: function (resultType) {
|
|
|
- this.resultType = resultType
|
|
|
+ if (this.nowPage > 1) {
|
|
|
+ this.listenPage(1).then(() => {
|
|
|
+ this.resultType = resultType
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.resultType = resultType
|
|
|
+ }
|
|
|
+// this.listenPage(1).then(() => {
|
|
|
+// this.resultType = resultType
|
|
|
+// })
|
|
|
}
|
|
|
}
|
|
|
}
|