feat:
This commit is contained in:
@ -19,13 +19,14 @@ export enum BindPhoneStatus {
|
||||
export interface ILoginButtonProps extends ButtonProps {
|
||||
needPhone?: boolean;
|
||||
needRefresh?: boolean;
|
||||
onRefresh?: (() => void) | (() => Promise<void>);
|
||||
needAssignment?: boolean;
|
||||
}
|
||||
|
||||
const PREFIX = 'login-button';
|
||||
|
||||
function LoginButton(props: ILoginButtonProps) {
|
||||
const { className, children, needPhone, onClick, needRefresh, ...otherProps } = props;
|
||||
const { className, children, needPhone, onRefresh, onClick, needRefresh, ...otherProps } = props;
|
||||
const userInfo = useUserInfo();
|
||||
const [loginVisible, setLoginVisible] = useState(false);
|
||||
const [assignVisible, setAssignVisible] = useState(false);
|
||||
@ -69,10 +70,11 @@ function LoginButton(props: ILoginButtonProps) {
|
||||
}, []);
|
||||
|
||||
const handleLoginSuccess = useCallback(
|
||||
e => {
|
||||
async e => {
|
||||
setLoginVisible(false);
|
||||
if (needRefresh) {
|
||||
requestUserInfo();
|
||||
onRefresh && (await onRefresh());
|
||||
}
|
||||
onClick?.(e);
|
||||
},
|
||||
|
||||
@ -82,9 +82,16 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
setProductRecord(result);
|
||||
}, [data.id]);
|
||||
|
||||
const getProductBalance = useCallback(async () => {
|
||||
const getProductBalance = useCallback(async (loading?: boolean) => {
|
||||
if (loading) {
|
||||
Taro.showLoading();
|
||||
}
|
||||
const [, resp] = await requestProductBalance(ProductType.VIP);
|
||||
setProductInfo(resp);
|
||||
console.log(resp);
|
||||
if (loading) {
|
||||
Taro.hideLoading();
|
||||
}
|
||||
return resp;
|
||||
}, []);
|
||||
|
||||
@ -179,6 +186,10 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
// return productInfo?.isCreateResume? '升级会员即可查看': '创建模卡,免费查看';
|
||||
// }, [productInfo, haveSeen]);
|
||||
|
||||
const handleRefresh = useCallback(async () => {
|
||||
await getProductBalance(true);
|
||||
}, [getProductBalance]);
|
||||
|
||||
useEffect(() => {
|
||||
Taro.eventCenter.on(EventName.CREATE_PROFILE, getProductBalance);
|
||||
return () => {
|
||||
@ -200,7 +211,12 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
<Button className={`${PREFIX}__share-button`} openType="share">
|
||||
分享
|
||||
</Button>
|
||||
<LoginButton needRefresh className={`${PREFIX}__contact-publisher`} onClick={handleClickContact}>
|
||||
<LoginButton
|
||||
needRefresh
|
||||
onRefresh={handleRefresh}
|
||||
className={`${PREFIX}__contact-publisher`}
|
||||
onClick={handleClickContact}
|
||||
>
|
||||
{data.isAuthed ? '在线沟通' : '查看联系方式'}
|
||||
{needPhone ? (
|
||||
<div className={`${PREFIX}__contact-publisher-tag`}>登录后可免费报单</div>
|
||||
|
||||
@ -51,5 +51,8 @@ export const requestBatchPublishGroups = async () => {
|
||||
};
|
||||
|
||||
export const requestSimpleGroupList = async (cityCode?: string) => {
|
||||
return http.post<SimpleGroupInfo[]>(API.SIMPLE_GROUP_LIST, { data: { cityCode } });
|
||||
return http.post<SimpleGroupInfo[]>(API.SIMPLE_GROUP_LIST, {
|
||||
data: { cityCode },
|
||||
contentType: 'application/x-www-form-urlencoded',
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user