feat:n
This commit is contained in:
@ -3,12 +3,12 @@ import classNames from 'classnames';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import ListPlaceholder from '@/components/list-placeholder';
|
||||
import { ProfitStatusDescriptions } from '@/constants/partner';
|
||||
import { GetProfitRequest, PartnerProfitItem, ProfitType } from '@/types/partner';
|
||||
import { logWithPrefix } from '@/utils/common';
|
||||
import { formatMoney, formatTimestamp, getProfitList as requestData } from '@/utils/partner';
|
||||
|
||||
import './index.less';
|
||||
import { PROFIT_STATUS_MAP, PROFIT_TYPE_MAP } from '@/constants/partner';
|
||||
|
||||
export interface IPartnerProfitListProps extends GetProfitRequest {
|
||||
visible?: boolean;
|
||||
@ -22,7 +22,7 @@ const PREFIX = 'partner-profit';
|
||||
const log = logWithPrefix(PREFIX);
|
||||
|
||||
function ProfitList(props: IPartnerProfitListProps) {
|
||||
const { className, listHeight, refreshDisabled, visible = true, profitType, onListEmpty } = props;
|
||||
const { className, listHeight, refreshDisabled, visible = true, type, onListEmpty } = props;
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
const [loadingMore, setLoadingMore] = useState(false);
|
||||
const [loadMoreError, setLoadMoreError] = useState(false);
|
||||
@ -34,7 +34,7 @@ function ProfitList(props: IPartnerProfitListProps) {
|
||||
try {
|
||||
setRefreshing(true);
|
||||
setLoadMoreError(false);
|
||||
const list = await requestData({ profitType });
|
||||
const list = await requestData({ type });
|
||||
setDataList(list);
|
||||
!list.length && onListEmptyRef.current?.();
|
||||
log('pull refresh success');
|
||||
@ -65,7 +65,7 @@ function ProfitList(props: IPartnerProfitListProps) {
|
||||
setDataList([]);
|
||||
setLoadingMore(true);
|
||||
setLoadMoreError(false);
|
||||
const list = await requestData({ profitType });
|
||||
const list = await requestData({ type });
|
||||
setDataList(list);
|
||||
!list.length && onListEmptyRef.current?.();
|
||||
} catch (e) {
|
||||
@ -77,7 +77,7 @@ function ProfitList(props: IPartnerProfitListProps) {
|
||||
}
|
||||
};
|
||||
refresh();
|
||||
}, [visible, profitType]);
|
||||
}, [visible, type]);
|
||||
|
||||
return (
|
||||
<div className={`${PREFIX}__tab-content`}>
|
||||
@ -95,18 +95,21 @@ function ProfitList(props: IPartnerProfitListProps) {
|
||||
fixedHeight={typeof listHeight !== 'undefined'}
|
||||
style={listHeight ? { height: `${listHeight}px` } : undefined}
|
||||
>
|
||||
{dataList.map(item => (
|
||||
<div className={`${PREFIX}__row`} key={item.id}>
|
||||
<div className={`${PREFIX}__row-content`}>
|
||||
<div className={`${PREFIX}__item time`}>{formatTimestamp(item.created)}</div>
|
||||
<div className={`${PREFIX}__item project`}>{PROFIT_TYPE_MAP[profitType]}</div>
|
||||
<div className={`${PREFIX}__item status`}>
|
||||
{profitType === ProfitType.Anchor ? '已结算' : PROFIT_STATUS_MAP[item.status]}
|
||||
{dataList.map(item => {
|
||||
const isChat = type === ProfitType.CHAT_SHARE || item.earnType.toString().toLowerCase().indexOf('chat');
|
||||
return (
|
||||
<div className={`${PREFIX}__row`} key={item.id}>
|
||||
<div className={`${PREFIX}__row-content`}>
|
||||
<div className={`${PREFIX}__item time`}>{formatTimestamp(item.created)}</div>
|
||||
<div className={`${PREFIX}__item project`}>{isChat ? '主播被开聊' : '会员支付'}</div>
|
||||
<div className={`${PREFIX}__item status`}>
|
||||
{isChat ? '已结算' : ProfitStatusDescriptions[item.status]}
|
||||
</div>
|
||||
<div className={`${PREFIX}__item income`}>+{formatMoney(item.amount)}</div>
|
||||
</div>
|
||||
<div className={`${PREFIX}__item income`}>+{formatMoney(item.profit)}</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
);
|
||||
})}
|
||||
<ListPlaceholder hasMore={false} loadingMore={loadingMore} loadMoreError={loadMoreError} />
|
||||
</List>
|
||||
</PullRefresh>
|
||||
|
||||
@ -30,15 +30,15 @@ export default function PartnerProfit() {
|
||||
<Tabs className={`${PREFIX}__tabs`}>
|
||||
<Tabs.TabPane title="推荐主播收益">
|
||||
<TableTitle />
|
||||
<ProfitList profitType={ProfitType.Anchor} />
|
||||
<ProfitList type={ProfitType.CHAT_SHARE} />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane title="推荐会员权益">
|
||||
<TableTitle />
|
||||
<ProfitList profitType={ProfitType.Member} />
|
||||
<ProfitList type={ProfitType.PAYMENT_SHARE} />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane title="推荐合伙人收益">
|
||||
<TableTitle />
|
||||
<ProfitList profitType={ProfitType.Partner} />
|
||||
<ProfitList type={ProfitType.INDIRECT_MEMBER_REFERRAL} />
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user