功能(打手端): 移动端个人中心新增添加提现信息入口
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
|||||||
CopyOutlined,
|
CopyOutlined,
|
||||||
CustomerServiceOutlined,
|
CustomerServiceOutlined,
|
||||||
GlobalOutlined,
|
GlobalOutlined,
|
||||||
|
IdcardOutlined,
|
||||||
LockOutlined,
|
LockOutlined,
|
||||||
LogoutOutlined,
|
LogoutOutlined,
|
||||||
ReloadOutlined,
|
ReloadOutlined,
|
||||||
@@ -12,11 +13,17 @@ import {
|
|||||||
import { Alert, Avatar, Button, Progress, Tag } from 'antd'
|
import { Alert, Avatar, Button, Progress, Tag } from 'antd'
|
||||||
import type { ReactNode } from 'react'
|
import type { ReactNode } from 'react'
|
||||||
|
|
||||||
import type { WorkerLevelProgress, WorkerProfileSummary, WorkerUser } from '@/types/worker-platform'
|
import type {
|
||||||
|
WorkerLevelProgress,
|
||||||
|
WorkerProfileSummary,
|
||||||
|
WorkerUser,
|
||||||
|
WorkerWithdrawalAccount,
|
||||||
|
} from '@/types/worker-platform'
|
||||||
import { formatDateTime } from '@/utils/date-time'
|
import { formatDateTime } from '@/utils/date-time'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
formatMoney,
|
formatMoney,
|
||||||
|
formatWithdrawChannel,
|
||||||
formatWorkerStatus,
|
formatWorkerStatus,
|
||||||
resolveWorkerInitial,
|
resolveWorkerInitial,
|
||||||
resolveWorkerStatusColor,
|
resolveWorkerStatusColor,
|
||||||
@@ -28,6 +35,7 @@ type WorkerProfileMobileViewProps = {
|
|||||||
levelProgress: WorkerLevelProgress | null | undefined
|
levelProgress: WorkerLevelProgress | null | undefined
|
||||||
canUseFinanceActions: boolean
|
canUseFinanceActions: boolean
|
||||||
needsAlipayQrCode: boolean
|
needsAlipayQrCode: boolean
|
||||||
|
withdrawalAccounts: WorkerWithdrawalAccount[]
|
||||||
activeTab: string
|
activeTab: string
|
||||||
loading: boolean
|
loading: boolean
|
||||||
ledgerRecords: ReactNode
|
ledgerRecords: ReactNode
|
||||||
@@ -42,6 +50,7 @@ type WorkerProfileMobileViewProps = {
|
|||||||
renameDisabled: boolean
|
renameDisabled: boolean
|
||||||
onManageDevices: () => void
|
onManageDevices: () => void
|
||||||
onContact: () => void
|
onContact: () => void
|
||||||
|
onAddWithdrawalAccount: () => void
|
||||||
onAddAlipayQrCode: () => void
|
onAddAlipayQrCode: () => void
|
||||||
onLogout: () => void
|
onLogout: () => void
|
||||||
}
|
}
|
||||||
@@ -52,6 +61,7 @@ export function WorkerProfileMobileView({
|
|||||||
levelProgress,
|
levelProgress,
|
||||||
canUseFinanceActions,
|
canUseFinanceActions,
|
||||||
needsAlipayQrCode,
|
needsAlipayQrCode,
|
||||||
|
withdrawalAccounts,
|
||||||
activeTab,
|
activeTab,
|
||||||
loading,
|
loading,
|
||||||
ledgerRecords,
|
ledgerRecords,
|
||||||
@@ -66,6 +76,7 @@ export function WorkerProfileMobileView({
|
|||||||
renameDisabled,
|
renameDisabled,
|
||||||
onManageDevices,
|
onManageDevices,
|
||||||
onContact,
|
onContact,
|
||||||
|
onAddWithdrawalAccount,
|
||||||
onAddAlipayQrCode,
|
onAddAlipayQrCode,
|
||||||
onLogout,
|
onLogout,
|
||||||
}: WorkerProfileMobileViewProps) {
|
}: WorkerProfileMobileViewProps) {
|
||||||
@@ -249,6 +260,14 @@ export function WorkerProfileMobileView({
|
|||||||
disabled={!worker.inviteCode}
|
disabled={!worker.inviteCode}
|
||||||
onClick={onCopyInviteCode}
|
onClick={onCopyInviteCode}
|
||||||
/>
|
/>
|
||||||
|
<MobileTool
|
||||||
|
label="添加提现信息"
|
||||||
|
icon={<IdcardOutlined />}
|
||||||
|
color="#0e7490"
|
||||||
|
background="#ecfeff"
|
||||||
|
disabled={!canUseFinanceActions}
|
||||||
|
onClick={onAddWithdrawalAccount}
|
||||||
|
/>
|
||||||
{needsAlipayQrCode ? (
|
{needsAlipayQrCode ? (
|
||||||
<MobileTool
|
<MobileTool
|
||||||
label="补充支付宝收款码"
|
label="补充支付宝收款码"
|
||||||
@@ -291,7 +310,13 @@ export function WorkerProfileMobileView({
|
|||||||
{activeTab === 'ledger' ? ledgerRecords : null}
|
{activeTab === 'ledger' ? ledgerRecords : null}
|
||||||
{activeTab === 'requests' ? requestRecords : null}
|
{activeTab === 'requests' ? requestRecords : null}
|
||||||
{activeTab === 'account' ? (
|
{activeTab === 'account' ? (
|
||||||
<WorkerProfileMobileAccountDetails worker={worker} summary={summary} />
|
<WorkerProfileMobileAccountDetails
|
||||||
|
worker={worker}
|
||||||
|
summary={summary}
|
||||||
|
withdrawalAccounts={withdrawalAccounts}
|
||||||
|
canUseFinanceActions={canUseFinanceActions}
|
||||||
|
onAddWithdrawalAccount={onAddWithdrawalAccount}
|
||||||
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -361,9 +386,15 @@ function MobileTab({
|
|||||||
function WorkerProfileMobileAccountDetails({
|
function WorkerProfileMobileAccountDetails({
|
||||||
worker,
|
worker,
|
||||||
summary,
|
summary,
|
||||||
|
withdrawalAccounts,
|
||||||
|
canUseFinanceActions,
|
||||||
|
onAddWithdrawalAccount,
|
||||||
}: {
|
}: {
|
||||||
worker: WorkerUser
|
worker: WorkerUser
|
||||||
summary: WorkerProfileSummary | undefined
|
summary: WorkerProfileSummary | undefined
|
||||||
|
withdrawalAccounts: WorkerWithdrawalAccount[]
|
||||||
|
canUseFinanceActions: boolean
|
||||||
|
onAddWithdrawalAccount: () => void
|
||||||
}) {
|
}) {
|
||||||
const items: Array<[string, ReactNode]> = [
|
const items: Array<[string, ReactNode]> = [
|
||||||
['账号', worker.username],
|
['账号', worker.username],
|
||||||
@@ -394,6 +425,55 @@ function WorkerProfileMobileAccountDetails({
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="worker-profile-mobile-withdraw-block">
|
||||||
|
<div className="worker-profile-mobile-withdraw-head">
|
||||||
|
<span className="worker-profile-mobile-withdraw-title">提现信息</span>
|
||||||
|
{withdrawalAccounts.length > 0 ? (
|
||||||
|
<span className="worker-profile-mobile-withdraw-hint">修改请联系客服</span>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
{withdrawalAccounts.length > 0 ? (
|
||||||
|
<div className="worker-profile-mobile-withdraw-list">
|
||||||
|
{withdrawalAccounts.map((account) => (
|
||||||
|
<div key={account.accountChannel} className="worker-profile-mobile-withdraw-item">
|
||||||
|
<div className="worker-profile-mobile-withdraw-line">
|
||||||
|
<Tag color="blue" className="worker-profile-mobile-withdraw-tag">
|
||||||
|
{formatWithdrawChannel(account.accountChannel)}
|
||||||
|
</Tag>
|
||||||
|
<strong className="worker-profile-mobile-withdraw-name">
|
||||||
|
{account.accountName}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
<span className="worker-profile-mobile-withdraw-desc">
|
||||||
|
{formatWithdrawalAccountDesc(account)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="worker-profile-mobile-withdraw-empty">
|
||||||
|
<span className="worker-profile-mobile-withdraw-desc">暂未添加提现信息</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="worker-profile-mobile-withdraw-add-btn"
|
||||||
|
disabled={!canUseFinanceActions}
|
||||||
|
onClick={onAddWithdrawalAccount}
|
||||||
|
>
|
||||||
|
添加提现信息
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatWithdrawalAccountDesc(account: WorkerWithdrawalAccount) {
|
||||||
|
if (account.accountChannel === 'wechat') {
|
||||||
|
return account.wechatQrCodeImage ? '已上传收款码' : '未上传收款码'
|
||||||
|
}
|
||||||
|
return `${account.accountNoMasked || '-'} · ${
|
||||||
|
account.alipayQrCodeImage ? '已上传收款码' : '未上传收款码'
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
|||||||
@@ -329,8 +329,6 @@ export default function WorkerProfilePage() {
|
|||||||
setWithdrawalAccountOpen(false)
|
setWithdrawalAccountOpen(false)
|
||||||
withdrawalAccountForm.resetFields()
|
withdrawalAccountForm.resetFields()
|
||||||
await refreshAll()
|
await refreshAll()
|
||||||
withdrawForm.setFieldValue('accountChannel', String(values.accountChannel || ''))
|
|
||||||
setWithdrawOpen(true)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error(error instanceof Error ? error.message : '添加提现信息失败')
|
message.error(error instanceof Error ? error.message : '添加提现信息失败')
|
||||||
} finally {
|
} finally {
|
||||||
@@ -424,6 +422,7 @@ export default function WorkerProfilePage() {
|
|||||||
needsAlipayQrCode={Boolean(
|
needsAlipayQrCode={Boolean(
|
||||||
alipayWithdrawalAccount && !alipayWithdrawalAccount.alipayQrCodeImage,
|
alipayWithdrawalAccount && !alipayWithdrawalAccount.alipayQrCodeImage,
|
||||||
)}
|
)}
|
||||||
|
withdrawalAccounts={withdrawalAccounts}
|
||||||
activeTab={activeTab}
|
activeTab={activeTab}
|
||||||
loading={profileQuery.isFetching || ledgersQuery.isFetching || requestsQuery.isFetching}
|
loading={profileQuery.isFetching || ledgersQuery.isFetching || requestsQuery.isFetching}
|
||||||
ledgerRecords={
|
ledgerRecords={
|
||||||
@@ -487,6 +486,7 @@ export default function WorkerProfilePage() {
|
|||||||
renameDisabled={!canRename}
|
renameDisabled={!canRename}
|
||||||
onManageDevices={() => setDevicesOpen(true)}
|
onManageDevices={() => setDevicesOpen(true)}
|
||||||
onContact={() => setContactOpen(true)}
|
onContact={() => setContactOpen(true)}
|
||||||
|
onAddWithdrawalAccount={openWithdrawalAccountModal}
|
||||||
onAddAlipayQrCode={openAlipayQrCodeModal}
|
onAddAlipayQrCode={openAlipayQrCodeModal}
|
||||||
onLogout={submitLogout}
|
onLogout={submitLogout}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -2330,6 +2330,101 @@ body {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 账号详情 - 提现信息 */
|
||||||
|
.worker-profile-mobile-withdraw-block {
|
||||||
|
margin-top: 12px;
|
||||||
|
padding-top: 12px;
|
||||||
|
border-top: 1px solid #f1f5f9;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-title {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-hint {
|
||||||
|
font-size: 11px;
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-item {
|
||||||
|
background: #f8fafc;
|
||||||
|
border: 1px solid #f1f5f9;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-line {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-tag {
|
||||||
|
margin-inline-end: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-name {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-desc {
|
||||||
|
font-size: 11px;
|
||||||
|
color: #64748b;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-empty {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
background: #f8fafc;
|
||||||
|
border: 1px dashed #e2e8f0;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-add-btn {
|
||||||
|
border: 1px solid #fdba74;
|
||||||
|
background: #ffffff;
|
||||||
|
color: #ea580c;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 3px 10px;
|
||||||
|
font-size: 11px;
|
||||||
|
cursor: pointer;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worker-profile-mobile-withdraw-add-btn:disabled {
|
||||||
|
border-color: #e2e8f0;
|
||||||
|
background: #f8fafc;
|
||||||
|
color: #94a3b8;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
/* ==========================================================================
|
/* ==========================================================================
|
||||||
移动端 抢单大厅 (Worker Hall Mobile Page)
|
移动端 抢单大厅 (Worker Hall Mobile Page)
|
||||||
========================================================================== */
|
========================================================================== */
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import { readFile } from 'node:fs/promises'
|
||||||
|
import test from 'node:test'
|
||||||
|
|
||||||
|
async function readSource(relativePath: string) {
|
||||||
|
return readFile(new URL(`../src/${relativePath}`, import.meta.url), 'utf8')
|
||||||
|
}
|
||||||
|
|
||||||
|
test('移动端个人中心提供添加提现信息入口', async () => {
|
||||||
|
const [mobileView, page] = await Promise.all([
|
||||||
|
readSource('pages/worker/WorkerProfileMobileView.tsx'),
|
||||||
|
readSource('pages/worker/WorkerProfilePage.tsx'),
|
||||||
|
])
|
||||||
|
|
||||||
|
assert.ok(mobileView.includes('label="添加提现信息"'), '工具宫格必须有添加提现信息入口')
|
||||||
|
assert.ok(mobileView.includes('onAddWithdrawalAccount'), '移动端必须接线添加提现信息回调')
|
||||||
|
assert.ok(
|
||||||
|
page.includes('onAddWithdrawalAccount={openWithdrawalAccountModal}'),
|
||||||
|
'页面必须复用现有添加提现信息弹窗',
|
||||||
|
)
|
||||||
|
assert.ok(
|
||||||
|
page.includes('withdrawalAccounts={withdrawalAccounts}'),
|
||||||
|
'页面必须把提现账户传给移动端',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('移动端账号详情展示提现信息与空状态入口', async () => {
|
||||||
|
const mobileView = await readSource('pages/worker/WorkerProfileMobileView.tsx')
|
||||||
|
|
||||||
|
assert.ok(mobileView.includes('worker-profile-mobile-withdraw-block'))
|
||||||
|
assert.ok(mobileView.includes('提现信息'))
|
||||||
|
assert.ok(mobileView.includes('暂未添加提现信息'))
|
||||||
|
assert.ok(mobileView.includes('formatWithdrawalAccountDesc'))
|
||||||
|
})
|
||||||
|
|
||||||
|
test('两个渠道都已添加时点击入口提示联系客服', async () => {
|
||||||
|
const page = await readSource('pages/worker/WorkerProfilePage.tsx')
|
||||||
|
|
||||||
|
assert.ok(page.includes('支付宝和微信提现信息均已添加,修改请联系客服处理'))
|
||||||
|
})
|
||||||
|
|
||||||
|
test('添加提现信息成功后只关闭弹窗,不自动打开提现申请', async () => {
|
||||||
|
const page = await readSource('pages/worker/WorkerProfilePage.tsx')
|
||||||
|
const submitBlock = page.slice(
|
||||||
|
page.indexOf('async function submitWithdrawalAccount'),
|
||||||
|
page.indexOf('async function submitAlipayQrCode'),
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.ok(submitBlock.length > 0, '必须能找到添加提现信息的提交函数')
|
||||||
|
assert.ok(submitBlock.includes('setWithdrawalAccountOpen(false)'), '成功后必须关闭添加弹窗')
|
||||||
|
assert.ok(!submitBlock.includes('setWithdrawOpen(true)'), '成功后不得自动打开提现申请弹窗')
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user