修改商品分类下的商品列表,使用搜搜接口
This commit is contained in:
parent
f529985c40
commit
6fb6f52bbe
@ -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>
|
||||||
|
@ -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">
|
<!-- <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
|
||||||
|
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>
|
</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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user