Merge branch 'trunk' into feat/update-login

This commit is contained in:
chashaobao 2025-06-15 01:09:35 +08:00
commit 1b782ee82c
15 changed files with 312 additions and 36 deletions

View File

@ -109,5 +109,6 @@
"ignoredBuiltDependencies": [
"@tarojs/binding"
]
}
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}

View File

@ -2,13 +2,13 @@ import { Image } from '@tarojs/components';
import classNames from 'classnames';
import { PropsWithChildren, useEffect, useState, useCallback } from 'react';
import { MaterialViewSource } from '@/constants/material';
import { PageUrl } from '@/constants/app';
import { MaterialViewSource } from '@/constants/material';
import useUserInfo from '@/hooks/use-user-info';
import { IChatMessage } from '@/types/message';
import { getScrollItemId } from '@/utils/common';
import { navigateTo } from '@/utils/route';
import { PageUrl } from '@/constants/app';
import './index.less';
@ -19,12 +19,13 @@ export interface IBaseMessageProps {
export interface IUserMessageProps extends PropsWithChildren, IBaseMessageProps {
isRead?: boolean;
resumeId?: string;
}
const PREFIX = 'base-message';
function BaseMessage(props: IUserMessageProps) {
const { id, message, isRead: isReadProps, children } = props;
const { id, message, isRead: isReadProps, children, resumeId } = props;
const { userId } = useUserInfo();
const [isRead, setIsRead] = useState(message.isRead);
const isSender = message.senderUserId === userId;
@ -37,10 +38,12 @@ function BaseMessage(props: IUserMessageProps) {
// const timer = setTimeout(() => setIsRead(true), 1200);
// return () => clearTimeout(timer);
// }, [isSender]);
const handleClick = useCallback(
() => navigateTo(PageUrl.MaterialView, { resumeId: message.jobId, source: MaterialViewSource.Chat }),
[message.jobId]
);
const handleClick = useCallback(() => {
if (!resumeId || isSender) {
return;
}
navigateTo(PageUrl.MaterialView, { resumeId: resumeId, source: MaterialViewSource.Chat });
}, [resumeId, isSender]);
useEffect(() => {
if (isRead) {
return;
@ -53,6 +56,7 @@ function BaseMessage(props: IUserMessageProps) {
<Image
mode="aspectFit"
className={`${PREFIX}__avatar`}
onClick={handleClick}
src={message.senderAvatarUrl || require('@/statics/png/default_avatar.png')}
/>
<div className={`${PREFIX}__content-container`}>

View File

@ -125,7 +125,7 @@ function PartnerList(props: {
hasMore={hasMore}
onLoad={handleLoadMore}
loading={loadingMore || refreshing}
disabled={loadMoreError}
disabled={loadMoreError || !visible}
fixedHeight={typeof listHeight !== 'undefined'}
style={listHeight ? { height: `${listHeight}px` } : undefined}
>

View File

@ -1,14 +1,16 @@
import { Button, Image } from '@tarojs/components';
import Taro, { useDidShow } from '@tarojs/taro';
import { Dialog } from '@taroify/core';
import { Question } from '@taroify/icons';
import { useCallback, useState, useEffect } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { PageUrl } from '@/constants/app';
import { PartnerProfitsState } from '@/types/partner';
import { formatMoney, getPartnerProfitStat } from '@/utils/partner';
import { formatMoney, getPartnerProfitStat, withdrawMoney } from '@/utils/partner';
import { navigateTo } from '@/utils/route';
import Toast from '@/utils/toast';
import './index.less';
const PREFIX = 'partner-kanban';
@ -31,14 +33,45 @@ function TipDialog(props: { open: boolean; onClose: () => void }) {
}
function WithdrawDialog(props: { open: boolean; onClose: () => void; count: number }) {
const handleWithdraw = useCallback(() => {}, []);
const handleWithdraw = useCallback(async () => {
if (Taro.canIUse('requestMerchantTransfer')) {
try {
const result = await withdrawMoney();
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
wx.requestMerchantTransfer({
mchId: '1642470088',
appId: 'wxf0724a83f8e377d2',
package: result.packageInfo,
success: (res: never) => {
// res.err_msg将在页面展示成功后返回应用时返回ok并不代表付款成功
console.log('success:', res);
Toast.success('提现成功');
props.onClose();
},
fail: (res: never) => {
Toast.error('提现失败');
console.log('fail:', res);
},
});
} catch (e) {
Toast.error('提现订单创建失败');
console.log(e);
}
} else {
await Taro.showModal({
content: '你的微信版本过低,请更新至最新版本。',
showCancel: false,
});
}
}, [props]);
return (
<Dialog open={props.open} onClose={props.onClose}>
<Dialog.Content>
<div className={`${PREFIX}-withdraw-dialog__container`}>
<div className={`${PREFIX}-withdraw-dialog__title`}></div>
<div className={`${PREFIX}-withdraw-dialog__count`}>
{props.count}
{+props.count}
<div className="yuan"></div>
</div>
<div className={`${PREFIX}-withdraw-dialog__hint`}>500</div>
@ -86,20 +119,24 @@ export default function PartnerKanban({ simple }: PartnerKanbanProps) {
const handleTipClose = useCallback(() => {
setTipOpen(false);
}, []);
const handleViewWithdraw = useCallback(() => {
if (stats.availableBalance < 10 * 1000) {
Toast.info('提现金额需大于等于10元');
return;
}
setWithdrawOpen(true);
}, []);
const handleWithdrawClose = useCallback(() => {
setWithdrawOpen(false);
}, []);
const getProfitStats = useCallback(async () => {
const data = await getPartnerProfitStat();
setStats(data);
}, []);
const handleViewWithdraw = useCallback(() => {
if (stats.availableBalance < 10 * 1000) {
Toast.error('提现金额需大于等于10元');
return;
}
setWithdrawOpen(true);
}, [stats.availableBalance]);
const handleWithdrawClose = useCallback(() => {
setWithdrawOpen(false);
getProfitStats();
}, [getProfitStats]);
useDidShow(() => {
getProfitStats();
});
useEffect(() => {
getProfitStats();
}, []);
@ -154,7 +191,13 @@ export default function PartnerKanban({ simple }: PartnerKanbanProps) {
)}
</div>
{!simple && <TipDialog open={tipOpen} onClose={handleTipClose} />}
{!simple && <WithdrawDialog count={350} open={withdrawOpen} onClose={handleWithdrawClose} />}
{!simple && (
<WithdrawDialog
count={Math.min(Number(formatMoney(stats.availableBalance)), 500)}
open={withdrawOpen}
onClose={handleWithdrawClose}
/>
)}
</div>
);
}

View File

@ -96,7 +96,8 @@ function ProfitList(props: IPartnerProfitListProps) {
style={listHeight ? { height: `${listHeight}px` } : undefined}
>
{dataList.map(item => {
const isChat = type === ProfitType.CHAT_SHARE || item.earnType.toString().toLowerCase().indexOf('chat') > -1;
const isChat =
type === ProfitType.CHAT_SHARE || item.earnType.toString().toLowerCase().indexOf('chat') > -1;
return (
<div className={`${PREFIX}__row`} key={item.id}>
<div className={`${PREFIX}__row-content`}>

View File

@ -78,10 +78,13 @@
&:last-child {
padding-right: 0;
}
&.time,
&.project {
&.time {
flex: 2;
}
&.project {
width: 150px;
flex-shrink: 0;
}
&.status {
width: 96px;
padding: 0 8px;

View File

@ -52,3 +52,9 @@ export const ProfitStatusDescriptions = {
OTHER: '',
FINISHED: '已分账',
};
export const WithdrawStatusDescriptions = {
0: '提现中',
1: '已提现',
2: '失败',
};

View File

@ -1,5 +1,6 @@
import { useSelector } from 'react-redux';
import { RoleType } from '@/constants/app';
import { selectRoleType } from '@/store/selector';
import { RoleType } from '@/constants/app';

View File

@ -82,4 +82,6 @@ export enum API {
BECOME_PARTNER = '/user/becomePartner',
GET_PROFIT_LIST = '/user/profit/list',
GET_PROFIT_STAT = '/user/profits',
WITHDRAW = '/user/withdraw',
GET_WITHDRAW_LIST = '/user/withdraw/records',
}

View File

@ -31,7 +31,7 @@ import {
PostMessageRequest,
} from '@/types/message';
import { isAnchorMode } from '@/utils/app';
import { getScrollItemId, last, logWithPrefix } from '@/utils/common';
import { getScrollItemId, last, logWithPrefix, safeJsonParse } from '@/utils/common';
import { collectEvent } from '@/utils/event';
import {
isExchangeMessage,
@ -55,6 +55,7 @@ import Toast from '@/utils/toast';
import { getUserId } from '@/utils/user';
import './index.less';
import useUserInfo from '@/hooks/use-user-info';
const PREFIX = 'page-message-chat';
const LIST_CONTAINER_CLASS = `${PREFIX}__chat-list`;
@ -85,8 +86,19 @@ const getHeaderLeftButtonText = (job?: IJobMessage, material?: IMaterialMessage)
return isAnchorMode() ? '不感兴趣' : '标记为不合适';
};
const getResumeId = (messages: IChatMessage[], userId?: string) => {
const resumeStr = messages.find(it => it.type === MessageType.Material && it.senderUserId !== userId)?.actionObject;
if (resumeStr) {
const { id } = safeJsonParse(resumeStr);
log('resumeId', id);
return id;
}
return undefined;
};
export default function MessageChat() {
const listHeight = useListHeight(CALC_LIST_PROPS);
const { userId } = useUserInfo();
const [input, setInput] = useState('');
const [showMore, setShowMore] = useState(false);
const [chat, setChat] = useState<IChatInfo | null>(null);
@ -96,6 +108,7 @@ export default function MessageChat() {
const [messageStatusList, setMessageStatusList] = useState<IMessageStatus[]>([]);
const [jobId, setJobId] = useState<string>();
const [job, setJob] = useState<IJobMessage>();
const [resumeId, setResumeId] = useState<string | undefined>();
const [material, setMaterial] = useState<IMaterialMessage>();
const [scrollItemId, setScrollItemId] = useState<string>();
const scrollToLowerRef = useRef(false);
@ -252,6 +265,14 @@ export default function MessageChat() {
// };
// }, []);
useEffect(() => {
if (resumeId) {
return;
}
setResumeId(getResumeId(messages, userId));
}, [messages, resumeId, userId]);
useEffect(() => {
if (!chat) {
return;
@ -353,6 +374,7 @@ export default function MessageChat() {
id={message.msgId}
key={message.msgId}
message={message}
resumeId={resumeId}
isRead={messageStatusList.some(m => m.msgId === message.msgId && !!m.isRead)}
/>
);

View File

@ -1,20 +1,23 @@
import { useShareAppMessage } from '@tarojs/taro';
import { Tabs } from '@taroify/core';
import { useState } from 'react';
import PartnerIntro from '@/components/partner-intro';
import PartnerInviteList from '@/components/partner-invite-list';
import PartnerProfit from '@/components/partner-profit';
import useInviteCode from '@/hooks/use-invite-code';
import { getCommonShareMessage } from '@/utils/share';
import './index.less';
const PREFIX = 'partner';
export default function Partner() {
const inviteCode = useInviteCode();
const [tab, setTab] = useState<number>(0);
const handleChange = v => {
setTab(v);
};
useShareAppMessage(() => {
console.log('Partner inviteCode', inviteCode);
return getCommonShareMessage(false, inviteCode);
@ -22,12 +25,12 @@ export default function Partner() {
return (
<div className={PREFIX}>
<Tabs className={`${PREFIX}__tabs`}>
<Tabs className={`${PREFIX}__tabs`} value={tab} onChange={handleChange}>
<Tabs.TabPane value={0} title="简介">
<PartnerIntro />
</Tabs.TabPane>
<Tabs.TabPane value={1} title="邀请名单">
<PartnerInviteList />
<PartnerInviteList refreshDisabled={tab !== 1} visible={tab === 1} />
</Tabs.TabPane>
<Tabs.TabPane value={2} title="我的收益">
<PartnerProfit />

View File

@ -2,4 +2,52 @@
@import '@/styles/variables.less';
.withdraw-record {
&__item {
height: 131px;
width: 100%;
background: #fff;
padding: 24px 32px 0 32px;
box-sizing: border-box;
font-size: 28px;
&-border {
border-bottom: 1px solid #e6e7e8;
}
&-content {
.flex-row();
width: 100%;
padding-bottom: 24px;
}
&-time {
padding-right: 8px;
line-height: 40px;
flex: 1;
.noWrap();
}
&-withdraw {
width: 200px;
text-align: right;
padding-left: 8px;
flex-shrink: 0;
}
&-money {
line-height: 40px;
padding-bottom: 8px;
.noWrap();
font-weight: 600;
font-size: 30px;
color: #ff5051;
}
&-status {
font-size: 24px;
line-height: 36px;
color: #999999;
.noWrap();
}
}
}

View File

@ -1,14 +1,119 @@
import { useShareAppMessage } from '@tarojs/taro';
import { List, PullRefresh } from '@taroify/core';
import { useCallback, useEffect, useRef, useState } from 'react';
import ListPlaceholder from '@/components/list-placeholder';
import { WithdrawStatusDescriptions } from '@/constants/partner';
import useInviteCode from '@/hooks/use-invite-code';
import { WithdrawRecord } from '@/types/partner';
import { logWithPrefix } from '@/utils/common';
import { formatMoney, formatTimestamp, getWithdrawList as requestData } from '@/utils/partner';
import { getCommonShareMessage } from '@/utils/share';
import './index.less';
const PREFIX = 'withdraw-record';
const log = logWithPrefix(PREFIX);
const FIRST_PAGE = 0;
export default function WithdrawRecord() {
export default function WithdrawRecords() {
const inviteCode = useInviteCode();
const [hasMore, setHasMore] = useState(true);
const [refreshing, setRefreshing] = useState(false);
const [loadingMore, setLoadingMore] = useState(false);
const [loadMoreError, setLoadMoreError] = useState(false);
const [dataList, setDataList] = useState<WithdrawRecord[]>([]);
const currentPage = useRef<number>(FIRST_PAGE);
const handleRefresh = useCallback(async () => {
log('start pull refresh');
try {
setRefreshing(true);
setLoadMoreError(false);
const { content, totalPages } = await requestData({ page: 1 });
setDataList(content);
currentPage.current = 1;
setHasMore(currentPage.current < totalPages);
log('pull refresh success');
} catch (e) {
setDataList([]);
setHasMore(false);
setLoadMoreError(true);
currentPage.current = FIRST_PAGE;
log('pull refresh failed');
} finally {
setRefreshing(false);
}
}, []);
const handleLoadMore = useCallback(async () => {
log('start load more', hasMore);
if (!hasMore) {
return;
}
setLoadMoreError(false);
setLoadingMore(true);
try {
const { totalPages, content } = await requestData({ page: currentPage.current + 1 });
setDataList([...dataList, ...content]);
currentPage.current = currentPage.current + 1;
setHasMore(currentPage.current < totalPages);
log('load more success');
} catch (e) {
setLoadMoreError(true);
log('load more failed');
} finally {
setLoadingMore(false);
}
}, [dataList, hasMore]);
// 初始化数据&配置变更后刷新数据
useEffect(() => {
const refresh = async () => {
log('visible changed, start refresh list data');
try {
setDataList([]);
setLoadingMore(true);
setLoadMoreError(false);
const { totalPages, content } = await requestData({ page: 1 });
setDataList(content);
currentPage.current = 1;
setHasMore(currentPage.current < totalPages);
} catch (e) {
setDataList([]);
setHasMore(false);
setLoadMoreError(true);
} finally {
log('visible changed, refresh list data end');
setLoadingMore(false);
}
};
refresh();
}, []);
useShareAppMessage(() => {
return getCommonShareMessage(false);
return getCommonShareMessage(false, inviteCode);
});
return <div className={PREFIX}></div>;
return (
<div className={PREFIX}>
<PullRefresh className={`${PREFIX}__pull-refresh`} loading={refreshing} onRefresh={handleRefresh}>
<List hasMore={hasMore} onLoad={handleLoadMore} loading={loadingMore || refreshing} disabled={loadMoreError}>
{dataList.map(item => (
<div className={`${PREFIX}__item`} key={item.id || item.userId}>
<div className={`${PREFIX}__item-border`}>
<div className={`${PREFIX}__item-content`}>
<div className={`${PREFIX}__item-time`}>{formatTimestamp(item.created)}</div>
<div className={`${PREFIX}__item-withdraw`}>
<div className={`${PREFIX}__item-money`}>{formatMoney(item.amt)}</div>
<div className={`${PREFIX}__item-status`}>{WithdrawStatusDescriptions[item.status]}</div>
</div>
</div>
</div>
</div>
))}
<ListPlaceholder hasMore={false} loadingMore={loadingMore} loadMoreError={loadMoreError} />
</List>
</PullRefresh>
</div>
);
}

View File

@ -64,3 +64,26 @@ export interface PartnerProfitItem {
expectedSettlementDate: string;
actualSettlementDate: string;
}
export interface WithdrawResponse {
outBillNo: string;
transferBillNo: string;
createTime: string;
state: string;
packageInfo: string;
}
export interface WithdrawRecord {
id: number;
userId: string;
orderNo: string;
outTradeId: string;
amt: number;
status: number;
remark: string;
created: string;
updated: string;
finishedTime: string;
}
export interface PartnerPagination<T> {
content: T[];
totalPages: number;
}

View File

@ -10,8 +10,11 @@ import {
GetProfitRequest,
InviteUserInfo,
PartnerInviteCode,
PartnerPagination,
PartnerProfitItem,
PartnerProfitsState,
WithdrawRecord,
WithdrawResponse,
} from '@/types/partner';
import { requestUserInfo } from '@/utils/user';
@ -53,7 +56,7 @@ export const getPartnerProfitStat = async () => {
return await http.post<PartnerProfitsState>(API.GET_PROFIT_STAT);
};
export const getPartnerInviteList = async (data: IPaginationRequest) => {
return await http.post<{ content: InviteUserInfo[]; totalPages: number }>(API.GET_INVITE_LIST, {
return await http.post<PartnerPagination<InviteUserInfo>>(API.GET_INVITE_LIST, {
data,
contentType: 'application/x-www-form-urlencoded',
});
@ -113,3 +116,14 @@ export function formatUserId(input: string): string {
// 拼接结果
return beforeMask + maskedPart + afterMask;
}
export async function withdrawMoney() {
return await http.post<WithdrawResponse>(API.WITHDRAW);
}
export async function getWithdrawList(data: IPaginationRequest) {
return await http.post<PartnerPagination<WithdrawRecord>>(API.GET_WITHDRAW_LIST, {
data,
contentType: 'application/x-www-form-urlencoded',
});
}