1.15提交
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
>
|
||||
<template v-slot:right>
|
||||
<view class="nav-actions">
|
||||
<view class="btn" @click="goToSearch">搜索</view>
|
||||
<view class="btn" @click="goSearch">搜索</view>
|
||||
</view>
|
||||
</template>
|
||||
</uni-nav-bar>
|
||||
@@ -148,11 +148,14 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商品网格(上拉加载) -->
|
||||
<!-- 商品网格(上拉加载 + 下拉刷新) -->
|
||||
<scroll-view
|
||||
class="product-grid"
|
||||
scroll-y
|
||||
refresher-enabled="true"
|
||||
:refresher-triggered="refresherTriggered"
|
||||
@scrolltolower="getGoodsList"
|
||||
@refresherrefresh="onRefresherRefresh"
|
||||
:lower-threshold="100"
|
||||
>
|
||||
<view class="grid-wrap">
|
||||
@@ -160,6 +163,7 @@
|
||||
class="product-item"
|
||||
v-for="(product, index) in products"
|
||||
:key="product.uuid || index"
|
||||
|
||||
@click="goToProductDetail(product)"
|
||||
>
|
||||
<view class="product-image-container">
|
||||
@@ -219,6 +223,7 @@ const page = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const isLoadingMore = ref(false);
|
||||
const noMore = ref(false);
|
||||
const refresherTriggered = ref(false);
|
||||
const onSwiperChange = (e) => {
|
||||
currentBannerIndex.value = e.detail.current;
|
||||
};
|
||||
@@ -288,7 +293,17 @@ const goToProductDetail = (product) => {
|
||||
url: `/pages_goods/productDetail/productDetail?id=${id}`,
|
||||
});
|
||||
};
|
||||
|
||||
const goSearch = () => {
|
||||
uni.sendNativeEvent(
|
||||
"goHomeSearch",
|
||||
{
|
||||
msg: "pointMall",
|
||||
},
|
||||
(ret) => {
|
||||
console.log(ret);
|
||||
}
|
||||
);
|
||||
}
|
||||
const goToMyRedemption = () => {
|
||||
uni.navigateTo({
|
||||
url: "/pages_goods/myRedemption/myRedemption",
|
||||
@@ -305,7 +320,7 @@ const goToBannerDetail = (banner) => {
|
||||
// 跳转到轮播图详情页面
|
||||
uni.navigateTo({
|
||||
url: `/pages_app/webview/webview?url=${encodeURIComponent(
|
||||
banner.path
|
||||
docUrl+banner.path
|
||||
)}&title=${banner.title}`,
|
||||
});
|
||||
};
|
||||
@@ -393,6 +408,31 @@ const getGoodsTagList = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// 下拉刷新处理
|
||||
const onRefresherRefresh = async () => {
|
||||
if (refresherTriggered.value) return;
|
||||
refresherTriggered.value = true;
|
||||
try {
|
||||
// 重置分页和列表
|
||||
page.value = 1;
|
||||
noMore.value = false;
|
||||
isLoadingMore.value = false;
|
||||
products.value = [];
|
||||
// 重新加载所有数据
|
||||
getGoodsNewsList();
|
||||
getGoodsTagList();
|
||||
await getGoodsList();
|
||||
} catch (error) {
|
||||
console.error("刷新数据失败:", error);
|
||||
uni.showToast({
|
||||
title: "刷新失败,请重试",
|
||||
icon: "none",
|
||||
});
|
||||
} finally {
|
||||
refresherTriggered.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getGoodsNewsList();
|
||||
// 初始化分页并加载第一页
|
||||
@@ -613,7 +653,7 @@ onMounted(() => {
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
height: calc(
|
||||
100vh - var(--status-bar-height) - 44px - 88rpx
|
||||
100vh - var(--status-bar-height) - 44px - 575rpx
|
||||
); /* 预留顶部导航/筛选及底部栏 */
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user