优化
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState, useEffect, useRef } from "react";
|
||||
import { View, Text, Input, Button } from "@tarojs/components";
|
||||
import Taro, { useDidShow } from "@tarojs/taro";
|
||||
|
||||
import httpService from "@/services/httpService";
|
||||
import "./index.scss";
|
||||
import { CommonPopup } from "@/components";
|
||||
import { useKeyboardHeight } from '@/store/keyboardStore'
|
||||
|
||||
interface WalletInfo {
|
||||
balance: string;
|
||||
@@ -15,6 +16,23 @@ interface WalletInfo {
|
||||
}
|
||||
|
||||
const Withdrawal: React.FC = () => {
|
||||
const inputRef = useRef(null);
|
||||
// 使用全局键盘状态
|
||||
const { keyboardHeight, isKeyboardVisible, addListener, initializeKeyboardListener } = useKeyboardHeight()
|
||||
// 使用全局键盘状态监听
|
||||
useEffect(() => {
|
||||
// 初始化全局键盘监听器
|
||||
initializeKeyboardListener()
|
||||
|
||||
// 添加本地监听器
|
||||
const removeListener = addListener((height, visible) => {
|
||||
console.log('AiImportPopup 收到键盘变化:', height, visible)
|
||||
})
|
||||
|
||||
return () => {
|
||||
removeListener()
|
||||
}
|
||||
}, [initializeKeyboardListener, addListener])
|
||||
const [showTips, setShowTips] = useState(false);
|
||||
const [tipsText, setTipsText] = useState<string>("");
|
||||
const [inputValue, setInputValue] = useState<string>("0.00");
|
||||
@@ -33,7 +51,11 @@ const Withdrawal: React.FC = () => {
|
||||
load_wallet_data();
|
||||
getWithdrawErrorCodes();
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (show_withdraw_popup && inputRef.current) {
|
||||
inputRef.current.focus();
|
||||
}
|
||||
}, [show_withdraw_popup]);
|
||||
useEffect(() => {
|
||||
if (show_withdraw_popup) {
|
||||
setIsFocus(true);
|
||||
@@ -51,7 +73,7 @@ const Withdrawal: React.FC = () => {
|
||||
setShowTips(true);
|
||||
setTipsText("单笔提现金额不能超过 200元");
|
||||
} else {
|
||||
setShowTips(false);
|
||||
setShowTips(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -191,7 +213,6 @@ const Withdrawal: React.FC = () => {
|
||||
content: message,
|
||||
showCancel: false,
|
||||
confirmText: "确认",
|
||||
confirmColor: "#fff",
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
@@ -214,6 +235,10 @@ const Withdrawal: React.FC = () => {
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
const handlePopupClick = (e) => {
|
||||
e.stopPropagation();
|
||||
inputRef.current!.focus();
|
||||
};
|
||||
return (
|
||||
<View className="withdrawal-page" >
|
||||
<View className="withdrawal-container">
|
||||
@@ -270,8 +295,9 @@ const Withdrawal: React.FC = () => {
|
||||
title="提现"
|
||||
className="withdraw_popup"
|
||||
hideFooter={true}
|
||||
style={{ bottom: isKeyboardVisible ? `${keyboardHeight}px` : undefined }}
|
||||
>
|
||||
<View className="popup_content">
|
||||
<View className="popup_content" onClick={handlePopupClick}>
|
||||
<View className="popup_text">{`¥${inputValue}`}</View>
|
||||
<View className="password_container">
|
||||
{
|
||||
@@ -282,7 +308,7 @@ const Withdrawal: React.FC = () => {
|
||||
))
|
||||
}
|
||||
</View>
|
||||
<Input focus={isFocus} type="number" style={{ width: "0", height: "0", opacity: "0" }} value={password.filter(item => item !== "").join("")} maxlength={6} onInput={handlePasswordInput} />
|
||||
<Input ref={inputRef} focus={isFocus} type="number" adjustPosition={false} style={{ width: "0", height: "0", opacity: "0" }} value={password.filter(item => item !== "").join("")} maxlength={6} onInput={handlePasswordInput} />
|
||||
</View>
|
||||
</CommonPopup>
|
||||
</View >
|
||||
|
||||
Reference in New Issue
Block a user