Merge branch 'main' of https://gitea.hao858.com/dachui/order_site
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
CopyOutlined,
|
||||
CustomerServiceOutlined,
|
||||
GlobalOutlined,
|
||||
IdcardOutlined,
|
||||
LockOutlined,
|
||||
LogoutOutlined,
|
||||
ReloadOutlined,
|
||||
@@ -12,11 +13,17 @@ import {
|
||||
import { Alert, Avatar, Button, Progress, Tag } from 'antd'
|
||||
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 {
|
||||
formatMoney,
|
||||
formatWithdrawChannel,
|
||||
formatWorkerStatus,
|
||||
resolveWorkerInitial,
|
||||
resolveWorkerStatusColor,
|
||||
@@ -28,6 +35,7 @@ type WorkerProfileMobileViewProps = {
|
||||
levelProgress: WorkerLevelProgress | null | undefined
|
||||
canUseFinanceActions: boolean
|
||||
needsAlipayQrCode: boolean
|
||||
withdrawalAccounts: WorkerWithdrawalAccount[]
|
||||
activeTab: string
|
||||
loading: boolean
|
||||
ledgerRecords: ReactNode
|
||||
@@ -42,6 +50,7 @@ type WorkerProfileMobileViewProps = {
|
||||
renameDisabled: boolean
|
||||
onManageDevices: () => void
|
||||
onContact: () => void
|
||||
onAddWithdrawalAccount: () => void
|
||||
onAddAlipayQrCode: () => void
|
||||
onLogout: () => void
|
||||
}
|
||||
@@ -52,6 +61,7 @@ export function WorkerProfileMobileView({
|
||||
levelProgress,
|
||||
canUseFinanceActions,
|
||||
needsAlipayQrCode,
|
||||
withdrawalAccounts,
|
||||
activeTab,
|
||||
loading,
|
||||
ledgerRecords,
|
||||
@@ -66,6 +76,7 @@ export function WorkerProfileMobileView({
|
||||
renameDisabled,
|
||||
onManageDevices,
|
||||
onContact,
|
||||
onAddWithdrawalAccount,
|
||||
onAddAlipayQrCode,
|
||||
onLogout,
|
||||
}: WorkerProfileMobileViewProps) {
|
||||
@@ -249,6 +260,14 @@ export function WorkerProfileMobileView({
|
||||
disabled={!worker.inviteCode}
|
||||
onClick={onCopyInviteCode}
|
||||
/>
|
||||
<MobileTool
|
||||
label="添加提现信息"
|
||||
icon={<IdcardOutlined />}
|
||||
color="#0e7490"
|
||||
background="#ecfeff"
|
||||
disabled={!canUseFinanceActions}
|
||||
onClick={onAddWithdrawalAccount}
|
||||
/>
|
||||
{needsAlipayQrCode ? (
|
||||
<MobileTool
|
||||
label="补充支付宝收款码"
|
||||
@@ -291,7 +310,13 @@ export function WorkerProfileMobileView({
|
||||
{activeTab === 'ledger' ? ledgerRecords : null}
|
||||
{activeTab === 'requests' ? requestRecords : null}
|
||||
{activeTab === 'account' ? (
|
||||
<WorkerProfileMobileAccountDetails worker={worker} summary={summary} />
|
||||
<WorkerProfileMobileAccountDetails
|
||||
worker={worker}
|
||||
summary={summary}
|
||||
withdrawalAccounts={withdrawalAccounts}
|
||||
canUseFinanceActions={canUseFinanceActions}
|
||||
onAddWithdrawalAccount={onAddWithdrawalAccount}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
@@ -361,9 +386,15 @@ function MobileTab({
|
||||
function WorkerProfileMobileAccountDetails({
|
||||
worker,
|
||||
summary,
|
||||
withdrawalAccounts,
|
||||
canUseFinanceActions,
|
||||
onAddWithdrawalAccount,
|
||||
}: {
|
||||
worker: WorkerUser
|
||||
summary: WorkerProfileSummary | undefined
|
||||
withdrawalAccounts: WorkerWithdrawalAccount[]
|
||||
canUseFinanceActions: boolean
|
||||
onAddWithdrawalAccount: () => void
|
||||
}) {
|
||||
const items: Array<[string, ReactNode]> = [
|
||||
['账号', worker.username],
|
||||
@@ -394,6 +425,55 @@ function WorkerProfileMobileAccountDetails({
|
||||
</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>
|
||||
)
|
||||
}
|
||||
|
||||
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)
|
||||
withdrawalAccountForm.resetFields()
|
||||
await refreshAll()
|
||||
withdrawForm.setFieldValue('accountChannel', String(values.accountChannel || ''))
|
||||
setWithdrawOpen(true)
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '添加提现信息失败')
|
||||
} finally {
|
||||
@@ -424,6 +422,7 @@ export default function WorkerProfilePage() {
|
||||
needsAlipayQrCode={Boolean(
|
||||
alipayWithdrawalAccount && !alipayWithdrawalAccount.alipayQrCodeImage,
|
||||
)}
|
||||
withdrawalAccounts={withdrawalAccounts}
|
||||
activeTab={activeTab}
|
||||
loading={profileQuery.isFetching || ledgersQuery.isFetching || requestsQuery.isFetching}
|
||||
ledgerRecords={
|
||||
@@ -487,6 +486,7 @@ export default function WorkerProfilePage() {
|
||||
renameDisabled={!canRename}
|
||||
onManageDevices={() => setDevicesOpen(true)}
|
||||
onContact={() => setContactOpen(true)}
|
||||
onAddWithdrawalAccount={openWithdrawalAccountModal}
|
||||
onAddAlipayQrCode={openAlipayQrCodeModal}
|
||||
onLogout={submitLogout}
|
||||
/>
|
||||
|
||||
@@ -2330,6 +2330,101 @@ body {
|
||||
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)
|
||||
========================================================================== */
|
||||
|
||||
@@ -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