自定义标题
This commit is contained in:
@@ -174,7 +174,7 @@ const MyselfPage: React.FC = () => {
|
|||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: "/publish_pages/publishBall/index",
|
url: "/publish_pages/publishBall/index",
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
// 处理球局订单
|
// 处理球局订单
|
||||||
const handle_game_orders = () => {
|
const handle_game_orders = () => {
|
||||||
@@ -243,8 +243,9 @@ const MyselfPage: React.FC = () => {
|
|||||||
<Text className="tab_text">我主办的</Text>
|
<Text className="tab_text">我主办的</Text>
|
||||||
</View>
|
</View>
|
||||||
<View
|
<View
|
||||||
className={`tab_item ${active_tab === "participated" ? "active" : ""
|
className={`tab_item ${
|
||||||
}`}
|
active_tab === "participated" ? "active" : ""
|
||||||
|
}`}
|
||||||
onClick={() => setActiveTab("participated")}
|
onClick={() => setActiveTab("participated")}
|
||||||
>
|
>
|
||||||
<Text className="tab_text">我参与的</Text>
|
<Text className="tab_text">我参与的</Text>
|
||||||
@@ -266,7 +267,7 @@ const MyselfPage: React.FC = () => {
|
|||||||
btnImg="ICON_ADD"
|
btnImg="ICON_ADD"
|
||||||
reload={goPublish}
|
reload={goPublish}
|
||||||
isShowNoData={game_records.length === 0}
|
isShowNoData={game_records.length === 0}
|
||||||
loadMoreMatches={() => { }}
|
loadMoreMatches={() => {}}
|
||||||
/>
|
/>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
@@ -290,7 +291,7 @@ const MyselfPage: React.FC = () => {
|
|||||||
error={null}
|
error={null}
|
||||||
errorImg="ICON_LIST_EMPTY"
|
errorImg="ICON_LIST_EMPTY"
|
||||||
isShowNoData={ended_game_records.length === 0}
|
isShowNoData={ended_game_records.length === 0}
|
||||||
loadMoreMatches={() => { }}
|
loadMoreMatches={() => {}}
|
||||||
/>
|
/>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
{/* </View> */}
|
{/* </View> */}
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ const SetTransactionPassword: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
|
if (!valid) return;
|
||||||
const { new_password, confirm_password } = formData;
|
const { new_password, confirm_password } = formData;
|
||||||
if (new_password !== confirm_password) {
|
if (new_password !== confirm_password) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
export default definePageConfig({
|
export default definePageConfig({
|
||||||
navigationBarTitleText: '钱包',
|
navigationBarTitleText: "钱包",
|
||||||
})
|
navigationBarBackgroundColor: "#ffffff",
|
||||||
|
navigationBarTextStyle: "black",
|
||||||
|
backgroundColor: "#f5f5f5",
|
||||||
|
enablePullDownRefresh: false,
|
||||||
|
disableScroll: false,
|
||||||
|
navigationStyle: "custom",
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,140 +1,183 @@
|
|||||||
.withdrawal-page {
|
.withdrawal-page {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
font-family: PingFang SC;
|
font-family: PingFang SC;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-style: Regular;
|
font-style: Regular;
|
||||||
color: #3C3C4399;
|
color: #3c3c4399;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
.custom-navbar {
|
||||||
|
height: 56px;
|
||||||
|
/* 通常与原生导航栏高度一致 */
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
// background-color: #fff;
|
||||||
|
color: #000;
|
||||||
|
padding-top: 44px;
|
||||||
|
/* 适配状态栏 */
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 100;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
.withdrawal-container {
|
.detail-navigator {
|
||||||
margin: 20px 5px 0;
|
height: 30px;
|
||||||
border-radius: 20px;
|
width: fit-content;
|
||||||
padding-top: 12px;
|
border-radius: 15px;
|
||||||
padding-right: 20px;
|
position: absolute;
|
||||||
padding-bottom: 24px;
|
left: 12px;
|
||||||
padding-left: 20px;
|
box-sizing: border-box;
|
||||||
gap: 16px;
|
display: flex;
|
||||||
border: 0.5px solid #EBEBEB;
|
align-items: center;
|
||||||
box-shadow: 0px 4px 36px 0px #0000000D;
|
|
||||||
|
|
||||||
.title-text {
|
.detail-navigator-back {
|
||||||
color: #000;
|
height: 32px;
|
||||||
}
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
font-family: PingFang SC;
|
||||||
|
font-weight: 600;
|
||||||
|
font-style: Semibold;
|
||||||
|
font-size: 20px;
|
||||||
|
letter-spacing: 0.38px;
|
||||||
|
|
||||||
.input-container {
|
& > .detail-navigator-back-icon {
|
||||||
font-weight: bold;
|
width: 32px;
|
||||||
color: #000;
|
height: 32px;
|
||||||
display: flex;
|
}
|
||||||
align-items: flex-end;
|
}
|
||||||
overflow: hidden;
|
}
|
||||||
gap: 8px;
|
|
||||||
border-bottom: 0.5px solid var(--Fills-Tertiary, #7878801F);
|
|
||||||
margin: 12px 0;
|
|
||||||
padding-bottom: 12px;
|
|
||||||
|
|
||||||
.symbol {
|
.withdrawal-container {
|
||||||
font-size: 20px;
|
margin: 20px 5px 0;
|
||||||
}
|
border-radius: 20px;
|
||||||
|
padding-top: 12px;
|
||||||
|
padding-right: 20px;
|
||||||
|
padding-bottom: 24px;
|
||||||
|
padding-left: 20px;
|
||||||
|
gap: 16px;
|
||||||
|
border: 0.5px solid #ebebeb;
|
||||||
|
box-shadow: 0px 4px 36px 0px #0000000d;
|
||||||
|
|
||||||
Input {
|
.title-text {
|
||||||
font-size: 32px;
|
color: #000;
|
||||||
height: 36px;
|
|
||||||
min-height: 0;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border: none;
|
|
||||||
background: none;
|
|
||||||
color: inherit;
|
|
||||||
outline: none;
|
|
||||||
-webkit-appearance: none;
|
|
||||||
-moz-appearance: none;
|
|
||||||
appearance: none;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
height: 24px;
|
|
||||||
border: 1px solid rgba(0, 0, 0, 0.06);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
color: #fff;
|
|
||||||
background: #000;
|
|
||||||
box-shadow: 0 8px 64px 0 rgba(0, 0, 0, 0.1);
|
|
||||||
backdrop-filter: blur(16px);
|
|
||||||
font-feature-settings: "liga" off, "clig" off;
|
|
||||||
font-family: "PingFang SC";
|
|
||||||
font-size: 9.6px;
|
|
||||||
font-style: normal;
|
|
||||||
line-height: normal;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.tips-text {
|
|
||||||
color: #F3334A;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-container {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
color: #007AFF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tips-container {
|
.input-container {
|
||||||
padding: 20px 20px;
|
font-weight: bold;
|
||||||
|
color: #000;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
overflow: hidden;
|
||||||
|
gap: 8px;
|
||||||
|
border-bottom: 0.5px solid var(--Fills-Tertiary, #7878801f);
|
||||||
|
margin: 12px 0;
|
||||||
|
padding-bottom: 12px;
|
||||||
|
|
||||||
.title-text {
|
.symbol {
|
||||||
font-weight: 600;
|
font-size: 20px;
|
||||||
margin-bottom: 12px;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.tips-text {
|
Input {
|
||||||
display: flex;
|
font-size: 32px;
|
||||||
flex-direction: column;
|
height: 36px;
|
||||||
}
|
min-height: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
color: inherit;
|
||||||
|
outline: none;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
height: 24px;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #fff;
|
||||||
|
background: #000;
|
||||||
|
box-shadow: 0 8px 64px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
backdrop-filter: blur(16px);
|
||||||
|
font-feature-settings: "liga" off, "clig" off;
|
||||||
|
font-family: "PingFang SC";
|
||||||
|
font-size: 9.6px;
|
||||||
|
font-style: normal;
|
||||||
|
line-height: normal;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tips-text {
|
||||||
|
color: #f3334a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
color: #007aff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tips-container {
|
||||||
|
padding: 20px 20px;
|
||||||
|
|
||||||
|
.title-text {
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tips-text {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.withdraw_popup {
|
.withdraw_popup {
|
||||||
min-height: unset;
|
min-height: unset;
|
||||||
.popup_content {
|
.popup_content {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
.popup_text {
|
.popup_text {
|
||||||
font-family: DingTalk JinBuTi;
|
font-family: DingTalk JinBuTi;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-style: Regular;
|
font-style: Regular;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
}
|
|
||||||
|
|
||||||
.password_container {
|
|
||||||
display: flex;
|
|
||||||
gap: 4px;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.password_item {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: #7878801F;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
-webkit-text-security: disc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
.password_container {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.password_item {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: #7878801f;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
-webkit-text-security: disc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,321 +1,394 @@
|
|||||||
import React, { useState, useEffect, useRef } from "react";
|
import React, { useState, useEffect, useRef } from "react";
|
||||||
import { View, Text, Input, Button } from "@tarojs/components";
|
import { View, Text, Input, Button, Image } from "@tarojs/components";
|
||||||
import Taro, { useDidShow } from "@tarojs/taro";
|
import Taro, { useDidShow } from "@tarojs/taro";
|
||||||
|
|
||||||
import httpService from "@/services/httpService";
|
import httpService from "@/services/httpService";
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
import { CommonPopup } from "@/components";
|
import { CommonPopup } from "@/components";
|
||||||
import { useKeyboardHeight } from '@/store/keyboardStore'
|
import { useKeyboardHeight } from "@/store/keyboardStore";
|
||||||
|
import img from "@/config/images";
|
||||||
|
|
||||||
interface WalletInfo {
|
interface WalletInfo {
|
||||||
balance: string;
|
balance: string;
|
||||||
frozen_balance?: string;
|
frozen_balance?: string;
|
||||||
total_balance?: string;
|
total_balance?: string;
|
||||||
total_income?: string;
|
total_income?: string;
|
||||||
total_withdraw?: string;
|
total_withdraw?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Withdrawal: React.FC = () => {
|
const Withdrawal: React.FC = () => {
|
||||||
const inputRef = useRef(null);
|
// 获取当前页面的配置
|
||||||
// 使用全局键盘状态
|
const currentPage = Taro.getCurrentInstance();
|
||||||
const { keyboardHeight, isKeyboardVisible, addListener, initializeKeyboardListener } = useKeyboardHeight()
|
const pageConfig = currentPage.page?.config;
|
||||||
// 使用全局键盘状态监听
|
const pageTitle = pageConfig?.navigationBarTitleText;
|
||||||
useEffect(() => {
|
const inputRef = useRef(null);
|
||||||
// 初始化全局键盘监听器
|
// 使用全局键盘状态
|
||||||
initializeKeyboardListener()
|
const {
|
||||||
|
keyboardHeight,
|
||||||
|
isKeyboardVisible,
|
||||||
|
addListener,
|
||||||
|
initializeKeyboardListener,
|
||||||
|
} = useKeyboardHeight();
|
||||||
|
// 使用全局键盘状态监听
|
||||||
|
useEffect(() => {
|
||||||
|
// 初始化全局键盘监听器
|
||||||
|
initializeKeyboardListener();
|
||||||
|
|
||||||
// 添加本地监听器
|
// 添加本地监听器
|
||||||
const removeListener = addListener((height, visible) => {
|
const removeListener = addListener((height, visible) => {
|
||||||
console.log('AiImportPopup 收到键盘变化:', 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");
|
|
||||||
const [walletInfo, setWalletInfo] = useState<WalletInfo>({
|
|
||||||
balance: "0.00",
|
|
||||||
});
|
});
|
||||||
const [isFocus, setIsFocus] = useState(false);
|
|
||||||
|
|
||||||
const [show_withdraw_popup, set_show_withdraw_popup] = useState(false);
|
return () => {
|
||||||
|
removeListener();
|
||||||
const [password, setPassword] = useState<string[]>(new Array(6).fill(""));
|
|
||||||
|
|
||||||
const [mapErrorCodes, setMapErrorCodes] = useState({});
|
|
||||||
|
|
||||||
useDidShow(() => {
|
|
||||||
load_wallet_data();
|
|
||||||
getWithdrawErrorCodes();
|
|
||||||
});
|
|
||||||
useEffect(() => {
|
|
||||||
if (show_withdraw_popup && inputRef.current) {
|
|
||||||
inputRef.current.focus();
|
|
||||||
}
|
|
||||||
}, [show_withdraw_popup]);
|
|
||||||
useEffect(() => {
|
|
||||||
if (show_withdraw_popup) {
|
|
||||||
setIsFocus(true);
|
|
||||||
} else {
|
|
||||||
setPassword(new Array(6).fill(""));
|
|
||||||
setIsFocus(false);
|
|
||||||
}
|
|
||||||
}, [show_withdraw_popup]);
|
|
||||||
|
|
||||||
const validateWithdrawAmount = (amount: string) => {
|
|
||||||
if (Number(amount) > Number(walletInfo.balance)) {
|
|
||||||
setShowTips(true);
|
|
||||||
setTipsText("输入金额超过钱包余额");
|
|
||||||
} else if (Number(amount) > 200) {
|
|
||||||
setShowTips(true);
|
|
||||||
setTipsText("单笔提现金额不能超过 200元");
|
|
||||||
} else {
|
|
||||||
setShowTips(false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
}, [initializeKeyboardListener, addListener]);
|
||||||
|
const [showTips, setShowTips] = useState(false);
|
||||||
|
const [tipsText, setTipsText] = useState<string>("");
|
||||||
|
const [inputValue, setInputValue] = useState<string>("0.00");
|
||||||
|
const [walletInfo, setWalletInfo] = useState<WalletInfo>({
|
||||||
|
balance: "0.00",
|
||||||
|
});
|
||||||
|
const [isFocus, setIsFocus] = useState(false);
|
||||||
|
|
||||||
const withdrawAll = () => {
|
const [show_withdraw_popup, set_show_withdraw_popup] = useState(false);
|
||||||
setInputValue(walletInfo.balance);
|
|
||||||
validateWithdrawAmount(walletInfo.balance);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleInput = (e: any) => {
|
const [password, setPassword] = useState<string[]>(new Array(6).fill(""));
|
||||||
console.log(e);
|
|
||||||
const value = e.detail.value;
|
|
||||||
setInputValue(value);
|
|
||||||
validateWithdrawAmount(value);
|
|
||||||
};
|
|
||||||
// 加载钱包数据
|
|
||||||
const load_wallet_data = async () => {
|
|
||||||
try {
|
|
||||||
const response = await httpService.post("/wallet/balance");
|
|
||||||
const {
|
|
||||||
balance,
|
|
||||||
frozen_balance,
|
|
||||||
total_balance,
|
|
||||||
total_income,
|
|
||||||
total_withdraw,
|
|
||||||
} = response.data;
|
|
||||||
setWalletInfo({
|
|
||||||
balance,
|
|
||||||
frozen_balance,
|
|
||||||
total_balance,
|
|
||||||
total_income,
|
|
||||||
total_withdraw,
|
|
||||||
});
|
|
||||||
} catch (error: any) {
|
|
||||||
console.error("加载钱包数据失败:", error);
|
|
||||||
|
|
||||||
let errorMessage = "加载失败,请重试";
|
const [mapErrorCodes, setMapErrorCodes] = useState({});
|
||||||
if (
|
|
||||||
error &&
|
|
||||||
error.response &&
|
|
||||||
error.response.data &&
|
|
||||||
error.response.data.message
|
|
||||||
) {
|
|
||||||
errorMessage = error.response.data.message;
|
|
||||||
} else if (error && error.data && error.data.message) {
|
|
||||||
errorMessage = error.data.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
Taro.showToast({
|
useDidShow(() => {
|
||||||
title: errorMessage,
|
load_wallet_data();
|
||||||
icon: "error",
|
getWithdrawErrorCodes();
|
||||||
duration: 2000,
|
});
|
||||||
});
|
useEffect(() => {
|
||||||
}
|
if (show_withdraw_popup && inputRef.current) {
|
||||||
};
|
inputRef.current.focus();
|
||||||
const getWithdrawErrorCodes = async () => {
|
|
||||||
try {
|
|
||||||
const response = await httpService.post("/wallet/error_codes");
|
|
||||||
if (response.code === 0) {
|
|
||||||
const { withdraw_errors: { WEIXIN_ERRORS } } = response.data;
|
|
||||||
const mapErrorCodes = {};
|
|
||||||
for (const key in WEIXIN_ERRORS) {
|
|
||||||
const { code } = WEIXIN_ERRORS[key];
|
|
||||||
mapErrorCodes[code] = WEIXIN_ERRORS[key];
|
|
||||||
}
|
|
||||||
setMapErrorCodes(mapErrorCodes);
|
|
||||||
}
|
|
||||||
} catch (error: any) {
|
|
||||||
console.error("获取提现错误码失败:", error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const handleWithdraw = async () => {
|
}, [show_withdraw_popup]);
|
||||||
set_show_withdraw_popup(true);
|
useEffect(() => {
|
||||||
};
|
if (show_withdraw_popup) {
|
||||||
const submit_withdraw = async (payment_password: string) => {
|
setIsFocus(true);
|
||||||
try {
|
} else {
|
||||||
// 先调用后端接口获取提现参数
|
setPassword(new Array(6).fill(""));
|
||||||
const response = await httpService.post("/wallet/withdraw", {
|
setIsFocus(false);
|
||||||
amount: parseFloat(inputValue),
|
}
|
||||||
transfer_remark: "用户申请提现",
|
}, [show_withdraw_popup]);
|
||||||
payment_password,
|
|
||||||
}, { showToast: false });
|
|
||||||
const { data } = response;
|
|
||||||
// 根据后端返回的数据结构解析参数
|
|
||||||
const { mch_id, app_id, package_info, open_id } = data;
|
|
||||||
|
|
||||||
console.log("/wallet/withdraw:", data);
|
const validateWithdrawAmount = (amount: string) => {
|
||||||
set_show_withdraw_popup(false);
|
if (Number(amount) > Number(walletInfo.balance)) {
|
||||||
|
setShowTips(true);
|
||||||
|
setTipsText("输入金额超过钱包余额");
|
||||||
|
} else if (Number(amount) > 200) {
|
||||||
|
setShowTips(true);
|
||||||
|
setTipsText("单笔提现金额不能超过 200元");
|
||||||
|
} else {
|
||||||
|
setShowTips(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 调用微信商户转账接口
|
const withdrawAll = () => {
|
||||||
(Taro as any).requestMerchantTransfer({
|
setInputValue(walletInfo.balance);
|
||||||
mchId: mch_id,
|
validateWithdrawAmount(walletInfo.balance);
|
||||||
appId: app_id,
|
};
|
||||||
package: package_info,
|
|
||||||
openId: open_id,
|
|
||||||
success: (res) => {
|
|
||||||
console.log("微信转账成功:", res);
|
|
||||||
Taro.showToast({
|
|
||||||
title: "提现成功",
|
|
||||||
icon: "success",
|
|
||||||
duration: 2000,
|
|
||||||
});
|
|
||||||
|
|
||||||
// 关闭弹窗并重置状态
|
const handleInput = (e: any) => {
|
||||||
set_show_withdraw_popup(false);
|
console.log(e);
|
||||||
setInputValue("0.00");
|
const value = e.detail.value;
|
||||||
// 重新加载数据
|
setInputValue(value);
|
||||||
load_wallet_data();
|
validateWithdrawAmount(value);
|
||||||
},
|
};
|
||||||
fail: (res) => {
|
// 加载钱包数据
|
||||||
console.log("微信转账失败:", res);
|
const load_wallet_data = async () => {
|
||||||
},
|
try {
|
||||||
|
const response = await httpService.post("/wallet/balance");
|
||||||
|
const {
|
||||||
|
balance,
|
||||||
|
frozen_balance,
|
||||||
|
total_balance,
|
||||||
|
total_income,
|
||||||
|
total_withdraw,
|
||||||
|
} = response.data;
|
||||||
|
setWalletInfo({
|
||||||
|
balance,
|
||||||
|
frozen_balance,
|
||||||
|
total_balance,
|
||||||
|
total_income,
|
||||||
|
total_withdraw,
|
||||||
|
});
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error("加载钱包数据失败:", error);
|
||||||
|
|
||||||
|
let errorMessage = "加载失败,请重试";
|
||||||
|
if (
|
||||||
|
error &&
|
||||||
|
error.response &&
|
||||||
|
error.response.data &&
|
||||||
|
error.response.data.message
|
||||||
|
) {
|
||||||
|
errorMessage = error.response.data.message;
|
||||||
|
} else if (error && error.data && error.data.message) {
|
||||||
|
errorMessage = error.data.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
Taro.showToast({
|
||||||
|
title: errorMessage,
|
||||||
|
icon: "error",
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const getWithdrawErrorCodes = async () => {
|
||||||
|
try {
|
||||||
|
const response = await httpService.post("/wallet/error_codes");
|
||||||
|
if (response.code === 0) {
|
||||||
|
const {
|
||||||
|
withdraw_errors: { WEIXIN_ERRORS },
|
||||||
|
} = response.data;
|
||||||
|
const mapErrorCodes = {};
|
||||||
|
for (const key in WEIXIN_ERRORS) {
|
||||||
|
const { code } = WEIXIN_ERRORS[key];
|
||||||
|
mapErrorCodes[code] = WEIXIN_ERRORS[key];
|
||||||
|
}
|
||||||
|
setMapErrorCodes(mapErrorCodes);
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error("获取提现错误码失败:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const handleWithdraw = async () => {
|
||||||
|
set_show_withdraw_popup(true);
|
||||||
|
};
|
||||||
|
const submit_withdraw = async (payment_password: string) => {
|
||||||
|
try {
|
||||||
|
// 先调用后端接口获取提现参数
|
||||||
|
const response = await httpService.post(
|
||||||
|
"/wallet/withdraw",
|
||||||
|
{
|
||||||
|
amount: parseFloat(inputValue),
|
||||||
|
transfer_remark: "用户申请提现",
|
||||||
|
payment_password,
|
||||||
|
},
|
||||||
|
{ showToast: false }
|
||||||
|
);
|
||||||
|
const { data } = response;
|
||||||
|
// 根据后端返回的数据结构解析参数
|
||||||
|
const { mch_id, app_id, package_info, open_id } = data;
|
||||||
|
|
||||||
|
console.log("/wallet/withdraw:", data);
|
||||||
|
set_show_withdraw_popup(false);
|
||||||
|
|
||||||
|
// 调用微信商户转账接口
|
||||||
|
(Taro as any).requestMerchantTransfer({
|
||||||
|
mchId: mch_id,
|
||||||
|
appId: app_id,
|
||||||
|
package: package_info,
|
||||||
|
openId: open_id,
|
||||||
|
success: (res) => {
|
||||||
|
console.log("微信转账成功:", res);
|
||||||
|
Taro.showToast({
|
||||||
|
title: "提现成功",
|
||||||
|
icon: "success",
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 关闭弹窗并重置状态
|
||||||
|
set_show_withdraw_popup(false);
|
||||||
|
setInputValue("0.00");
|
||||||
|
// 重新加载数据
|
||||||
|
load_wallet_data();
|
||||||
|
},
|
||||||
|
fail: (res) => {
|
||||||
|
console.log("微信转账失败:", res);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error: any) {
|
||||||
|
const { code, message } = error;
|
||||||
|
if (message === "支付密码错误") {
|
||||||
|
set_show_withdraw_popup(false);
|
||||||
|
Taro.showModal({
|
||||||
|
content: "支付密码错误,请重试",
|
||||||
|
cancelText: "忘记密码",
|
||||||
|
confirmText: "重试",
|
||||||
|
cancelColor: "#000",
|
||||||
|
confirmColor: "#fff",
|
||||||
|
}).then((res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
set_show_withdraw_popup(true);
|
||||||
|
} else if (res.cancel) {
|
||||||
|
Taro.navigateTo({
|
||||||
|
url: "/user_pages/validPhone/index",
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
}
|
||||||
const { code, message } = error;
|
});
|
||||||
if (message === "支付密码错误") {
|
return;
|
||||||
set_show_withdraw_popup(false);
|
} else if (mapErrorCodes[code]) {
|
||||||
Taro.showModal({
|
const { message, description } = mapErrorCodes[code];
|
||||||
content: "支付密码错误,请重试",
|
Taro.showModal({
|
||||||
cancelText: "忘记密码",
|
title: description,
|
||||||
confirmText: "重试",
|
content: message,
|
||||||
cancelColor: "#000",
|
showCancel: false,
|
||||||
confirmColor: "#fff",
|
confirmText: "确认",
|
||||||
}).then((res) => {
|
});
|
||||||
if (res.confirm) {
|
return;
|
||||||
set_show_withdraw_popup(true);
|
} else {
|
||||||
} else if (res.cancel) {
|
Taro.showToast({
|
||||||
Taro.navigateTo({
|
title: message,
|
||||||
url: "/user_pages/validPhone/index"
|
icon: "none",
|
||||||
});
|
duration: 2000,
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
return;
|
|
||||||
} else if (mapErrorCodes[code]) {
|
|
||||||
const { message, description } = mapErrorCodes[code];
|
|
||||||
Taro.showModal({
|
|
||||||
title: description,
|
|
||||||
content: message,
|
|
||||||
showCancel: false,
|
|
||||||
confirmText: "确认",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
Taro.showToast({
|
|
||||||
title: message,
|
|
||||||
icon: "none",
|
|
||||||
duration: 2000,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const handlePasswordInput = (e: any) => {
|
};
|
||||||
const value = e.detail.value;
|
const handlePasswordInput = (e: any) => {
|
||||||
const [one = "", two = "", three = "", four = "", five = "", six = ""] = value.split("");
|
const value = e.detail.value;
|
||||||
setPassword([one, two, three, four, five, six]);
|
const [one = "", two = "", three = "", four = "", five = "", six = ""] =
|
||||||
if (value.length === 6) {
|
value.split("");
|
||||||
const timer = setTimeout(() => {
|
setPassword([one, two, three, four, five, six]);
|
||||||
submit_withdraw(value);
|
if (value.length === 6) {
|
||||||
clearTimeout(timer);
|
const timer = setTimeout(() => {
|
||||||
}, 100);
|
submit_withdraw(value);
|
||||||
}
|
clearTimeout(timer);
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
const handlePopupClick = (e) => {
|
};
|
||||||
e.preventDefault()
|
const handlePopupClick = (e) => {
|
||||||
e.stopPropagation()
|
e.preventDefault();
|
||||||
e.nativeEvent.stopImmediatePropagation()
|
e.stopPropagation();
|
||||||
inputRef.current!.focus();
|
e.nativeEvent.stopImmediatePropagation();
|
||||||
};
|
inputRef.current!.focus();
|
||||||
return (
|
};
|
||||||
<View className="withdrawal-page" >
|
return (
|
||||||
<View className="withdrawal-container">
|
<View className="withdrawal-page">
|
||||||
<Text className="title-text">提现金额</Text>
|
{/* 导航栏 */}
|
||||||
<View className="input-container">
|
<View className="custom-navbar">
|
||||||
<Text className="symbol">¥</Text>
|
<View className="detail-navigator">
|
||||||
<Input type="digit" placeholder="0.00" cursorColor="#000" value={inputValue} onInput={handleInput} />
|
<View
|
||||||
{
|
className="detail-navigator-back"
|
||||||
!showTips && (Number(inputValue) !== 0) && (
|
onClick={() => {
|
||||||
<Button className="btn" onClick={handleWithdraw}>提现</Button>
|
Taro.navigateBack();
|
||||||
)
|
}}
|
||||||
}
|
>
|
||||||
</View>
|
<Image
|
||||||
<View className="btn-container">
|
className="detail-navigator-back-icon"
|
||||||
<View>
|
src={img.ICON_NAVIGATOR_BACK}
|
||||||
<Text>{`我的余额:¥${walletInfo.balance}`}</Text>
|
/>
|
||||||
{/* <Text>(可提现余额:¥5000.00)</Text> */}
|
<Text>{pageTitle}</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text className="btn" onClick={withdrawAll}>全部提现</Text>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{
|
<View className="withdrawal-container">
|
||||||
showTips && (
|
<Text className="title-text">提现金额</Text>
|
||||||
<View className="tips-text">{tipsText}</View>
|
<View className="input-container">
|
||||||
)
|
<Text className="symbol">¥</Text>
|
||||||
}
|
<Input
|
||||||
</View>
|
type="digit"
|
||||||
<View className="tips-container">
|
placeholder="0.00"
|
||||||
<View className="title-text">提现须知</View>
|
cursorColor="#000"
|
||||||
<View className="tips-text">
|
value={inputValue}
|
||||||
<Text>1. 本钱包余额由平台统一管理,提现服务由 微信支付(财付通) 提供。</Text>
|
onInput={handleInput}
|
||||||
<Text>2. 提现仅支持提现至本人实名认证的微信支付账户,请确保账户信息真实有效。</Text>
|
/>
|
||||||
<Text>3. 每次提现金额不得超过钱包余额,且需满足提现金额最低限制(如有)。</Text>
|
{!showTips && Number(inputValue) !== 0 && (
|
||||||
<Text>4. 正常情况下提现 实时到账,如遇网络、系统或银行通道原因,可能会有延迟。</Text>
|
<Button className="btn" onClick={handleWithdraw}>
|
||||||
<Text>5. 提现过程中平台不收取任何手续费,如微信支付有特殊规则,按其实际规定执行。</Text>
|
提现
|
||||||
<Text>6. 若发现异常交易、涉嫌违规或存在风险,平台有权暂停或拒绝提现操作。</Text>
|
</Button>
|
||||||
<Text>7. 实际到账结果以 微信支付通知 为准。</Text>
|
)}
|
||||||
|
</View>
|
||||||
|
<View className="btn-container">
|
||||||
|
<View>
|
||||||
|
<Text>{`我的余额:¥${walletInfo.balance}`}</Text>
|
||||||
|
{/* <Text>(可提现余额:¥5000.00)</Text> */}
|
||||||
|
</View>
|
||||||
|
<Text className="btn" onClick={withdrawAll}>
|
||||||
|
全部提现
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
{showTips && <View className="tips-text">{tipsText}</View>}
|
||||||
|
</View>
|
||||||
|
<View className="tips-container">
|
||||||
|
<View className="title-text">提现须知</View>
|
||||||
|
<View className="tips-text">
|
||||||
|
<Text>
|
||||||
|
1. 本钱包余额由平台统一管理,提现服务由 微信支付(财付通) 提供。
|
||||||
|
</Text>
|
||||||
|
<Text>
|
||||||
|
2.
|
||||||
|
提现仅支持提现至本人实名认证的微信支付账户,请确保账户信息真实有效。
|
||||||
|
</Text>
|
||||||
|
<Text>
|
||||||
|
3. 每次提现金额不得超过钱包余额,且需满足提现金额最低限制(如有)。
|
||||||
|
</Text>
|
||||||
|
<Text>
|
||||||
|
4. 正常情况下提现
|
||||||
|
实时到账,如遇网络、系统或银行通道原因,可能会有延迟。
|
||||||
|
</Text>
|
||||||
|
<Text>
|
||||||
|
5.
|
||||||
|
提现过程中平台不收取任何手续费,如微信支付有特殊规则,按其实际规定执行。
|
||||||
|
</Text>
|
||||||
|
<Text>
|
||||||
|
6. 若发现异常交易、涉嫌违规或存在风险,平台有权暂停或拒绝提现操作。
|
||||||
|
</Text>
|
||||||
|
<Text>7. 实际到账结果以 微信支付通知 为准。</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View className="tips-container">
|
||||||
|
<View className="title-text">免费声明</View>
|
||||||
|
<View className="tips-text">
|
||||||
|
<Text>1. 本平台不向用户收取提现手续费,提现服务免费。</Text>
|
||||||
|
<Text>2. 若因银行或微信支付方收取相关费用,与本平台无关。</Text>
|
||||||
|
<Text>
|
||||||
|
3. 因网络、系统或第三方原因造成的延迟、失败,本平台不承担责任。
|
||||||
|
</Text>
|
||||||
|
<Text>4. 用户在使用提现服务前,应充分了解并同意上述规则。</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
</View>
|
{/* 提现输入密码弹窗 */}
|
||||||
</View>
|
<CommonPopup
|
||||||
<View className="tips-container">
|
showHeader={true}
|
||||||
<View className="title-text">免费声明</View>
|
visible={show_withdraw_popup}
|
||||||
<View className="tips-text">
|
onClose={() => set_show_withdraw_popup(false)}
|
||||||
<Text>1. 本平台不向用户收取提现手续费,提现服务免费。</Text>
|
title="提现"
|
||||||
<Text>2. 若因银行或微信支付方收取相关费用,与本平台无关。</Text>
|
className="withdraw_popup"
|
||||||
<Text>3. 因网络、系统或第三方原因造成的延迟、失败,本平台不承担责任。</Text>
|
hideFooter={true}
|
||||||
<Text>4. 用户在使用提现服务前,应充分了解并同意上述规则。</Text>
|
style={{
|
||||||
</View>
|
bottom: isKeyboardVisible ? `${keyboardHeight}px` : undefined,
|
||||||
</View>
|
}}
|
||||||
|
>
|
||||||
{/* 提现输入密码弹窗 */}
|
<View
|
||||||
<CommonPopup
|
className="popup_content"
|
||||||
showHeader={true}
|
onTouchForceChange={handlePopupClick}
|
||||||
visible={show_withdraw_popup}
|
onTouchStart={handlePopupClick}
|
||||||
onClose={() => set_show_withdraw_popup(false)}
|
onTouchMove={handlePopupClick}
|
||||||
title="提现"
|
onTouchEnd={handlePopupClick}
|
||||||
className="withdraw_popup"
|
>
|
||||||
hideFooter={true}
|
<View className="popup_text">{`¥${inputValue}`}</View>
|
||||||
style={{ bottom: isKeyboardVisible ? `${keyboardHeight}px` : undefined }}
|
<View className="password_container">
|
||||||
>
|
{password.map((item, index) => (
|
||||||
<View className="popup_content" onTouchForceChange={handlePopupClick} onTouchStart={handlePopupClick} onTouchMove={handlePopupClick} onTouchEnd={handlePopupClick}>
|
<View key={index} className="password_item">
|
||||||
<View className="popup_text">{`¥${inputValue}`}</View>
|
<Text className="password_text">{item}</Text>
|
||||||
<View className="password_container">
|
</View>
|
||||||
{
|
))}
|
||||||
password.map((item, index) => (
|
</View>
|
||||||
<View key={index} className="password_item">
|
<Input
|
||||||
<Text className="password_text">{item}</Text>
|
holdKeyboard={true}
|
||||||
</View>
|
ref={inputRef}
|
||||||
))
|
focus={isFocus}
|
||||||
}
|
type="number"
|
||||||
</View>
|
adjustPosition={false}
|
||||||
<Input holdKeyboard={true} 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} onBlur={() => { set_show_withdraw_popup(false) }} />
|
style={{ width: "0", height: "0", opacity: "0" }}
|
||||||
</View>
|
value={password.filter((item) => item !== "").join("")}
|
||||||
</CommonPopup>
|
maxlength={6}
|
||||||
</View >
|
onInput={handlePasswordInput}
|
||||||
);
|
onBlur={() => {
|
||||||
|
set_show_withdraw_popup(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</CommonPopup>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Withdrawal;
|
export default Withdrawal;
|
||||||
|
|||||||
Reference in New Issue
Block a user