Merge branch 'trunk' into feat/update-login
This commit is contained in:
@ -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`}>
|
||||
|
||||
@ -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}
|
||||
>
|
||||
|
||||
@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@ -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`}>
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user