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

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">
<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 slot="tags">
<p class="price" v-if="product.buyPrice || product.price">
<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">
{{ product.promotionActivityTitle }}
</van-tag>

View File

@ -8,14 +8,26 @@
<van-tab v-for="category in childCategories" :title="category.name" />
</van-tabs>
<div v-for="(product,i) in products" :key="i">
<product-card :product='product' @click="showProduct(product)" />
</div>
<!-- <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">
<product-card :product='product' @click="showProduct(product)" />
</div>
</van-list>
</div>
</template>
<script>
import { getProductCategoryList, getProductSpuPage } from '../../api/product';
import {getProductPage} from "../../api/search";
export default {
data() {
@ -28,8 +40,14 @@ export default {
id: parseInt(this.$route.query.cidSecond),
},
childCategories: [],
active: 2,
active: -1,
products: [],
page: 0,
pageSize: 10,
loading: false,
finished: false,
};
},
methods: {
@ -41,18 +59,40 @@ export default {
this.active = key;
//
this.products = [];
this.loadProductList(this.childCategories[key].id);
//
this.loadProductList(this.childCategories[key].id, 1);
},
loadProductList(categoryId) {
//
loadProductList(categoryId, page) {
this.childCategory.id = categoryId;
//
// alert('' + categoryId);
let response = getProductSpuPage(categoryId);
response.then(data => {
this.products.push(...data.spus);
})
}
getProductPage({
pageNo: page,
pageSize: this.pageSize,
cid: this.childCategory.id,
}).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() {
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:
elasticsearch:
cluster-name: elasticsearch
cluster-nodes: 192.168.88.10:9300
cluster-nodes: 180.167.213.26:9300
repositories:
enable: true