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