feat(dealer): 添加配送员解冻资金功能
- 在dealer页面添加配送员权限判断和解冻资金功能 - 导入useUser hook和updateShopDealerUser API - 仅配送员角色可操作冻结金额转入可提现 - 点击待使用金额弹出确认框进行资金转移 - 统一rider和dealer页面的解冻资金逻辑实现 - 修改环境配置支持SERVER_API_URL变量导出 - 更新版权信息配置结构优化代码注释 - 优化待使用金额卡片点击交互体验
This commit is contained in:
@@ -10,8 +10,10 @@ import {
|
||||
People
|
||||
} from '@nutui/icons-react-taro'
|
||||
import {useDealerUser} from '@/hooks/useDealerUser'
|
||||
import {useUser} from '@/hooks/useUser'
|
||||
import { useThemeStyles } from '@/hooks/useTheme'
|
||||
import {businessGradients, cardGradients, gradientUtils} from '@/styles/gradients'
|
||||
import {updateShopDealerUser} from '@/api/shop/shopDealerUser'
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
const DealerIndex: React.FC = () => {
|
||||
@@ -21,6 +23,9 @@ const DealerIndex: React.FC = () => {
|
||||
refresh,
|
||||
} = useDealerUser()
|
||||
|
||||
// 获取用户角色信息
|
||||
const { hasRole } = useUser()
|
||||
|
||||
// 使用主题样式
|
||||
const themeStyles = useThemeStyles()
|
||||
|
||||
@@ -55,6 +60,59 @@ const DealerIndex: React.FC = () => {
|
||||
|
||||
console.log(getGradientBackground(),'getGradientBackground()')
|
||||
|
||||
// 判断是否是配送员
|
||||
const isRider = hasRole('rider')
|
||||
|
||||
// 点击待使用金额 - 配送员专用:将冻结金额转入可提现
|
||||
const handleFreezeMoneyClick = async () => {
|
||||
// 检查是否是配送员
|
||||
if (!isRider) {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查冻结金额是否为 0
|
||||
const freezeMoney = Number(dealerUser?.freezeMoney ?? 0)
|
||||
if (freezeMoney <= 0) {
|
||||
return
|
||||
}
|
||||
|
||||
// 弹出确认框
|
||||
Taro.showModal({
|
||||
title: '确认操作',
|
||||
content: `确定要将 ¥${freezeMoney.toFixed(2)} 转入钱包吗?`,
|
||||
confirmText: '确定',
|
||||
cancelText: '取消',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
Taro.showLoading({ title: '处理中...' })
|
||||
const currentMoney = Number(dealerUser?.money ?? 0)
|
||||
await updateShopDealerUser({
|
||||
id: dealerUser?.id,
|
||||
money: (currentMoney + freezeMoney).toFixed(2),
|
||||
freezeMoney: '0.00'
|
||||
})
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
// 刷新数据
|
||||
refresh()
|
||||
} catch (error) {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: '更新失败',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<View className="p-4">
|
||||
@@ -140,13 +198,20 @@ const DealerIndex: React.FC = () => {
|
||||
</Text>
|
||||
<Text className="text-xs" style={{ color: 'rgba(255, 255, 255, 0.9)' }}>可提现</Text>
|
||||
</View>
|
||||
<View className="text-center p-3 rounded-lg flex flex-col" style={{
|
||||
background: businessGradients.money.frozen
|
||||
}}>
|
||||
<View
|
||||
className="text-center p-3 rounded-lg flex flex-col"
|
||||
style={{
|
||||
background: businessGradients.money.frozen,
|
||||
opacity: isRider && Number(dealerUser.freezeMoney ?? 0) > 0 ? 1 : 0.8
|
||||
}}
|
||||
onClick={isRider && Number(dealerUser.freezeMoney ?? 0) > 0 ? handleFreezeMoneyClick : undefined}
|
||||
>
|
||||
<Text className="text-lg font-bold mb-1 text-white">
|
||||
{formatMoney(dealerUser.freezeMoney)}
|
||||
</Text>
|
||||
<Text className="text-xs" style={{ color: 'rgba(255, 255, 255, 0.9)' }}>待使用</Text>
|
||||
<Text className="text-xs" style={{ color: 'rgba(255, 255, 255, 0.9)' }}>
|
||||
{isRider && Number(dealerUser.freezeMoney ?? 0) > 0 ? '待使用' : '待使用'}
|
||||
</Text>
|
||||
</View>
|
||||
<View className="text-center p-3 rounded-lg flex flex-col" style={{
|
||||
background: businessGradients.money.total
|
||||
|
||||
@@ -5,7 +5,7 @@ import {Popup} from '@nutui/nutui-react-taro'
|
||||
import {UserParam} from "@/api/system/user/model";
|
||||
import {Button} from '@nutui/nutui-react-taro'
|
||||
import {Form, Input} from '@nutui/nutui-react-taro'
|
||||
import {Copyright, Version} from "@/config/app";
|
||||
import {Copyright} from "@/config/app";
|
||||
const UserFooter = () => {
|
||||
const [openLoginByPhone, setOpenLoginByPhone] = useState(false)
|
||||
const [clickNum, setClickNum] = useState<number>(0)
|
||||
|
||||
@@ -11,8 +11,10 @@ import {
|
||||
Scan
|
||||
} from '@nutui/icons-react-taro'
|
||||
import {useDealerUser} from '@/hooks/useDealerUser'
|
||||
import {useUser} from '@/hooks/useUser'
|
||||
import { useThemeStyles } from '@/hooks/useTheme'
|
||||
import {businessGradients, cardGradients, gradientUtils} from '@/styles/gradients'
|
||||
import {updateShopDealerUser} from '@/api/shop/shopDealerUser'
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
const DealerIndex: React.FC = () => {
|
||||
@@ -22,6 +24,9 @@ const DealerIndex: React.FC = () => {
|
||||
refresh,
|
||||
} = useDealerUser()
|
||||
|
||||
// 获取用户角色信息
|
||||
const { hasRole } = useUser()
|
||||
|
||||
// 使用主题样式
|
||||
const themeStyles = useThemeStyles()
|
||||
|
||||
@@ -56,6 +61,59 @@ const DealerIndex: React.FC = () => {
|
||||
|
||||
console.log(getGradientBackground(),'getGradientBackground()')
|
||||
|
||||
// 判断是否是配送员
|
||||
const isRider = hasRole('rider')
|
||||
|
||||
// 点击待使用金额 - 配送员专用:将冻结金额转入可提现
|
||||
const handleFreezeMoneyClick = async () => {
|
||||
// 检查是否是配送员
|
||||
if (!isRider) {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查冻结金额是否为 0
|
||||
const freezeMoney = Number(dealerUser?.freezeMoney ?? 0)
|
||||
if (freezeMoney <= 0) {
|
||||
return
|
||||
}
|
||||
|
||||
// 弹出确认框
|
||||
Taro.showModal({
|
||||
title: '确认操作',
|
||||
content: `确定要将 ¥${freezeMoney.toFixed(2)} 转入钱包吗?`,
|
||||
confirmText: '确定',
|
||||
cancelText: '取消',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
Taro.showLoading({ title: '处理中...' })
|
||||
const currentMoney = Number(dealerUser?.money ?? 0)
|
||||
await updateShopDealerUser({
|
||||
id: dealerUser?.id,
|
||||
money: (currentMoney + freezeMoney).toFixed(2),
|
||||
freezeMoney: '0.00'
|
||||
})
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
// 刷新数据
|
||||
refresh()
|
||||
} catch (error) {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: '更新失败',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<View className="p-4">
|
||||
@@ -148,13 +206,20 @@ const DealerIndex: React.FC = () => {
|
||||
</Text>
|
||||
<Text className="text-xs" style={{ color: 'rgba(255, 255, 255, 0.9)' }}>本月配送佣金</Text>
|
||||
</View>
|
||||
<View className="text-center p-3 rounded-lg flex flex-col" style={{
|
||||
background: businessGradients.money.frozen
|
||||
}}>
|
||||
<View
|
||||
className="text-center p-3 rounded-lg flex flex-col"
|
||||
style={{
|
||||
background: businessGradients.money.frozen,
|
||||
opacity: isRider && Number(dealerUser.freezeMoney ?? 0) > 0 ? 1 : 0.8
|
||||
}}
|
||||
onClick={isRider && Number(dealerUser.freezeMoney ?? 0) > 0 ? handleFreezeMoneyClick : undefined}
|
||||
>
|
||||
<Text className="text-lg font-bold mb-1 text-white">
|
||||
{formatMoney(dealerUser.freezeMoney)}
|
||||
</Text>
|
||||
<Text className="text-xs" style={{ color: 'rgba(255, 255, 255, 0.9)' }}>桶数</Text>
|
||||
<Text className="text-xs" style={{ color: 'rgba(255, 255, 255, 0.9)' }}>
|
||||
{isRider && Number(dealerUser.freezeMoney ?? 0) > 0 ? '待使用' : '待使用'}
|
||||
</Text>
|
||||
</View>
|
||||
<View className="text-center p-3 rounded-lg flex flex-col" style={{
|
||||
background: businessGradients.money.total
|
||||
|
||||
@@ -3,10 +3,11 @@ import {User} from "@/api/system/user/model";
|
||||
|
||||
// 模版套餐ID - 请根据实际情况修改
|
||||
export const TEMPLATE_ID = '10584';
|
||||
// 服务接口 - 请根据实际情况修改
|
||||
export const SERVER_API_URL = 'https://glt-server.websoft.top/api';
|
||||
// export const SERVER_API_URL = 'https://server.websoft.top/api';
|
||||
// export const SERVER_API_URL = 'http://127.0.0.1:8000/api';
|
||||
// 服务接口 - 从环境配置读取
|
||||
// @ts-ignore
|
||||
export const SERVER_API_URL = process.env.TARO_ENV === 'production'
|
||||
? 'https://glt-server.websoft.top/api'
|
||||
: 'https://glt-dev-server.websoft.top/api';
|
||||
/**
|
||||
* 保存用户信息到本地存储
|
||||
* @param token
|
||||
|
||||
Reference in New Issue
Block a user