Compare commits
6 Commits
trunk
...
feat/updat
Author | SHA1 | Date | |
---|---|---|---|
|
0ec366cc2e | ||
|
828497fcd6 | ||
|
fd5b3dab97 | ||
|
1b782ee82c | ||
|
80c0d71921 | ||
|
5acc25c8c9 |
41
src/components/agreement-popup/index.less
Normal file
41
src/components/agreement-popup/index.less
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
@import '@/styles/common.less';
|
||||||
|
@import '@/styles/variables.less';
|
||||||
|
|
||||||
|
.agreement-popup {
|
||||||
|
&__content {
|
||||||
|
.flex-column();
|
||||||
|
padding: 40px 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 32px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 48px;
|
||||||
|
color: @blColor;;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__body {
|
||||||
|
font-weight: 400;
|
||||||
|
font-size: 28px;
|
||||||
|
line-height: 40px;
|
||||||
|
color: @blColor;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
align-self: flex-start;
|
||||||
|
};
|
||||||
|
|
||||||
|
&__btn-group {
|
||||||
|
margin-top: 32px;
|
||||||
|
.flex-row();
|
||||||
|
gap: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__confirm-button {
|
||||||
|
.button(@width: 230px, @height: 72px, @fontSize: 28px, @fontWeight: 400, @borderRadius: 44px);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
&__cancel-button {
|
||||||
|
.button(@width: 230px, @height: 72px, @fontSize: 28px, @fontWeight: 400, @borderRadius: 44px, @highlight: 0);
|
||||||
|
}
|
||||||
|
}
|
66
src/components/agreement-popup/index.tsx
Normal file
66
src/components/agreement-popup/index.tsx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import { Button, ITouchEvent } from '@tarojs/components';
|
||||||
|
|
||||||
|
import { Popup } from '@taroify/core';
|
||||||
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
|
import { BindPhoneStatus } from '@/components/login-button';
|
||||||
|
import PhoneButton from '@/components/phone-button';
|
||||||
|
import { ProtocolPrivacy } from '@/components/protocol-privacy';
|
||||||
|
import SafeBottomPadding from '@/components/safe-bottom-padding';
|
||||||
|
|
||||||
|
import './index.less';
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
open: boolean;
|
||||||
|
onCancel: () => void;
|
||||||
|
onConfirm: (e: ITouchEvent) => void;
|
||||||
|
needPhone?: boolean;
|
||||||
|
needBindPhone?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PREFIX = 'agreement-popup';
|
||||||
|
|
||||||
|
export function AgreementPopup({ open, onCancel, onConfirm, needPhone, needBindPhone }: IProps) {
|
||||||
|
const handleBindPhone = useCallback(
|
||||||
|
(status: BindPhoneStatus, e: ITouchEvent) => {
|
||||||
|
if (status === BindPhoneStatus.Success) {
|
||||||
|
onConfirm(e);
|
||||||
|
} else {
|
||||||
|
onCancel();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[onCancel, onConfirm]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!open) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Popup rounded className={PREFIX} placement="bottom" open={open} onClose={onCancel}>
|
||||||
|
<div className={`${PREFIX}__content`}>
|
||||||
|
<div className={`${PREFIX}__title`}>提示</div>
|
||||||
|
<div className={`${PREFIX}__body`}>
|
||||||
|
<div>你好,以下是播络隐私协议与用户协议</div>
|
||||||
|
<div>同意后可使用全部功能,不同意你也可以浏览</div>
|
||||||
|
</div>
|
||||||
|
<ProtocolPrivacy divider />
|
||||||
|
<div className={`${PREFIX}__btn-group`}>
|
||||||
|
<Button className={`${PREFIX}__cancel-button`} onClick={onCancel}>
|
||||||
|
拒绝
|
||||||
|
</Button>
|
||||||
|
{needBindPhone ? (
|
||||||
|
<PhoneButton className={`${PREFIX}__confirm-button`} needPhone={needPhone} onBindPhone={handleBindPhone}>
|
||||||
|
同意
|
||||||
|
</PhoneButton>
|
||||||
|
) : (
|
||||||
|
<Button className={`${PREFIX}__confirm-button`} onClick={onConfirm}>
|
||||||
|
同意
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<SafeBottomPadding />
|
||||||
|
</Popup>
|
||||||
|
);
|
||||||
|
}
|
@ -18,6 +18,7 @@ import './index.less';
|
|||||||
interface IProps {
|
interface IProps {
|
||||||
data: AnchorInfo;
|
data: AnchorInfo;
|
||||||
jobId?: string;
|
jobId?: string;
|
||||||
|
validator: (onSuccess: () => void) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PREFIX = 'anchor-card';
|
const PREFIX = 'anchor-card';
|
||||||
@ -34,14 +35,17 @@ const getSalary = (data: AnchorInfo) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function AnchorCard(props: IProps) {
|
function AnchorCard(props: IProps) {
|
||||||
const { data, jobId } = props;
|
const { data, jobId, validator } = props;
|
||||||
const style = data.isRead ? ({ '--read-color': '#999999' } as React.CSSProperties) : {};
|
const style = data.isRead ? ({ '--read-color': '#999999' } as React.CSSProperties) : {};
|
||||||
const cover = (data.materialVideoInfoList.find(video => video.isDefault) || data.materialVideoInfoList[0])?.coverUrl;
|
const cover = (data.materialVideoInfoList.find(video => video.isDefault) || data.materialVideoInfoList[0])?.coverUrl;
|
||||||
|
|
||||||
const handleClick = useCallback(
|
const handleNavTo = useCallback(() => {
|
||||||
() => navigateTo(PageUrl.MaterialView, { jobId, resumeId: data.id, source: MaterialViewSource.AnchorList }),
|
navigateTo(PageUrl.MaterialView, { jobId, resumeId: data.id, source: MaterialViewSource.AnchorList });
|
||||||
[data, jobId]
|
}, [data, jobId]);
|
||||||
);
|
|
||||||
|
const handleClick = useCallback(() => {
|
||||||
|
validator(handleNavTo);
|
||||||
|
}, [handleNavTo, validator]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={PREFIX} style={style} onClick={handleClick}>
|
<div className={PREFIX} style={style} onClick={handleClick}>
|
||||||
|
@ -7,11 +7,16 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|||||||
|
|
||||||
import AnchorCard from '@/components/anchor-card';
|
import AnchorCard from '@/components/anchor-card';
|
||||||
import ListPlaceholder from '@/components/list-placeholder';
|
import ListPlaceholder from '@/components/list-placeholder';
|
||||||
|
import LoginDialog from '@/components/login-dialog';
|
||||||
import { EventName } from '@/constants/app';
|
import { EventName } from '@/constants/app';
|
||||||
import { AnchorSortType } from '@/constants/material';
|
import { AnchorSortType } from '@/constants/material';
|
||||||
|
import useUserInfo from '@/hooks/use-user-info';
|
||||||
import { AnchorInfo, GetAnchorListRequest, IAnchorFilters } from '@/types/material';
|
import { AnchorInfo, GetAnchorListRequest, IAnchorFilters } from '@/types/material';
|
||||||
import { logWithPrefix } from '@/utils/common';
|
import { logWithPrefix } from '@/utils/common';
|
||||||
import { requestAnchorList as requestData } from '@/utils/material';
|
import { requestAnchorList as requestData } from '@/utils/material';
|
||||||
|
import { getAgreementSigned, isNeedLogin, setAgreementSigned } from '@/utils/user';
|
||||||
|
|
||||||
|
import { AgreementPopup } from '../agreement-popup';
|
||||||
|
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
@ -55,6 +60,11 @@ function AnchorList(props: IAnchorListProps) {
|
|||||||
const requestProps = useRef<IRequestProps>({});
|
const requestProps = useRef<IRequestProps>({});
|
||||||
const prevRequestProps = useRef<IRequestProps>({});
|
const prevRequestProps = useRef<IRequestProps>({});
|
||||||
const onListEmptyRef = useRef(onListEmpty);
|
const onListEmptyRef = useRef(onListEmpty);
|
||||||
|
const [openLogin, setLoginOpen] = useState(false);
|
||||||
|
const [openAssignment, setAssignmentOpen] = useState(false);
|
||||||
|
const successCallback = useRef<() => void>(() => {});
|
||||||
|
const userInfo = useUserInfo();
|
||||||
|
const needLogin = isNeedLogin(userInfo);
|
||||||
|
|
||||||
const handleRefresh = useCallback(async () => {
|
const handleRefresh = useCallback(async () => {
|
||||||
log('start pull refresh');
|
log('start pull refresh');
|
||||||
@ -120,6 +130,37 @@ function AnchorList(props: IAnchorListProps) {
|
|||||||
[dataList]
|
[dataList]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleCancel = useCallback(() => {
|
||||||
|
setAssignmentOpen(false);
|
||||||
|
setAgreementSigned(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleConfirm = useCallback(() => {
|
||||||
|
setAssignmentOpen(false);
|
||||||
|
setAgreementSigned(true);
|
||||||
|
successCallback.current();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleLoginSuccess = useCallback(() => {
|
||||||
|
setLoginOpen(false);
|
||||||
|
successCallback.current();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleLoginCancel = useCallback(() => {
|
||||||
|
setLoginOpen(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const validator = (onSuccess: () => void) => {
|
||||||
|
successCallback.current = onSuccess;
|
||||||
|
if (!getAgreementSigned()) {
|
||||||
|
setAssignmentOpen(true);
|
||||||
|
} else if (needLogin) {
|
||||||
|
setLoginOpen(true);
|
||||||
|
} else {
|
||||||
|
onSuccess();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onListEmptyRef.current = onListEmpty;
|
onListEmptyRef.current = onListEmpty;
|
||||||
}, [onListEmpty]);
|
}, [onListEmpty]);
|
||||||
@ -183,26 +224,35 @@ function AnchorList(props: IAnchorListProps) {
|
|||||||
}, [jobId, ready, filters, cityCode, sortType]);
|
}, [jobId, ready, filters, cityCode, sortType]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PullRefresh
|
<>
|
||||||
className={classNames(`${PREFIX}__pull-refresh`, className)}
|
<PullRefresh
|
||||||
loading={refreshing}
|
className={classNames(`${PREFIX}__pull-refresh`, className)}
|
||||||
onRefresh={handleRefresh}
|
loading={refreshing}
|
||||||
disabled={refreshDisabled || !ready}
|
onRefresh={handleRefresh}
|
||||||
>
|
disabled={refreshDisabled || !ready}
|
||||||
<List
|
|
||||||
hasMore={hasMore}
|
|
||||||
onLoad={handleLoadMore}
|
|
||||||
loading={loadingMore || refreshing}
|
|
||||||
disabled={loadMoreError || !ready}
|
|
||||||
fixedHeight={typeof listHeight !== 'undefined'}
|
|
||||||
style={listHeight ? { height: `${listHeight}px` } : undefined}
|
|
||||||
>
|
>
|
||||||
{dataList.map(item => (
|
<List
|
||||||
<AnchorCard data={item} jobId={jobId} key={item.id} />
|
hasMore={hasMore}
|
||||||
))}
|
onLoad={handleLoadMore}
|
||||||
<ListPlaceholder hasMore={hasMore} loadingMore={loadingMore} loadMoreError={loadMoreError} />
|
loading={loadingMore || refreshing}
|
||||||
</List>
|
disabled={loadMoreError || !ready}
|
||||||
</PullRefresh>
|
fixedHeight={typeof listHeight !== 'undefined'}
|
||||||
|
style={listHeight ? { height: `${listHeight}px` } : undefined}
|
||||||
|
>
|
||||||
|
{dataList.map(item => (
|
||||||
|
<AnchorCard data={item} jobId={jobId} key={item.id} validator={validator} />
|
||||||
|
))}
|
||||||
|
<ListPlaceholder hasMore={hasMore} loadingMore={loadingMore} loadMoreError={loadMoreError} />
|
||||||
|
</List>
|
||||||
|
</PullRefresh>
|
||||||
|
<AgreementPopup
|
||||||
|
open={openAssignment}
|
||||||
|
onCancel={handleCancel}
|
||||||
|
onConfirm={handleConfirm}
|
||||||
|
needBindPhone={needLogin}
|
||||||
|
/>
|
||||||
|
{openLogin && <LoginDialog onCancel={handleLoginCancel} onSuccess={handleLoginSuccess} />}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { Button, ButtonProps } from '@tarojs/components';
|
import { Button, ButtonProps, ITouchEvent } from '@tarojs/components';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
|
|
||||||
|
import { AgreementPopup } from '@/components/agreement-popup';
|
||||||
import LoginDialog from '@/components/login-dialog';
|
import LoginDialog from '@/components/login-dialog';
|
||||||
import useUserInfo from '@/hooks/use-user-info';
|
import useUserInfo from '@/hooks/use-user-info';
|
||||||
import { isNeedLogin } from '@/utils/user';
|
import { getAgreementSigned, isNeedLogin, setAgreementSigned } from '@/utils/user';
|
||||||
|
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ export enum BindPhoneStatus {
|
|||||||
|
|
||||||
export interface ILoginButtonProps extends ButtonProps {
|
export interface ILoginButtonProps extends ButtonProps {
|
||||||
needPhone?: boolean;
|
needPhone?: boolean;
|
||||||
|
needAssignment?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PREFIX = 'login-button';
|
const PREFIX = 'login-button';
|
||||||
@ -24,12 +26,50 @@ const PREFIX = 'login-button';
|
|||||||
function LoginButton(props: ILoginButtonProps) {
|
function LoginButton(props: ILoginButtonProps) {
|
||||||
const { className, children, needPhone, onClick, ...otherProps } = props;
|
const { className, children, needPhone, onClick, ...otherProps } = props;
|
||||||
const userInfo = useUserInfo();
|
const userInfo = useUserInfo();
|
||||||
const [visible, setVisible] = useState(false);
|
const [loginVisible, setLoginVisible] = useState(false);
|
||||||
|
const [assignVisible, setAssignVisible] = useState(false);
|
||||||
const needLogin = isNeedLogin(userInfo);
|
const needLogin = isNeedLogin(userInfo);
|
||||||
|
// 点击按钮时,协议同意也手机也授权了 -> 下一步
|
||||||
|
//
|
||||||
|
// 点击按钮时,协议同意但是手机授权没给 -> 弹登录
|
||||||
|
// -> 如果授权了手机号就进行下一步
|
||||||
|
// -> 不给授权没下一步
|
||||||
|
//
|
||||||
|
// 点击按钮时,协议不同意 -> 弹协议窗口
|
||||||
|
// -> 如果同意就进行下一步
|
||||||
|
// -> 不同意没下一步
|
||||||
|
const handleClick = useCallback(
|
||||||
|
(e: ITouchEvent) => {
|
||||||
|
if (!getAgreementSigned()) {
|
||||||
|
setAssignVisible(true);
|
||||||
|
} else if (needLogin) {
|
||||||
|
setLoginVisible(true);
|
||||||
|
} else if (onClick) {
|
||||||
|
onClick(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[needLogin, onClick]
|
||||||
|
);
|
||||||
|
|
||||||
const onSuccess = useCallback(
|
const handleConfirm = useCallback(
|
||||||
|
(e: ITouchEvent) => {
|
||||||
|
setAssignVisible(false);
|
||||||
|
setAgreementSigned(true);
|
||||||
|
if (onClick) {
|
||||||
|
onClick(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[onClick]
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleCancel = useCallback(() => {
|
||||||
|
setAgreementSigned(false);
|
||||||
|
setAssignVisible(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleLoginSuccess = useCallback(
|
||||||
e => {
|
e => {
|
||||||
setVisible(false);
|
setLoginVisible(false);
|
||||||
onClick?.(e);
|
onClick?.(e);
|
||||||
},
|
},
|
||||||
[onClick]
|
[onClick]
|
||||||
@ -37,14 +77,18 @@ function LoginButton(props: ILoginButtonProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button {...otherProps} className={classNames(PREFIX, className)} onClick={handleClick}>
|
||||||
{...otherProps}
|
|
||||||
className={classNames(PREFIX, className)}
|
|
||||||
onClick={needLogin ? () => setVisible(true) : onClick}
|
|
||||||
>
|
|
||||||
{children}
|
{children}
|
||||||
</Button>
|
</Button>
|
||||||
{visible && <LoginDialog onCancel={() => setVisible(false)} onSuccess={onSuccess} needPhone={needPhone} />}
|
<AgreementPopup
|
||||||
|
open={assignVisible}
|
||||||
|
onCancel={handleCancel}
|
||||||
|
onConfirm={handleConfirm}
|
||||||
|
needBindPhone={needLogin}
|
||||||
|
/>
|
||||||
|
{loginVisible && (
|
||||||
|
<LoginDialog onCancel={() => setLoginVisible(false)} onSuccess={handleLoginSuccess} needPhone={needPhone} />
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -17,22 +17,4 @@
|
|||||||
.button(@width: 360px, @height: 72px, @fontSize: 28px, @fontWeight: 400, @borderRadius: 44px);
|
.button(@width: 360px, @height: 72px, @fontSize: 28px, @fontWeight: 400, @borderRadius: 44px);
|
||||||
margin-top: 40px;
|
margin-top: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__cancel-button {
|
|
||||||
min-width: fit-content;
|
|
||||||
font-size: 28px;
|
|
||||||
line-height: 32px;
|
|
||||||
color: @blHighlightColor;
|
|
||||||
background: transparent;
|
|
||||||
border: none;
|
|
||||||
margin-top: 40px;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
border-color: transparent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__checkbox {
|
|
||||||
margin-top: 40px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
import { Button } from '@tarojs/components';
|
|
||||||
|
|
||||||
import { Dialog } from '@taroify/core';
|
import { Dialog } from '@taroify/core';
|
||||||
import { useCallback, useState } from 'react';
|
|
||||||
|
|
||||||
import PhoneButton, { IPhoneButtonProps } from '@/components/phone-button';
|
import PhoneButton, { IPhoneButtonProps } from '@/components/phone-button';
|
||||||
import { ProtocolPrivacyCheckbox } from '@/components/protocol-privacy';
|
|
||||||
import Toast from '@/utils/toast';
|
|
||||||
|
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
@ -21,36 +16,20 @@ const PREFIX = 'login-dialog';
|
|||||||
|
|
||||||
export default function LoginDialog(props: IProps) {
|
export default function LoginDialog(props: IProps) {
|
||||||
const { title = '使用播络服务前,请先登录', needPhone, onSuccess, onCancel, onBindPhone } = props;
|
const { title = '使用播络服务前,请先登录', needPhone, onSuccess, onCancel, onBindPhone } = props;
|
||||||
const [checked, setChecked] = useState(false);
|
|
||||||
|
|
||||||
const handleTipCheck = useCallback(() => {
|
|
||||||
Toast.info('请先阅读并同意协议');
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open onClose={onCancel}>
|
<Dialog open onClose={onCancel}>
|
||||||
<Dialog.Content>
|
<Dialog.Content>
|
||||||
<div className={`${PREFIX}__container`}>
|
<div className={`${PREFIX}__container`}>
|
||||||
<div className={`${PREFIX}__title`}>{title}</div>
|
<div className={`${PREFIX}__title`}>{title}</div>
|
||||||
{!checked && (
|
<PhoneButton
|
||||||
<Button className={`${PREFIX}__confirm-button`} onClick={handleTipCheck}>
|
className={`${PREFIX}__confirm-button`}
|
||||||
登录
|
onSuccess={onSuccess}
|
||||||
</Button>
|
onBindPhone={onBindPhone}
|
||||||
)}
|
needPhone={needPhone}
|
||||||
{checked && (
|
>
|
||||||
<PhoneButton
|
登录
|
||||||
className={`${PREFIX}__confirm-button`}
|
</PhoneButton>
|
||||||
onSuccess={onSuccess}
|
|
||||||
onBindPhone={onBindPhone}
|
|
||||||
needPhone={needPhone}
|
|
||||||
>
|
|
||||||
登录
|
|
||||||
</PhoneButton>
|
|
||||||
)}
|
|
||||||
<Button className={`${PREFIX}__cancel-button`} onClick={onCancel}>
|
|
||||||
跳过,暂不登录
|
|
||||||
</Button>
|
|
||||||
<ProtocolPrivacyCheckbox checked={checked} onChange={setChecked} className={`${PREFIX}__checkbox`} />
|
|
||||||
</div>
|
</div>
|
||||||
</Dialog.Content>
|
</Dialog.Content>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
@ -60,7 +60,9 @@ export default function PartnerBanner() {
|
|||||||
)}
|
)}
|
||||||
<div className={`${PREFIX}__close`} onClick={handlePartnerBannerClose} />
|
<div className={`${PREFIX}__close`} onClick={handlePartnerBannerClose} />
|
||||||
</div>
|
</div>
|
||||||
{visible && <LoginDialog onCancel={() => setVisible(false)} onSuccess={handleBind} needPhone={needPhone} />}
|
{visible && (
|
||||||
|
<LoginDialog disableCheck onCancel={() => setVisible(false)} onSuccess={handleBind} needPhone={needPhone} />
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,9 @@ function JoinEntry({ onBindSuccess }: JoinEntryProps) {
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{visible && <LoginDialog onCancel={() => setVisible(false)} onSuccess={onBindSuccess} needPhone={needPhone} />}
|
{visible && (
|
||||||
|
<LoginDialog disableCheck onCancel={() => setVisible(false)} onSuccess={onBindSuccess} needPhone={needPhone} />
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ function WithdrawDialog(props: { open: boolean; onClose: () => void; count: numb
|
|||||||
{+props.count}
|
{+props.count}
|
||||||
<div className="yuan">元</div>
|
<div className="yuan">元</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={`${PREFIX}-withdraw-dialog__hint`}>单笔最大500元</div>
|
<div className={`${PREFIX}-withdraw-dialog__hint`}>单日提现最大200元</div>
|
||||||
<Button className={`${PREFIX}-withdraw-dialog__confirm-button`} onClick={handleWithdraw}>
|
<Button className={`${PREFIX}-withdraw-dialog__confirm-button`} onClick={handleWithdraw}>
|
||||||
提现
|
提现
|
||||||
</Button>
|
</Button>
|
||||||
@ -193,7 +193,7 @@ export default function PartnerKanban({ simple }: PartnerKanbanProps) {
|
|||||||
{!simple && <TipDialog open={tipOpen} onClose={handleTipClose} />}
|
{!simple && <TipDialog open={tipOpen} onClose={handleTipClose} />}
|
||||||
{!simple && (
|
{!simple && (
|
||||||
<WithdrawDialog
|
<WithdrawDialog
|
||||||
count={Math.min(Number(formatMoney(stats.availableBalance)), 500)}
|
count={Math.min(Number(formatMoney(stats.availableBalance)), 200)}
|
||||||
open={withdrawOpen}
|
open={withdrawOpen}
|
||||||
onClose={handleWithdrawClose}
|
onClose={handleWithdrawClose}
|
||||||
/>
|
/>
|
||||||
|
@ -19,7 +19,7 @@ export interface IPhoneButtonProps extends ButtonProps {
|
|||||||
message?: string;
|
message?: string;
|
||||||
// 绑定后是否需要刷新接口获取手机号
|
// 绑定后是否需要刷新接口获取手机号
|
||||||
needPhone?: boolean;
|
needPhone?: boolean;
|
||||||
onBindPhone?: (status: BindPhoneStatus) => void;
|
onBindPhone?: (status: BindPhoneStatus, e: ITouchEvent) => void;
|
||||||
onSuccess?: (e: ITouchEvent) => void;
|
onSuccess?: (e: ITouchEvent) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,17 +44,17 @@ export default function PhoneButton(props: IPhoneButtonProps) {
|
|||||||
const encryptedData = e.detail.encryptedData;
|
const encryptedData = e.detail.encryptedData;
|
||||||
const iv = e.detail.iv;
|
const iv = e.detail.iv;
|
||||||
if (!encryptedData || !iv) {
|
if (!encryptedData || !iv) {
|
||||||
onBindPhone?.(BindPhoneStatus.Cancel);
|
onBindPhone?.(BindPhoneStatus.Cancel, e as ITouchEvent);
|
||||||
return Toast.error('取消授权');
|
return Toast.error('取消授权');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await setPhoneNumber({ encryptedData, iv });
|
await setPhoneNumber({ encryptedData, iv });
|
||||||
needPhone && (await requestUserInfo());
|
needPhone && (await requestUserInfo());
|
||||||
Toast.success(message);
|
Toast.success(message);
|
||||||
onBindPhone?.(BindPhoneStatus.Success);
|
onBindPhone?.(BindPhoneStatus.Success, e as ITouchEvent);
|
||||||
onSuccess?.(e as ITouchEvent);
|
onSuccess?.(e as ITouchEvent);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
onBindPhone?.(BindPhoneStatus.Error);
|
onBindPhone?.(BindPhoneStatus.Error, e as ITouchEvent);
|
||||||
Toast.error('绑定失败');
|
Toast.error('绑定失败');
|
||||||
log('bind phone fail', err);
|
log('bind phone fail', err);
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,6 @@ export enum CacheKey {
|
|||||||
LAST_SELECT_MY_JOB = '__last_select_my_job__',
|
LAST_SELECT_MY_JOB = '__last_select_my_job__',
|
||||||
CLOSE_PARTNER_BANNER = '__close_partner_banner__',
|
CLOSE_PARTNER_BANNER = '__close_partner_banner__',
|
||||||
INVITE_CODE = '__invite_code__',
|
INVITE_CODE = '__invite_code__',
|
||||||
|
AGREEMENT_SIGNED = '__agreement_signed__',
|
||||||
|
CITY_CODES = '__city_codes__',
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ const getSalaryPrice = (fullSalary?: SalaryRange, partSalary?: SalaryRange) => {
|
|||||||
|
|
||||||
function ProfileIntentionFragment(props: IProps, ref) {
|
function ProfileIntentionFragment(props: IProps, ref) {
|
||||||
const { profile } = props;
|
const { profile } = props;
|
||||||
const [cityCodes, setCityCodes] = useState(calcInitCityCodes(profile.cityCodes));
|
const [cityCodes, setCityCodes] = useState(calcInitCityCodes(profile.cityCodes || ''));
|
||||||
const [employType, setEmployType] = useState(profile.employType);
|
const [employType, setEmployType] = useState(profile.employType);
|
||||||
const [fullSalary, setFullSalary] = useState(calcSalarySelect(profile, true));
|
const [fullSalary, setFullSalary] = useState(calcSalarySelect(profile, true));
|
||||||
const [partSalary, setPartSalary] = useState(calcSalarySelect(profile, false));
|
const [partSalary, setPartSalary] = useState(calcSalarySelect(profile, false));
|
||||||
|
@ -186,7 +186,7 @@ export default function AnchorPage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useShareAppMessage(() => {
|
useShareAppMessage(() => {
|
||||||
return getCommonShareMessage(true, inviteCode);
|
return getCommonShareMessage(true, inviteCode, '数万名优质主播等你来挑');
|
||||||
});
|
});
|
||||||
|
|
||||||
useDidShow(() => requestUnreadMessageCount());
|
useDidShow(() => requestUnreadMessageCount());
|
||||||
|
@ -11,6 +11,7 @@ import { getCurrentCityCode } from '@/utils/location';
|
|||||||
import { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
import { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
||||||
import { getPageQuery } from '@/utils/route';
|
import { getPageQuery } from '@/utils/route';
|
||||||
import { getCommonShareMessage } from '@/utils/share';
|
import { getCommonShareMessage } from '@/utils/share';
|
||||||
|
import { checkCityCode } from '@/utils/user';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
const PREFIX = 'group-v2-page';
|
const PREFIX = 'group-v2-page';
|
||||||
@ -26,6 +27,9 @@ export default function GroupV2() {
|
|||||||
useShareAppMessage(() => getCommonShareMessage(true, inviteCode));
|
useShareAppMessage(() => getCommonShareMessage(true, inviteCode));
|
||||||
|
|
||||||
const handleSelectCity = useCallback(cityCode => {
|
const handleSelectCity = useCallback(cityCode => {
|
||||||
|
if (!checkCityCode(cityCode)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const group = GROUPS.find(g => String(g.cityCode) === cityCode);
|
const group = GROUPS.find(g => String(g.cityCode) === cityCode);
|
||||||
if (group) {
|
if (group) {
|
||||||
openCustomerServiceChat(group.serviceUrl);
|
openCustomerServiceChat(group.serviceUrl);
|
||||||
|
@ -112,7 +112,6 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
|||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
const handleDialogHidden = useCallback(() => setDialogVisible(false), []);
|
const handleDialogHidden = useCallback(() => setDialogVisible(false), []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={`${PREFIX}__footer`}>
|
<div className={`${PREFIX}__footer`}>
|
||||||
|
@ -4,7 +4,6 @@ import { Tabs } from '@taroify/core';
|
|||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
import HomePage from '@/components/home-page';
|
import HomePage from '@/components/home-page';
|
||||||
import LocationDialog from '@/components/location-dialog';
|
|
||||||
import { LoginGuide } from '@/components/login-guide';
|
import { LoginGuide } from '@/components/login-guide';
|
||||||
import MaterialGuide from '@/components/material-guide';
|
import MaterialGuide from '@/components/material-guide';
|
||||||
import { EventName, OpenSource, PageUrl } from '@/constants/app';
|
import { EventName, OpenSource, PageUrl } from '@/constants/app';
|
||||||
@ -82,13 +81,6 @@ export default function Job() {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleCloseAuthorize = useCallback(() => setShowAuthorize(false), []);
|
|
||||||
|
|
||||||
const handleClickAuthorize = useCallback(() => {
|
|
||||||
requestLocation(true);
|
|
||||||
setShowAuthorize(false);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Taro.eventCenter.on(EventName.SELECT_CITY, handleCityChange);
|
Taro.eventCenter.on(EventName.SELECT_CITY, handleCityChange);
|
||||||
return () => {
|
return () => {
|
||||||
@ -116,6 +108,7 @@ export default function Job() {
|
|||||||
} else {
|
} else {
|
||||||
log('show authorize location dialog');
|
log('show authorize location dialog');
|
||||||
setShowAuthorize(true);
|
setShowAuthorize(true);
|
||||||
|
requestLocation(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -154,7 +147,6 @@ export default function Job() {
|
|||||||
))}
|
))}
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<div>
|
<div>
|
||||||
<LocationDialog open={showAuthorize} onClose={handleCloseAuthorize} onClick={handleClickAuthorize} />
|
|
||||||
<LoginGuide disabled={showAuthorize} onAfterBind={handleAfterBindPhone} />
|
<LoginGuide disabled={showAuthorize} onAfterBind={handleAfterBindPhone} />
|
||||||
{showMaterialGuide && <MaterialGuide onClose={() => setShowMaterialGuide(false)} />}
|
{showMaterialGuide && <MaterialGuide onClose={() => setShowMaterialGuide(false)} />}
|
||||||
</div>
|
</div>
|
||||||
|
@ -31,7 +31,7 @@ import {
|
|||||||
PostMessageRequest,
|
PostMessageRequest,
|
||||||
} from '@/types/message';
|
} from '@/types/message';
|
||||||
import { isAnchorMode } from '@/utils/app';
|
import { isAnchorMode } from '@/utils/app';
|
||||||
import { getScrollItemId, last, logWithPrefix, safeJsonParse } from '@/utils/common';
|
import { getScrollItemId, last, logWithPrefix } from '@/utils/common';
|
||||||
import { collectEvent } from '@/utils/event';
|
import { collectEvent } from '@/utils/event';
|
||||||
import {
|
import {
|
||||||
isExchangeMessage,
|
isExchangeMessage,
|
||||||
@ -55,7 +55,6 @@ import Toast from '@/utils/toast';
|
|||||||
import { getUserId } from '@/utils/user';
|
import { getUserId } from '@/utils/user';
|
||||||
|
|
||||||
import './index.less';
|
import './index.less';
|
||||||
import useUserInfo from '@/hooks/use-user-info';
|
|
||||||
|
|
||||||
const PREFIX = 'page-message-chat';
|
const PREFIX = 'page-message-chat';
|
||||||
const LIST_CONTAINER_CLASS = `${PREFIX}__chat-list`;
|
const LIST_CONTAINER_CLASS = `${PREFIX}__chat-list`;
|
||||||
@ -86,19 +85,8 @@ const getHeaderLeftButtonText = (job?: IJobMessage, material?: IMaterialMessage)
|
|||||||
return isAnchorMode() ? '不感兴趣' : '标记为不合适';
|
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() {
|
export default function MessageChat() {
|
||||||
const listHeight = useListHeight(CALC_LIST_PROPS);
|
const listHeight = useListHeight(CALC_LIST_PROPS);
|
||||||
const { userId } = useUserInfo();
|
|
||||||
const [input, setInput] = useState('');
|
const [input, setInput] = useState('');
|
||||||
const [showMore, setShowMore] = useState(false);
|
const [showMore, setShowMore] = useState(false);
|
||||||
const [chat, setChat] = useState<IChatInfo | null>(null);
|
const [chat, setChat] = useState<IChatInfo | null>(null);
|
||||||
@ -107,8 +95,8 @@ export default function MessageChat() {
|
|||||||
const [messages, setMessages] = useState<IChatMessage[]>([]);
|
const [messages, setMessages] = useState<IChatMessage[]>([]);
|
||||||
const [messageStatusList, setMessageStatusList] = useState<IMessageStatus[]>([]);
|
const [messageStatusList, setMessageStatusList] = useState<IMessageStatus[]>([]);
|
||||||
const [jobId, setJobId] = useState<string>();
|
const [jobId, setJobId] = useState<string>();
|
||||||
|
const [resumeId, setResumeId] = useState<string>();
|
||||||
const [job, setJob] = useState<IJobMessage>();
|
const [job, setJob] = useState<IJobMessage>();
|
||||||
const [resumeId, setResumeId] = useState<string | undefined>();
|
|
||||||
const [material, setMaterial] = useState<IMaterialMessage>();
|
const [material, setMaterial] = useState<IMaterialMessage>();
|
||||||
const [scrollItemId, setScrollItemId] = useState<string>();
|
const [scrollItemId, setScrollItemId] = useState<string>();
|
||||||
const scrollToLowerRef = useRef(false);
|
const scrollToLowerRef = useRef(false);
|
||||||
@ -265,14 +253,6 @@ export default function MessageChat() {
|
|||||||
// };
|
// };
|
||||||
// }, []);
|
// }, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (resumeId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setResumeId(getResumeId(messages, userId));
|
|
||||||
}, [messages, resumeId, userId]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
return;
|
return;
|
||||||
@ -319,6 +299,7 @@ export default function MessageChat() {
|
|||||||
const parseMaterial = query.material ? parseQuery<IMaterialMessage>(query.material) : null;
|
const parseMaterial = query.material ? parseQuery<IMaterialMessage>(query.material) : null;
|
||||||
// log('requestChatDetail', chatDetail, parseJob, parseMaterial);
|
// log('requestChatDetail', chatDetail, parseJob, parseMaterial);
|
||||||
setChat(chatDetail);
|
setChat(chatDetail);
|
||||||
|
setResumeId(chatDetail.participants.find(u => u.userId !== currentUserId)?.resumeId);
|
||||||
setJobId(query.jobId);
|
setJobId(query.jobId);
|
||||||
setMessages(chatDetail.messages);
|
setMessages(chatDetail.messages);
|
||||||
setScrollItemId(getScrollItemId(last(chatDetail.messages)?.msgId));
|
setScrollItemId(getScrollItemId(last(chatDetail.messages)?.msgId));
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import { Image } from '@tarojs/components';
|
import { Image } from '@tarojs/components';
|
||||||
|
|
||||||
import { useLoad } from '@tarojs/taro';
|
import { useLoad } from '@tarojs/taro';
|
||||||
|
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
import { AgreementPopup } from '@/components/agreement-popup';
|
||||||
import Slogan from '@/components/slogan';
|
import Slogan from '@/components/slogan';
|
||||||
import { PageUrl, RoleType } from '@/constants/app';
|
import { PageUrl, RoleType } from '@/constants/app';
|
||||||
import { ANCHOR_TAB_LIST, COMPANY_TAB_LIST } from '@/hooks/use-config';
|
import { ANCHOR_TAB_LIST, COMPANY_TAB_LIST } from '@/hooks/use-config';
|
||||||
@ -8,12 +11,13 @@ import store from '@/store';
|
|||||||
import { changeHomePage } from '@/store/actions';
|
import { changeHomePage } from '@/store/actions';
|
||||||
import { getRoleType, switchDefaultTab, switchRoleType } from '@/utils/app';
|
import { getRoleType, switchDefaultTab, switchRoleType } from '@/utils/app';
|
||||||
import { switchTab } from '@/utils/route';
|
import { switchTab } from '@/utils/route';
|
||||||
|
import { getAgreementSigned, setAgreementSigned } from '@/utils/user';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
const PREFIX = 'page-start';
|
const PREFIX = 'page-start';
|
||||||
|
|
||||||
export default function Start() {
|
export default function Start() {
|
||||||
|
const [open, setOpen] = useState(typeof getAgreementSigned() !== 'boolean');
|
||||||
const mode = getRoleType();
|
const mode = getRoleType();
|
||||||
useLoad(() => {
|
useLoad(() => {
|
||||||
switchDefaultTab();
|
switchDefaultTab();
|
||||||
@ -30,6 +34,15 @@ export default function Start() {
|
|||||||
await switchTab(COMPANY_TAB_LIST[0].pagePath as PageUrl);
|
await switchTab(COMPANY_TAB_LIST[0].pagePath as PageUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCancel = () => {
|
||||||
|
setOpen(false);
|
||||||
|
setAgreementSigned(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleConfirm = () => {
|
||||||
|
setOpen(false);
|
||||||
|
setAgreementSigned(true);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div className={`${PREFIX} ${mode ? '' : 'color-bg'}`}>
|
<div className={`${PREFIX} ${mode ? '' : 'color-bg'}`}>
|
||||||
{mode && (
|
{mode && (
|
||||||
@ -69,6 +82,7 @@ export default function Start() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Slogan />
|
<Slogan />
|
||||||
|
<AgreementPopup open={open} onCancel={handleCancel} onConfirm={handleConfirm} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,6 +11,7 @@ import useInviteCode from '@/hooks/use-invite-code';
|
|||||||
import { openCustomerServiceChat } from '@/utils/common';
|
import { openCustomerServiceChat } from '@/utils/common';
|
||||||
import { getCurrentCityCode } from '@/utils/location';
|
import { getCurrentCityCode } from '@/utils/location';
|
||||||
import { getCommonShareMessage } from '@/utils/share';
|
import { getCommonShareMessage } from '@/utils/share';
|
||||||
|
import { checkCityCode } from '@/utils/user';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
const PREFIX = 'page-biz-service';
|
const PREFIX = 'page-biz-service';
|
||||||
@ -22,6 +23,9 @@ export default function BizService() {
|
|||||||
openCustomerServiceChat('https://work.weixin.qq.com/kfid/kfcd60708731367168d');
|
openCustomerServiceChat('https://work.weixin.qq.com/kfid/kfcd60708731367168d');
|
||||||
}, []);
|
}, []);
|
||||||
const handleSelectCity = useCallback(cityCode => {
|
const handleSelectCity = useCallback(cityCode => {
|
||||||
|
if (!checkCityCode(cityCode)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const group = GROUPS.find(g => String(g.cityCode) === cityCode);
|
const group = GROUPS.find(g => String(g.cityCode) === cityCode);
|
||||||
if (group) {
|
if (group) {
|
||||||
openCustomerServiceChat(group.serviceUrl);
|
openCustomerServiceChat(group.serviceUrl);
|
||||||
|
@ -43,7 +43,9 @@ export interface ILocationMessage {
|
|||||||
longitude: number;
|
longitude: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IChatUser extends Pick<UserInfo, 'userId' | 'nickName'> {}
|
export interface IChatUser extends Pick<UserInfo, 'userId' | 'nickName'> {
|
||||||
|
resumeId: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IChatMessage {
|
export interface IChatMessage {
|
||||||
msgId: string;
|
msgId: string;
|
||||||
|
@ -15,10 +15,14 @@ const getRandomCount = () => {
|
|||||||
return (seed % 300) + 500;
|
return (seed % 300) + 500;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCommonShareMessage = (useCapture: boolean = true, inviteCode?: string): ShareAppMessageReturn => {
|
export const getCommonShareMessage = (
|
||||||
|
useCapture: boolean = true,
|
||||||
|
inviteCode?: string,
|
||||||
|
title?: string
|
||||||
|
): ShareAppMessageReturn => {
|
||||||
console.log('share share message', getJumpUrl(PageUrl.Job, inviteCode ? { c: inviteCode } : undefined));
|
console.log('share share message', getJumpUrl(PageUrl.Job, inviteCode ? { c: inviteCode } : undefined));
|
||||||
return {
|
return {
|
||||||
title: `昨天新增了${getRandomCount()}条主播通告,宝子快来看看`,
|
title: title || `昨天新增了${getRandomCount()}条主播通告,宝子快来看看`,
|
||||||
path: getJumpUrl(PageUrl.Job, inviteCode ? { c: inviteCode } : undefined),
|
path: getJumpUrl(PageUrl.Job, inviteCode ? { c: inviteCode } : undefined),
|
||||||
imageUrl: useCapture ? undefined : imageUrl,
|
imageUrl: useCapture ? undefined : imageUrl,
|
||||||
};
|
};
|
||||||
|
@ -148,3 +148,23 @@ export async function followGroup(blGroupId: FollowGroupRequest['blGroupId']) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getAgreementSigned = (): boolean | '' => Taro.getStorageSync(CacheKey.AGREEMENT_SIGNED);
|
||||||
|
export const setAgreementSigned = (signed: boolean) => Taro.setStorageSync(CacheKey.AGREEMENT_SIGNED, signed);
|
||||||
|
export const getCityCodes = (): string[] => {
|
||||||
|
const cachedValue = Taro.getStorageSync(CacheKey.CITY_CODES);
|
||||||
|
return !cachedValue || !Array.isArray(cachedValue) ? [] : cachedValue;
|
||||||
|
};
|
||||||
|
export const setCityCodes = (cityCode: string[]) => Taro.setStorageSync(CacheKey.CITY_CODES, cityCode);
|
||||||
|
export const checkCityCode = (cityCode: string): boolean => {
|
||||||
|
const cachedCityCodes = getCityCodes();
|
||||||
|
const isNewCityCode = cachedCityCodes.indexOf(cityCode) === -1;
|
||||||
|
if (cachedCityCodes.length === 2 && isNewCityCode) {
|
||||||
|
Toast.info('最多只能进入2个城市');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isNewCityCode) {
|
||||||
|
setCityCodes([...cachedCityCodes, cityCode]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user