This commit is contained in:
2026-04-10 19:00:01 +08:00
parent 32fa3e9bd2
commit 26e57e4891
6 changed files with 315 additions and 167 deletions

View File

@ -170,6 +170,8 @@ export default {
total: 0,
page: 1,
size: 10,
nextCursor: '',
hasMore: true,
showModal: false,
addGoodInfo: null,
showContactModal: false,
@ -263,6 +265,9 @@ export default {
initData() {
this.getCategoryList();
this.page = 1;
this.nextCursor = '';
this.hasMore = true;
this.goodsList = [];
this.getGoodsList();
this.getCartListData();
},
@ -281,13 +286,25 @@ export default {
// 商品列表
getGoodsList() {
if (this.isLoading) return;
if (!this.hasMore && this.page > 1) return;
this.isLoading = true;
getGoodsListData({
type: this.selectCategoryId ? this.selectCategoryId : 0,
cursor: this.nextCursor,
})
.then((res) => {
const list = res?.data.data.products || [];
this.goodsList = list;
const hasMore = res?.data.data.has_more;
const nextCursor = res?.data.data.next_cursor || '';
if (this.page === 1) {
this.goodsList = list;
} else {
this.goodsList = [...this.goodsList, ...list];
}
this.hasMore = hasMore;
this.nextCursor = nextCursor;
this.total = res?.count || 0;
})
.finally(() => {
@ -300,10 +317,12 @@ export default {
this.page = 1;
this.size = 10;
this.total = 0;
this.nextCursor = '';
this.hasMore = true;
this.getGoodsList();
},
onLoadMore() {
if (!this.isLoading && this.total > this.goodsList.length) {
if (!this.isLoading && this.hasMore) {
this.page++;
this.getGoodsList();
}
@ -378,20 +397,20 @@ export default {
}
uni.navigateTo({
url: `/pages/client/order/create`,
success: (res) => {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit("createOrder", {
goodList: [{
goods_id:goodsData.product.out_id,
product_pic: firstImageUrl,
number:1,
goods_name: goodsData.product.product_name,
price_name: goodsData?.product.product_name,
goods_price: goodsData.sku.actual_amount / 100
}, ],
});
},
url: `/pages/client/order/create?product_id=${goodsData.product.product_id}`,
// success: (res) => {
// // 通过eventChannel向被打开页面传送数据
// res.eventChannel.emit("createOrder", {
// goodList: [{
// goods_id:goodsData.product.out_id,
// product_pic: firstImageUrl,
// number:1,
// goods_name: goodsData.product.product_name,
// price_name: goodsData?.product.product_name,
// goods_price: goodsData.sku.actual_amount / 100
// }, ],
// });
// },
});
},
// 购物车列表
@ -419,31 +438,31 @@ export default {
// 立即购买
handleBuyNow(good) {
uni.navigateTo({
url: `/pages/client/order/create`,
success: (res) => {
// 通过 eventChannel 向被打开页面传送数据
res.eventChannel.emit("createOrder", {
goodList: [
{
goods_id: good.product_id,
item_type: good.type,
price_id: good.prices?.[0]?.price_id,
price_desc: good.prices?.[0]?.price_desc,
item_name: good.product_name,
item_price: good.prices?.[0]?.actual_price,
item_pic: good.product_pic,
number: 1,
product_id: good.product_id,
product_name: good.product_name,
product_pic: good.product_pic,
goods_price: good.prices?.[0]?.actual_price / 100,
product_price: good.prices?.[0]?.actual_price / 100,
original_price: good.prices?.[0]?.original_price,
yunfei: good.yunfei || 0,
},
],
});
},
url: `/pages/client/order/create?product_id=${good.product.product_id}`,
// success: (res) => {
// // 通过 eventChannel 向被打开页面传送数据
// res.eventChannel.emit("createOrder", {
// goodList: [
// {
// goods_id: good.product_id,
// item_type: good.type,
// price_id: good.prices?.[0]?.price_id,
// price_desc: good.prices?.[0]?.price_desc,
// item_name: good.product_name,
// item_price: good.prices?.[0]?.actual_price,
// item_pic: good.product_pic,
// number: 1,
// product_id: good.product_id,
// product_name: good.product_name,
// product_pic: good.product_pic,
// goods_price: good.prices?.[0]?.actual_price / 100,
// product_price: good.prices?.[0]?.actual_price / 100,
// original_price: good.prices?.[0]?.original_price,
// yunfei: good.yunfei || 0,
// },
// ],
// });
// },
});
},
},