feat: 增加防抖

This commit is contained in:
2025-12-29 10:23:15 +08:00
parent c9c19855c3
commit a0f7838895
2 changed files with 8 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from "react";
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import classnames from "classnames"; import classnames from "classnames";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { debounce } from "@tarojs/runtime";
import { Text, View, Image } from "@tarojs/components"; import { Text, View, Image } from "@tarojs/components";
import OrderService from "@/services/orderService"; import OrderService from "@/services/orderService";
import { EvaluateCallback, EvaluateScene } from "@/store/evaluateStore"; import { EvaluateCallback, EvaluateScene } from "@/store/evaluateStore";
@@ -348,6 +349,8 @@ export default function StickyButton(props) {
}; };
} }
const debounceAction = debounce(action, 300);
return ( return (
<> <>
<View className={styles["sticky-bottom-bar"]}> <View className={styles["sticky-bottom-bar"]}>
@@ -390,7 +393,7 @@ export default function StickyButton(props) {
<View <View
style={is_organizer ? {} : { margin: "auto" }} style={is_organizer ? {} : { margin: "auto" }}
className={styles["sticky-bottom-bar-join-game"]} className={styles["sticky-bottom-bar-join-game"]}
onClick={action} onClick={debounceAction}
> >
<ActionText /> <ActionText />
</View> </View>

View File

@@ -11,6 +11,7 @@ import orderService, {
OrderStatus, OrderStatus,
refundTextMap, refundTextMap,
} from "@/services/orderService"; } from "@/services/orderService";
import { debounce } from "@tarojs/runtime";
import { import {
payOrder, payOrder,
delay, delay,
@@ -615,7 +616,7 @@ const OrderCheck = () => {
} }
//TODO: get order msg from id //TODO: get order msg from id
const handlePay = async () => { const handlePay = debounce(async () => {
// 检查登录状态和手机号 // 检查登录状态和手机号
if (!requireLoginWithPhone()) { if (!requireLoginWithPhone()) {
return; // 未登录或未绑定手机号,已跳转到登录页 return; // 未登录或未绑定手机号,已跳转到登录页
@@ -654,7 +655,8 @@ const OrderCheck = () => {
init(); init();
setPaying(false); setPaying(false);
} }
}; }, 300);
if (!id && !gameId) { if (!id && !gameId) {
return ( return (
<View className={styles.errorTip}> <View className={styles.errorTip}>