zjk
2026-06-03 e688b7abd552ca9556af55a3d9545be1b5e1d277
feat(coupon): 优化优惠券列表的加载更多功能

新增ScrollView包裹优惠券列表,支持滚动列表底部触发加载,同时提取加载逻辑为独立函数复用代码
1个文件已修改
16 ■■■■■ 已修改文件
src/robotaxi/pages/coupon/index.tsx 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/coupon/index.tsx
@@ -1,6 +1,6 @@
import Taro, { useReachBottom } from "@tarojs/taro";
import { useState, useEffect } from "react";
import { View, Text, Image, RichText } from "@tarojs/components";
import { View, Text, Image, RichText, ScrollView } from "@tarojs/components";
import "./index.less";
import {
  getCouponList,
@@ -94,12 +94,16 @@
    getList(1, activeStatus, true);
  }, [activeStatus]);
  useReachBottom(() => {
  const loadMore = () => {
    if (hasMore) {
      const nextPage = pageNum + 1;
      setPageNum(nextPage);
      getList(nextPage, activeStatus);
    }
  };
  useReachBottom(() => {
    loadMore();
  });
  const changeStatus = (value: string | number) => {
@@ -184,7 +188,11 @@
        })}
      </View>
      {couponList.length > 0 && (
        <View className="coupon-card">
        <ScrollView
          className="coupon-card"
          scrollY
          onScrollToLower={loadMore}
        >
          {couponList.map((item, index) => {
            return (
              <View
@@ -245,7 +253,7 @@
              </View>
            );
          })}
        </View>
        </ScrollView>
      )}
      {!couponList.length && (
        <View className="no-data-box">