修改商品分类下的商品列表,使用搜搜接口

This commit is contained in:
YunaiV 2019-04-26 00:15:15 +08:00
parent f529985c40
commit 6fb6f52bbe
3 changed files with 56 additions and 22 deletions

View File

@ -9,16 +9,10 @@
> >
<template slot="thumb"> <template slot="thumb">
<img :src="product.picUrls && product.picUrls ? product.picUrls[0] : ''"/> <img :src="product.picUrls && product.picUrls ? product.picUrls[0] : ''"/>
<!-- TODO 芋艿 暂时去掉 -->
<!-- <p v-if="product.imageTag!=null&&product.imageTag!=''" class="image_tag">{{product.imageTag}}</p>-->
</template> </template>
<template slot="tags"> <template slot="tags">
<p class="price" v-if="product.buyPrice || product.price"> <p class="price" v-if="product.buyPrice || product.price">
<span>{{product.buyPrice ? product.buyPrice / 100.00 : product.price / 100.00}}</span> <span>{{product.buyPrice ? product.buyPrice / 100.00 : product.price / 100.00}}</span>
<!-- TODO 芋艿 暂时去掉 -->
<!-- <van-tag v-if="product.tags!=null" v-for="tag in product.tags" :key="tag" plain type="danger">-->
<!-- {{tag}}-->
<!-- </van-tag>-->
<van-tag v-if="product.promotionActivityTitle" plain type="danger"> <van-tag v-if="product.promotionActivityTitle" plain type="danger">
{{ product.promotionActivityTitle }} {{ product.promotionActivityTitle }}
</van-tag> </van-tag>

View File

@ -8,14 +8,26 @@
<van-tab v-for="category in childCategories" :title="category.name" /> <van-tab v-for="category in childCategories" :title="category.name" />
</van-tabs> </van-tabs>
<!-- <div v-for="(product,i) in products" :key="i">-->
<!-- <product-card :product='product' @click="showProduct(product)" />-->
<!-- </div>-->
<van-list
v-model="loading"
:finished="finished"
finished-text="没有更多了"
@load="onLoad"
>
<div v-for="(product,i) in products" :key="i"> <div v-for="(product,i) in products" :key="i">
<product-card :product='product' @click="showProduct(product)" /> <product-card :product='product' @click="showProduct(product)" />
</div> </div>
</van-list>
</div> </div>
</template> </template>
<script> <script>
import { getProductCategoryList, getProductSpuPage } from '../../api/product'; import { getProductCategoryList, getProductSpuPage } from '../../api/product';
import {getProductPage} from "../../api/search";
export default { export default {
data() { data() {
@ -28,8 +40,14 @@ export default {
id: parseInt(this.$route.query.cidSecond), id: parseInt(this.$route.query.cidSecond),
}, },
childCategories: [], childCategories: [],
active: 2,
active: -1,
products: [], products: [],
page: 0,
pageSize: 10,
loading: false,
finished: false,
}; };
}, },
methods: { methods: {
@ -41,18 +59,40 @@ export default {
this.active = key; this.active = key;
// //
this.products = []; this.products = [];
this.loadProductList(this.childCategories[key].id); //
this.loadProductList(this.childCategories[key].id, 1);
}, },
loadProductList(categoryId) { loadProductList(categoryId, page) {
//
this.childCategory.id = categoryId; this.childCategory.id = categoryId;
// getProductPage({
// alert('' + categoryId); pageNo: page,
let response = getProductSpuPage(categoryId); pageSize: this.pageSize,
response.then(data => { cid: this.childCategory.id,
this.products.push(...data.spus); }).then(data => {
}) this.handleData(page, data);
});
},
onLoad() {
// debugger;
//
let page = this.page + 1;
//
this.loadProductList(this.childCategory.id, page);
},
handleData(page, data) {
this.loading = true;
//
this.page = page;
// list
this.products.push(...data.list);
//
if (this.products.length >= data.total) {
this.finished = true;
} }
//
this.loading = false;
},
}, },
mounted() { mounted() {
let response = getProductCategoryList(this.rootCategory.id); let response = getProductCategoryList(this.rootCategory.id);
@ -70,7 +110,7 @@ export default {
} }
} }
// //
this.loadProductList(this.childCategory.id); // this.loadProductList(this.childCategory.id);
}); });
} }
}; };

View File

@ -3,7 +3,7 @@ spring:
data: data:
elasticsearch: elasticsearch:
cluster-name: elasticsearch cluster-name: elasticsearch
cluster-nodes: 192.168.88.10:9300 cluster-nodes: 180.167.213.26:9300
repositories: repositories:
enable: true enable: true