diff --git a/CONFIG.md b/docs/CONFIG.md similarity index 100% rename from CONFIG.md rename to docs/CONFIG.md diff --git a/LOGIN_STATUS_UPDATE_TEST.md b/docs/LOGIN_STATUS_UPDATE_TEST.md similarity index 100% rename from LOGIN_STATUS_UPDATE_TEST.md rename to docs/LOGIN_STATUS_UPDATE_TEST.md diff --git a/RUNTIME_ERROR_RESOLUTION.md b/docs/RUNTIME_ERROR_RESOLUTION.md similarity index 100% rename from RUNTIME_ERROR_RESOLUTION.md rename to docs/RUNTIME_ERROR_RESOLUTION.md diff --git a/TYPESCRIPT_FIXES.md b/docs/TYPESCRIPT_FIXES.md similarity index 100% rename from TYPESCRIPT_FIXES.md rename to docs/TYPESCRIPT_FIXES.md diff --git a/头像昵称同步问题修复说明.md b/docs/头像昵称同步问题修复说明.md similarity index 100% rename from 头像昵称同步问题修复说明.md rename to docs/头像昵称同步问题修复说明.md diff --git a/头像昵称显示问题修复说明.md b/docs/头像昵称显示问题修复说明.md similarity index 100% rename from 头像昵称显示问题修复说明.md rename to docs/头像昵称显示问题修复说明.md diff --git a/客户交易页面上拉加载功能实现说明.md b/docs/客户交易页面上拉加载功能实现说明.md similarity index 100% rename from 客户交易页面上拉加载功能实现说明.md rename to docs/客户交易页面上拉加载功能实现说明.md diff --git a/客户管理上拉加载功能实现说明.md b/docs/客户管理上拉加载功能实现说明.md similarity index 100% rename from 客户管理上拉加载功能实现说明.md rename to docs/客户管理上拉加载功能实现说明.md diff --git a/报备成功后列表刷新问题修复说明.md b/docs/报备成功后列表刷新问题修复说明.md similarity index 100% rename from 报备成功后列表刷新问题修复说明.md rename to docs/报备成功后列表刷新问题修复说明.md diff --git a/用户信息缓存丢失问题修复说明.md b/docs/用户信息缓存丢失问题修复说明.md similarity index 100% rename from 用户信息缓存丢失问题修复说明.md rename to docs/用户信息缓存丢失问题修复说明.md diff --git a/签约时间和合同日期选择功能实现说明.md b/docs/签约时间和合同日期选择功能实现说明.md similarity index 100% rename from 签约时间和合同日期选择功能实现说明.md rename to docs/签约时间和合同日期选择功能实现说明.md diff --git a/订单筛选查询功能说明.md b/docs/订单筛选查询功能说明.md similarity index 100% rename from 订单筛选查询功能说明.md rename to docs/订单筛选查询功能说明.md diff --git a/src/api/shop/shopDealerBank/index.ts b/src/api/shop/shopDealerBank/index.ts new file mode 100644 index 0000000..bc6eaf6 --- /dev/null +++ b/src/api/shop/shopDealerBank/index.ts @@ -0,0 +1,101 @@ +import request from '@/utils/request'; +import type { ApiResult, PageResult } from '@/api'; +import type { ShopDealerBank, ShopDealerBankParam } from './model'; + +/** + * 分页查询分销商银行卡 + */ +export async function pageShopDealerBank(params: ShopDealerBankParam) { + const res = await request.get>>( + '/shop/shop-dealer-bank/page', + params + ); + if (res.code === 0) { + return res.data; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 查询分销商银行卡列表 + */ +export async function listShopDealerBank(params?: ShopDealerBankParam) { + const res = await request.get>( + 'http://127.0.0.1:9200/api/shop/shop-dealer-bank', + params + ); + if (res.code === 0 && res.data) { + return res.data; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 添加分销商银行卡 + */ +export async function addShopDealerBank(data: ShopDealerBank) { + const res = await request.post>( + '/shop/shop-dealer-bank', + data + ); + if (res.code === 0) { + return res.message; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 修改分销商银行卡 + */ +export async function updateShopDealerBank(data: ShopDealerBank) { + const res = await request.put>( + '/shop/shop-dealer-bank', + data + ); + if (res.code === 0) { + return res.message; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 删除分销商银行卡 + */ +export async function removeShopDealerBank(id?: number) { + const res = await request.del>( + '/shop/shop-dealer-bank/' + id + ); + if (res.code === 0) { + return res.message; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 批量删除分销商银行卡 + */ +export async function removeBatchShopDealerBank(data: (number | undefined)[]) { + const res = await request.del>( + '/shop/shop-dealer-bank/batch', + { + data + } + ); + if (res.code === 0) { + return res.message; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 根据id查询分销商银行卡 + */ +export async function getShopDealerBank(id: number) { + const res = await request.get>( + '/shop/shop-dealer-bank/' + id + ); + if (res.code === 0 && res.data) { + return res.data; + } + return Promise.reject(new Error(res.message)); +} diff --git a/src/api/shop/shopDealerBank/model/index.ts b/src/api/shop/shopDealerBank/model/index.ts new file mode 100644 index 0000000..0fbd93b --- /dev/null +++ b/src/api/shop/shopDealerBank/model/index.ts @@ -0,0 +1,45 @@ +import type { PageParam } from '@/api'; + +/** + * 分销商提现银行卡 + */ +export interface ShopDealerBank { + // 主键ID + id?: number; + // 分销商用户ID + userId?: number; + // 开户行名称 + bankName?: string; + // 银行开户名 + bankAccount?: string; + // 银行卡号 + bankCard?: string; + // 申请状态 (10待审核 20审核通过 30驳回) + applyStatus?: number; + // 审核时间 + auditTime?: number; + // 驳回原因 + rejectReason?: string; + // 是否默认 + isDefault?: boolean; + // 租户id + tenantId?: number; + // 创建时间 + createTime?: string; + // 修改时间 + updateTime?: string; + // 类型 + type?: string; + // 名称 + name?: string; +} + +/** + * 分销商提现银行卡搜索条件 + */ +export interface ShopDealerBankParam extends PageParam { + id?: number; + userId?: number; + isDefault?: boolean; + keywords?: string; +} diff --git a/src/api/shop/shopDealerWithdraw/model/index.ts b/src/api/shop/shopDealerWithdraw/model/index.ts index d53db44..4fd07d9 100644 --- a/src/api/shop/shopDealerWithdraw/model/index.ts +++ b/src/api/shop/shopDealerWithdraw/model/index.ts @@ -1,4 +1,4 @@ -import type { PageParam } from '@/api/index'; +import type { PageParam } from '@/api'; /** * 分销商提现明细表 diff --git a/src/app.config.ts b/src/app.config.ts index 39b34e4..4fa7148 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -67,7 +67,9 @@ export default defineAppConfig({ "customer/index", "customer/add", "customer/trading", - "wechat/index" + "wechat/index", + "bank/index", + "bank/add" ] }, // { diff --git a/src/dealer/bank/add.config.ts b/src/dealer/bank/add.config.ts new file mode 100644 index 0000000..e07ffad --- /dev/null +++ b/src/dealer/bank/add.config.ts @@ -0,0 +1,4 @@ +export default definePageConfig({ + navigationBarTitleText: '添加银行卡', + navigationBarTextStyle: 'black' +}) diff --git a/src/dealer/bank/add.tsx b/src/dealer/bank/add.tsx new file mode 100644 index 0000000..ef11e80 --- /dev/null +++ b/src/dealer/bank/add.tsx @@ -0,0 +1,142 @@ +import {useEffect, useState, useRef} from "react"; +import {useRouter} from '@tarojs/taro' +import {Loading, CellGroup, Input, Form} from '@nutui/nutui-react-taro' +import Taro from '@tarojs/taro' +import { + getShopDealerBank, + listShopDealerBank, + updateShopDealerBank, + addShopDealerBank +} from "@/api/shop/shopDealerBank"; +import FixedButton from "@/components/FixedButton"; +import {ShopDealerBank} from "@/api/shop/shopDealerBank/model"; + +const AddUserAddress = () => { + const {params} = useRouter(); + const [loading, setLoading] = useState(true) + const [FormData, setFormData] = useState() + const formRef = useRef(null) + + // 判断是编辑还是新增模式 + const isEditMode = !!params.id + const bankId = params.id ? Number(params.id) : undefined + + const reload = async () => { + // 如果是编辑模式,加载地址数据 + if (isEditMode && bankId) { + try { + const bank = await getShopDealerBank(bankId) + setFormData(bank) + } catch (error) { + console.error('加载地址失败:', error) + Taro.showToast({ + title: '加载地址失败', + icon: 'error' + }); + } + } + } + + // 提交表单 + const submitSucceed = async (values: any) => { + console.log('.>>>>>>,....') + try { + // 准备提交的数据 + const submitData = { + ...values, + isDefault: true // 新增或编辑的地址都设为默认地址 + }; + + console.log('提交数据:', submitData) + + // 如果是编辑模式,添加id + if (isEditMode && bankId) { + submitData.id = bankId; + } + + // 先处理默认地址逻辑 + const defaultAddress = await listShopDealerBank({isDefault: true}); + if (defaultAddress && defaultAddress.length > 0) { + // 如果当前编辑的不是默认地址,或者是新增地址,需要取消其他默认地址 + if (!isEditMode || (isEditMode && defaultAddress[0].id !== bankId)) { + await updateShopDealerBank({ + ...defaultAddress[0], + isDefault: false + }); + } + } + + // 执行新增或更新操作 + if (isEditMode) { + await updateShopDealerBank(submitData); + } else { + await addShopDealerBank(submitData); + } + + Taro.showToast({ + title: `${isEditMode ? '更新' : '保存'}成功`, + icon: 'success' + }); + + setTimeout(() => { + Taro.navigateBack(); + }, 1000); + + } catch (error) { + console.error('保存失败:', error); + Taro.showToast({ + title: `${isEditMode ? '更新' : '保存'}失败`, + icon: 'error' + }); + } + } + + const submitFailed = (error: any) => { + console.log(error, 'err...') + } + + useEffect(() => { + // 动态设置页面标题 + Taro.setNavigationBarTitle({ + title: isEditMode ? '编辑银行卡' : '添加银行卡' + }); + + reload().then(() => { + setLoading(false) + }) + }, [isEditMode]); + + if (loading) { + return 加载中 + } + + return ( + <> +
submitSucceed(values)} + onFinishFailed={(errors) => submitFailed(errors)} + > + + + + + + + + + + + +
+ + {/* 底部浮动按钮 */} + formRef.current?.submit()}/> + + ); +}; + +export default AddUserAddress; diff --git a/src/dealer/bank/index.config.ts b/src/dealer/bank/index.config.ts new file mode 100644 index 0000000..8f92036 --- /dev/null +++ b/src/dealer/bank/index.config.ts @@ -0,0 +1,4 @@ +export default definePageConfig({ + navigationBarTitleText: '银行卡管理', + navigationBarTextStyle: 'black' +}) diff --git a/src/dealer/bank/index.tsx b/src/dealer/bank/index.tsx new file mode 100644 index 0000000..71046ff --- /dev/null +++ b/src/dealer/bank/index.tsx @@ -0,0 +1,134 @@ +import {useState} from "react"; +import Taro, {useDidShow} from '@tarojs/taro' +import {Button, Cell, Space, Empty, ConfigProvider} from '@nutui/nutui-react-taro' +import {CheckNormal, Checked} from '@nutui/icons-react-taro' +import {View} from '@tarojs/components' +import {ShopDealerBank} from "@/api/shop/shopDealerBank/model"; +import {listShopDealerBank, removeShopDealerBank, updateShopDealerBank} from "@/api/shop/shopDealerBank"; +import FixedButton from "@/components/FixedButton"; + +const DealerBank = () => { + const [list, setList] = useState([]) + const [bank, setAddress] = useState() + + const reload = () => { + listShopDealerBank({}) + .then(data => { + setList(data || []) + // 默认地址 + setAddress(data.find(item => item.isDefault)) + }) + .catch(() => { + Taro.showToast({ + title: '获取地址失败', + icon: 'error' + }); + }) + } + + const onDefault = async (item: ShopDealerBank) => { + if (bank) { + await updateShopDealerBank({ + ...bank, + isDefault: false + }) + } + await updateShopDealerBank({ + id: item.id, + isDefault: true + }) + Taro.showToast({ + title: '设置成功', + icon: 'success' + }); + reload(); + } + + const onDel = async (id?: number) => { + await removeShopDealerBank(id) + Taro.showToast({ + title: '删除成功', + icon: 'success' + }); + reload(); + } + + const selectAddress = async (item: ShopDealerBank) => { + if (bank) { + await updateShopDealerBank({ + ...bank, + isDefault: false + }) + } + await updateShopDealerBank({ + id: item.id, + isDefault: true + }) + setTimeout(() => { + Taro.navigateBack() + }, 500) + } + + useDidShow(() => { + reload() + }); + + if (list.length == 0) { + return ( + +
+ + + + + +
+
+ ) + } + + return ( + + {list.map((item, _) => ( + + selectAddress(item)}> + + {item.bankName} + + + {item.bankCard} {item.bankAccount} + + + onDefault(item)}> + {item.isDefault ? : } + 选择 + + } + extra={ + <> + onDel(item.id)}> + 删除 + + + } + /> + + ))} + {/* 底部浮动按钮 */} + Taro.navigateTo({url: '/dealer/bank/add'})} /> + + ); +}; + +export default DealerBank; diff --git a/src/dealer/customer/trading.tsx b/src/dealer/customer/trading.tsx index 8f2c410..f5bb0a5 100644 --- a/src/dealer/customer/trading.tsx +++ b/src/dealer/customer/trading.tsx @@ -122,7 +122,7 @@ const CustomerTrading = () => { - 统一代码:{customer.dealerCode} + {/*统一代码:{customer.dealerCode}*/} 入市时间:{customer.createTime} diff --git a/src/dealer/index.tsx b/src/dealer/index.tsx index 06c514f..2c9d6a0 100644 --- a/src/dealer/index.tsx +++ b/src/dealer/index.tsx @@ -132,7 +132,7 @@ const DealerIndex: React.FC = () => { 佣金统计 - @@ -140,7 +140,7 @@ const DealerIndex: React.FC = () => { 可提现 - @@ -148,7 +148,7 @@ const DealerIndex: React.FC = () => { 冻结中 - diff --git a/src/dealer/orders/index.tsx b/src/dealer/orders/index.tsx index 2a513bd..63ea8ac 100644 --- a/src/dealer/orders/index.tsx +++ b/src/dealer/orders/index.tsx @@ -133,15 +133,6 @@ const DealerOrders: React.FC = () => { ) - if (!dealerUser) { - return ( - - - 加载中... - - ) - } - return ( { if (!dealerUser) { return ( - + navTo(`/dealer/apply/add`,true)}]} diff --git a/src/dealer/withdraw/index.tsx b/src/dealer/withdraw/index.tsx index 9a3fbfe..456d139 100644 --- a/src/dealer/withdraw/index.tsx +++ b/src/dealer/withdraw/index.tsx @@ -4,22 +4,23 @@ import { Cell, Space, Button, - Form, Input, CellGroup, - Radio, Tabs, Tag, Empty, + ActionSheet, Loading, PullToRefresh } from '@nutui/nutui-react-taro' -import {Wallet} from '@nutui/icons-react-taro' +import {Wallet, ArrowRight} from '@nutui/icons-react-taro' import {businessGradients} from '@/styles/gradients' import Taro from '@tarojs/taro' import {useDealerUser} from '@/hooks/useDealerUser' import {pageShopDealerWithdraw, addShopDealerWithdraw} from '@/api/shop/shopDealerWithdraw' import type {ShopDealerWithdraw} from '@/api/shop/shopDealerWithdraw/model' +import {ShopDealerBank} from "@/api/shop/shopDealerBank/model"; +import {listShopDealerBank} from "@/api/shop/shopDealerBank"; interface WithdrawRecordWithDetails extends ShopDealerWithdraw { accountDisplay?: string @@ -31,6 +32,9 @@ const DealerWithdraw: React.FC = () => { const [loading, setLoading] = useState(false) const [refreshing, setRefreshing] = useState(false) const [submitting, setSubmitting] = useState(false) + const [banks, setBanks] = useState([]) + const [bank, setBank] = useState() + const [isVisible, setIsVisible] = useState(false) const [availableAmount, setAvailableAmount] = useState('0.00') const [withdrawRecords, setWithdrawRecords] = useState([]) const formRef = useRef(null) @@ -88,6 +92,21 @@ const DealerWithdraw: React.FC = () => { } }, [dealerUser?.userId]) + function fetchBanks() { + listShopDealerBank({}).then(data => { + const list = data.map(d => { + d.name = d.bankName; + d.type = d.bankName; + return d; + }) + setBanks(list.concat({ + name: '管理银行卡', + type: 'add' + })) + setBank(data[0]) + }) + } + // 格式化账户显示 const getAccountDisplay = (record: ShopDealerWithdraw) => { if (record.payType === 10) { @@ -107,11 +126,22 @@ const DealerWithdraw: React.FC = () => { setRefreshing(false) } + const handleSelect = (item: ShopDealerBank) => { + if(item.type === 'add'){ + return Taro.navigateTo({ + url: '/dealer/bank/index' + }) + } + setBank(item) + setIsVisible(false) + } + // 初始化加载数据 useEffect(() => { if (dealerUser?.userId) { fetchBalance().then() fetchWithdrawRecords().then() + fetchBanks() } }, [fetchBalance, fetchWithdrawRecords]) @@ -259,16 +289,6 @@ const DealerWithdraw: React.FC = () => { } } - const quickAmounts = ['100', '300', '500', '1000'] - - const setQuickAmount = (amount: string) => { - formRef.current?.setFieldsValue({amount}) - } - - const setAllAmount = () => { - formRef.current?.setFieldsValue({amount: availableAmount.replace(/,/g, '')}) - } - // 格式化金额 const formatMoney = (money?: string) => { if (!money) return '0.00' @@ -303,121 +323,55 @@ const DealerWithdraw: React.FC = () => { borderTop: '1px solid rgba(255, 255, 255, 0.3)' }}> - 最低提现金额:¥100 | 手续费:每笔3元 + 最低提现金额:¥100 -
- - + + + { - // 实时验证提现金额 - const amount = parseFloat(value) - const available = parseFloat(availableAmount.replace(/,/g, '')) - if (!isNaN(amount) && amount > available) { - // 可以在这里添加实时提示,但不阻止输入 - } + maxLength={7} + style={{ + padding: '0 10px', + fontSize: '20px' }} /> - - - {/* 快捷金额 */} - - 快捷金额 - - {quickAmounts.map(amount => ( - - ))} - - + + } + /> + setIsVisible(true)} extra={ + + {bank ? {bank.bankName} : 请选择} + + + }/> + + ¥2141.41 + + }/> + - - setSelectedAccount}> - - - 微信钱包 - - - 支付宝 - - - 银行卡 - - - 对公转账 - - - - - - {selectedAccount === 'alipay' && ( - <> - - - - - - - - )} - - {selectedAccount === 'bank' && ( - <> - - - - - - - - - - - )} - - {selectedAccount === 'wechat' && ( - - - 微信钱包提现将直接转入您的微信零钱 - - - )} - - - - - -
+ + + ) @@ -475,15 +429,6 @@ const DealerWithdraw: React.FC = () => { ) } - if (!dealerUser) { - return ( - - - 加载中... - - ) - } - return ( @@ -495,6 +440,12 @@ const DealerWithdraw: React.FC = () => { {renderWithdrawRecords()} + setIsVisible(false)} + /> ) }