feat: update
This commit is contained in:
parent
ed99c7b1ae
commit
451add0e7d
@ -7,16 +7,16 @@ import { REFRESH_UNREAD_COUNT_TIME } from '@/constants/message';
|
|||||||
import http from '@/http';
|
import http from '@/http';
|
||||||
import store from '@/store';
|
import store from '@/store';
|
||||||
import { requestUnreadMessageCount } from '@/utils/message';
|
import { requestUnreadMessageCount } from '@/utils/message';
|
||||||
import { getInviteCode } from '@/utils/partner';
|
import { getInviteCode, getInviteCodeFromQuery } from '@/utils/partner';
|
||||||
import qiniuUpload from '@/utils/qiniu-upload';
|
import qiniuUpload from '@/utils/qiniu-upload';
|
||||||
import { requestUserInfo, updateLastLoginTime } from '@/utils/user';
|
import { requestUserInfo, updateLastLoginTime } from '@/utils/user';
|
||||||
|
|
||||||
import './app.less';
|
import './app.less';
|
||||||
|
|
||||||
function App({ children }: PropsWithChildren<BL.Anything>) {
|
function App({ children }: PropsWithChildren<BL.Anything>) {
|
||||||
useLaunch(async () => {
|
useLaunch(async ({ query }) => {
|
||||||
console.log('App launched.');
|
console.log('App launched.');
|
||||||
await http.init();
|
await http.init(getInviteCodeFromQuery(query));
|
||||||
requestUserInfo().then(userInfo => {
|
requestUserInfo().then(userInfo => {
|
||||||
if (userInfo.isPartner) {
|
if (userInfo.isPartner) {
|
||||||
getInviteCode();
|
getInviteCode();
|
||||||
|
@ -61,6 +61,10 @@
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
|
|
||||||
|
&.grey {
|
||||||
|
color: @blColorG2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
|
@ -142,12 +142,18 @@ export default function PartnerIntro() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={`${PREFIX}__block`}>
|
<div className={`${PREFIX}__block`}>
|
||||||
<div className={`${PREFIX}__title`}>群主特别通道</div>
|
<div className={`${PREFIX}__title`}>分享方法</div>
|
||||||
|
<div className={`${PREFIX}__card`}>
|
||||||
|
<div className={`${PREFIX}__body`}>分享小程序任意页面到群、朋友圈、好友即可</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={`${PREFIX}__block`}>
|
||||||
|
<div className={`${PREFIX}__title`}>合伙人交流群</div>
|
||||||
<div className={`${PREFIX}__card ${PREFIX}__special`}>
|
<div className={`${PREFIX}__card ${PREFIX}__special`}>
|
||||||
<div className={`${PREFIX}__body`}>如果您是主播群群主,请务必添加播络小伙计</div>
|
<div className={`${PREFIX}__h1`}>加入播络合伙人交流群</div>
|
||||||
<div className={`${PREFIX}__body`}>我们会为您提供专属服务,让您的收益最大化</div>
|
<div className={`${PREFIX}__body grey`}>学习分享邀请经验,一起赚钱</div>
|
||||||
<Button className={`${PREFIX}__service`} onClick={handleOpenService}>
|
<Button className={`${PREFIX}__service`} onClick={handleOpenService}>
|
||||||
点击添加播络伙计
|
点击加入
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className={`${PREFIX}__tip`}>注:收益不设时限,可重复享有,播络保留活动最终解释权</div>
|
<div className={`${PREFIX}__tip`}>注:收益不设时限,可重复享有,播络保留活动最终解释权</div>
|
||||||
|
@ -41,14 +41,18 @@
|
|||||||
height: 131px;
|
height: 131px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
padding: 24px 32px;
|
padding: 24px 32px 0 32px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
|
|
||||||
|
&-border {
|
||||||
|
border-bottom: 1px solid #e6e7e8;
|
||||||
|
}
|
||||||
|
|
||||||
&-content {
|
&-content {
|
||||||
.flex-row();
|
.flex-row();
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-bottom: 1px solid #e6e7e8;
|
padding-bottom: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-time-id {
|
&-time-id {
|
||||||
|
@ -12,6 +12,8 @@ import './index.less';
|
|||||||
const PREFIX = 'partner-invite-list';
|
const PREFIX = 'partner-invite-list';
|
||||||
const log = logWithPrefix(PREFIX);
|
const log = logWithPrefix(PREFIX);
|
||||||
|
|
||||||
|
const FIRST_PAGE = 0;
|
||||||
|
|
||||||
function PartnerList(props: {
|
function PartnerList(props: {
|
||||||
refreshDisabled?: boolean;
|
refreshDisabled?: boolean;
|
||||||
visible?: boolean;
|
visible?: boolean;
|
||||||
@ -20,10 +22,12 @@ function PartnerList(props: {
|
|||||||
onListEmpty?: () => void;
|
onListEmpty?: () => void;
|
||||||
}) {
|
}) {
|
||||||
const { className, listHeight, refreshDisabled, visible = true, onListEmpty } = props;
|
const { className, listHeight, refreshDisabled, visible = true, onListEmpty } = props;
|
||||||
|
const [hasMore, setHasMore] = useState(true);
|
||||||
const [refreshing, setRefreshing] = useState(false);
|
const [refreshing, setRefreshing] = useState(false);
|
||||||
const [loadingMore, setLoadingMore] = useState(false);
|
const [loadingMore, setLoadingMore] = useState(false);
|
||||||
const [loadMoreError, setLoadMoreError] = useState(false);
|
const [loadMoreError, setLoadMoreError] = useState(false);
|
||||||
const [dataList, setDataList] = useState<InviteUserInfo[]>([]);
|
const [dataList, setDataList] = useState<InviteUserInfo[]>([]);
|
||||||
|
const currentPage = useRef<number>(FIRST_PAGE);
|
||||||
const onListEmptyRef = useRef(onListEmpty);
|
const onListEmptyRef = useRef(onListEmpty);
|
||||||
|
|
||||||
const handleRefresh = useCallback(async () => {
|
const handleRefresh = useCallback(async () => {
|
||||||
@ -31,19 +35,44 @@ function PartnerList(props: {
|
|||||||
try {
|
try {
|
||||||
setRefreshing(true);
|
setRefreshing(true);
|
||||||
setLoadMoreError(false);
|
setLoadMoreError(false);
|
||||||
const list = await requestData();
|
const { content, totalPages } = await requestData({ page: 1 });
|
||||||
setDataList(list);
|
setDataList(content);
|
||||||
!list.length && onListEmptyRef.current?.();
|
currentPage.current = 1;
|
||||||
|
setHasMore(currentPage.current < totalPages);
|
||||||
|
!content.length && onListEmptyRef.current?.();
|
||||||
log('pull refresh success');
|
log('pull refresh success');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setDataList([]);
|
setDataList([]);
|
||||||
|
setHasMore(false);
|
||||||
setLoadMoreError(true);
|
setLoadMoreError(true);
|
||||||
|
currentPage.current = FIRST_PAGE;
|
||||||
log('pull refresh failed');
|
log('pull refresh failed');
|
||||||
} finally {
|
} finally {
|
||||||
setRefreshing(false);
|
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(() => {
|
useEffect(() => {
|
||||||
onListEmptyRef.current = onListEmpty;
|
onListEmptyRef.current = onListEmpty;
|
||||||
}, [onListEmpty]);
|
}, [onListEmpty]);
|
||||||
@ -62,11 +91,14 @@ function PartnerList(props: {
|
|||||||
setDataList([]);
|
setDataList([]);
|
||||||
setLoadingMore(true);
|
setLoadingMore(true);
|
||||||
setLoadMoreError(false);
|
setLoadMoreError(false);
|
||||||
const list = await requestData();
|
const { totalPages, content } = await requestData({ page: 1 });
|
||||||
setDataList(list);
|
setDataList(content);
|
||||||
!list.length && onListEmptyRef.current?.();
|
currentPage.current = 1;
|
||||||
|
setHasMore(currentPage.current < totalPages);
|
||||||
|
!content.length && onListEmptyRef.current?.();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setDataList([]);
|
setDataList([]);
|
||||||
|
setHasMore(false);
|
||||||
setLoadMoreError(true);
|
setLoadMoreError(true);
|
||||||
} finally {
|
} finally {
|
||||||
log('visible changed, refresh list data end');
|
log('visible changed, refresh list data end');
|
||||||
@ -90,8 +122,8 @@ function PartnerList(props: {
|
|||||||
disabled={refreshDisabled}
|
disabled={refreshDisabled}
|
||||||
>
|
>
|
||||||
<List
|
<List
|
||||||
hasMore={false}
|
hasMore={hasMore}
|
||||||
onLoad={() => {}}
|
onLoad={handleLoadMore}
|
||||||
loading={loadingMore || refreshing}
|
loading={loadingMore || refreshing}
|
||||||
disabled={loadMoreError}
|
disabled={loadMoreError}
|
||||||
fixedHeight={typeof listHeight !== 'undefined'}
|
fixedHeight={typeof listHeight !== 'undefined'}
|
||||||
@ -99,6 +131,7 @@ function PartnerList(props: {
|
|||||||
>
|
>
|
||||||
{dataList.map(item => (
|
{dataList.map(item => (
|
||||||
<div className={`${PREFIX}__item`} key={item.id || item.userId}>
|
<div className={`${PREFIX}__item`} key={item.id || item.userId}>
|
||||||
|
<div className={`${PREFIX}__item-border`}>
|
||||||
<div className={`${PREFIX}__item-content`}>
|
<div className={`${PREFIX}__item-content`}>
|
||||||
<div className={`${PREFIX}__item-time-id`}>
|
<div className={`${PREFIX}__item-time-id`}>
|
||||||
<div className={`${PREFIX}__item-time`}>{formatTimestamp(item.created)}</div>
|
<div className={`${PREFIX}__item-time`}>{formatTimestamp(item.created)}</div>
|
||||||
@ -108,6 +141,7 @@ function PartnerList(props: {
|
|||||||
<div className={`${PREFIX}__item-joined`}>{item.isPartner ? '已加入' : '未加入'}</div>
|
<div className={`${PREFIX}__item-joined`}>{item.isPartner ? '已加入' : '未加入'}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
))}
|
))}
|
||||||
<ListPlaceholder hasMore={false} loadingMore={loadingMore} loadMoreError={loadMoreError} />
|
<ListPlaceholder hasMore={false} loadingMore={loadingMore} loadMoreError={loadMoreError} />
|
||||||
</List>
|
</List>
|
||||||
|
@ -96,7 +96,7 @@ function ProfitList(props: IPartnerProfitListProps) {
|
|||||||
style={listHeight ? { height: `${listHeight}px` } : undefined}
|
style={listHeight ? { height: `${listHeight}px` } : undefined}
|
||||||
>
|
>
|
||||||
{dataList.map(item => {
|
{dataList.map(item => {
|
||||||
const isChat = type === ProfitType.CHAT_SHARE || item.earnType.toString().toLowerCase().indexOf('chat');
|
const isChat = type === ProfitType.CHAT_SHARE || item.earnType.toString().toLowerCase().indexOf('chat') > -1;
|
||||||
return (
|
return (
|
||||||
<div className={`${PREFIX}__row`} key={item.id}>
|
<div className={`${PREFIX}__row`} key={item.id}>
|
||||||
<div className={`${PREFIX}__row-content`}>
|
<div className={`${PREFIX}__row-content`}>
|
||||||
|
@ -28,6 +28,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__help-icon {
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
margin-left: 2px;
|
||||||
|
position: relative;
|
||||||
|
top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
height: 72px;
|
height: 72px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
import { Image } from '@tarojs/components';
|
||||||
|
|
||||||
import { Tabs } from '@taroify/core';
|
import { Tabs } from '@taroify/core';
|
||||||
|
|
||||||
import PartnerKanban from '@/components/partner-kanban';
|
import PartnerKanban from '@/components/partner-kanban';
|
||||||
import { ProfitType } from '@/types/partner';
|
import { ProfitType } from '@/types/partner';
|
||||||
|
import Toast from '@/utils/toast';
|
||||||
|
|
||||||
import ProfitList from './ProfitList';
|
import ProfitList from './ProfitList';
|
||||||
|
|
||||||
@ -21,22 +24,64 @@ function TableTitle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function PartnerProfit() {
|
export default function PartnerProfit() {
|
||||||
|
const handleClickHelpChat = () => {
|
||||||
|
Toast.info('主播被开聊14天后会显示收益');
|
||||||
|
};
|
||||||
|
const handleClickHelpPay = () => {
|
||||||
|
Toast.info('会员支付15日后结算收益');
|
||||||
|
};
|
||||||
|
const handleClickHelpInvite = () => {
|
||||||
|
Toast.info('所邀合伙人获得收益后自动获得收益');
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div className={PREFIX}>
|
<div className={PREFIX}>
|
||||||
<div className={`${PREFIX}__top`}>
|
<div className={`${PREFIX}__top`}>
|
||||||
<PartnerKanban />
|
<PartnerKanban />
|
||||||
</div>
|
</div>
|
||||||
<div className={`${PREFIX}__main`}>
|
<div className={`${PREFIX}__main`}>
|
||||||
<Tabs className={`${PREFIX}__tabs`}>
|
<Tabs className={`${PREFIX}__tabs`} ellipsis={false}>
|
||||||
<Tabs.TabPane title="推荐主播收益">
|
<Tabs.TabPane
|
||||||
|
title={
|
||||||
|
<>
|
||||||
|
推荐主播收益
|
||||||
|
<Image
|
||||||
|
className={`${PREFIX}__help-icon`}
|
||||||
|
src={require('@/statics/svg/help.svg')}
|
||||||
|
onClick={handleClickHelpChat}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
<TableTitle />
|
<TableTitle />
|
||||||
<ProfitList type={ProfitType.CHAT_SHARE} />
|
<ProfitList type={ProfitType.CHAT_SHARE} />
|
||||||
</Tabs.TabPane>
|
</Tabs.TabPane>
|
||||||
<Tabs.TabPane title="推荐会员权益">
|
<Tabs.TabPane
|
||||||
|
title={
|
||||||
|
<>
|
||||||
|
推荐会员权益
|
||||||
|
<Image
|
||||||
|
className={`${PREFIX}__help-icon`}
|
||||||
|
src={require('@/statics/svg/help.svg')}
|
||||||
|
onClick={handleClickHelpPay}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
<TableTitle />
|
<TableTitle />
|
||||||
<ProfitList type={ProfitType.PAYMENT_SHARE} />
|
<ProfitList type={ProfitType.PAYMENT_SHARE} />
|
||||||
</Tabs.TabPane>
|
</Tabs.TabPane>
|
||||||
<Tabs.TabPane title="推荐合伙人收益">
|
<Tabs.TabPane
|
||||||
|
title={
|
||||||
|
<>
|
||||||
|
推荐合伙人收益
|
||||||
|
<Image
|
||||||
|
className={`${PREFIX}__help-icon`}
|
||||||
|
src={require('@/statics/svg/help.svg')}
|
||||||
|
onClick={handleClickHelpInvite}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
<TableTitle />
|
<TableTitle />
|
||||||
<ProfitList type={ProfitType.INDIRECT_MEMBER_REFERRAL} />
|
<ProfitList type={ProfitType.INDIRECT_MEMBER_REFERRAL} />
|
||||||
</Tabs.TabPane>
|
</Tabs.TabPane>
|
||||||
|
@ -2,53 +2,53 @@ export enum ProfitStatus {
|
|||||||
/**
|
/**
|
||||||
* 待处理/待计算 (例如,等待上游数据或条件满足)
|
* 待处理/待计算 (例如,等待上游数据或条件满足)
|
||||||
*/
|
*/
|
||||||
PENDING_CALCULATION = 0,
|
PENDING_CALCULATION = 'PENDING_CALCULATION',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 待直接结算/待直接分账 (例如,T+7 到账)
|
* 待直接结算/待直接分账 (例如,T+7 到账)
|
||||||
* 这种类型的佣金会计入银行账户,而非平台余额
|
* 这种类型的佣金会计入银行账户,而非平台余额
|
||||||
*/
|
*/
|
||||||
DIRECT_SETTLEMENT_PENDING = 1,
|
DIRECT_SETTLEMENT_PENDING = 'DIRECT_SETTLEMENT_PENDING',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直接结算已完成/直接分账已完成
|
* 直接结算已完成/直接分账已完成
|
||||||
*/
|
*/
|
||||||
DIRECT_SETTLEMENT_PROCESSING = 2,
|
DIRECT_SETTLEMENT_PROCESSING = 'DIRECT_SETTLEMENT_PROCESSING',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 间接收益已结算到合伙人余额 (例如,主播推荐奖金进入可提现余额)
|
* 间接收益已结算到合伙人余额 (例如,主播推荐奖金进入可提现余额)
|
||||||
*/
|
*/
|
||||||
INDIRECT_SETTLED_TO_BALANCE = 3,
|
INDIRECT_SETTLED_TO_BALANCE = 'INDIRECT_SETTLED_TO_BALANCE',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 佣金已取消 (例如,订单退款,不满足条件等)
|
* 佣金已取消 (例如,订单退款,不满足条件等)
|
||||||
*/
|
*/
|
||||||
CANCELLED = 4,
|
CANCELLED = 'CANCELLED',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 佣金处理失败
|
* 佣金处理失败
|
||||||
*/
|
*/
|
||||||
FAILED = 5,
|
FAILED = 'FAILED',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 其他状态
|
* 其他状态
|
||||||
*/
|
*/
|
||||||
OTHER = 6,
|
OTHER = 'OTHER',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 已完成
|
* 已完成
|
||||||
*/
|
*/
|
||||||
FINISHED = 7,
|
FINISHED = 'FINISHED',
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果需要为每个枚举值添加描述,可以使用一个单独的映射对象
|
// 如果需要为每个枚举值添加描述,可以使用一个单独的映射对象
|
||||||
export const ProfitStatusDescriptions: { [key in ProfitStatus]: string } = {
|
export const ProfitStatusDescriptions = {
|
||||||
[ProfitStatus.PENDING_CALCULATION]: '',
|
PENDING_CALCULATION: '',
|
||||||
[ProfitStatus.DIRECT_SETTLEMENT_PENDING]: '待分账',
|
DIRECT_SETTLEMENT_PENDING: '待分账',
|
||||||
[ProfitStatus.DIRECT_SETTLEMENT_PROCESSING]: '',
|
DIRECT_SETTLEMENT_PROCESSING: '',
|
||||||
[ProfitStatus.INDIRECT_SETTLED_TO_BALANCE]: '',
|
INDIRECT_SETTLED_TO_BALANCE: '',
|
||||||
[ProfitStatus.CANCELLED]: '',
|
CANCELLED: '',
|
||||||
[ProfitStatus.FAILED]: '',
|
FAILED: '',
|
||||||
[ProfitStatus.OTHER]: '',
|
OTHER: '',
|
||||||
[ProfitStatus.FINISHED]: '已分账',
|
FINISHED: '已分账',
|
||||||
};
|
};
|
||||||
|
@ -107,14 +107,14 @@ class Http {
|
|||||||
url: BASE_URL + url,
|
url: BASE_URL + url,
|
||||||
data,
|
data,
|
||||||
method: method,
|
method: method,
|
||||||
header: { 'content-type': contentType /*, 'user-Id': '588002047871053824' */ },
|
header: { 'content-type': contentType /*'user-Id': '588002047871053824' */ },
|
||||||
};
|
};
|
||||||
return this.request(option);
|
return this.request(option);
|
||||||
};
|
};
|
||||||
|
|
||||||
async init() {
|
async init(inviteCode?: string) {
|
||||||
if (isTokenExpired()) {
|
if (isTokenExpired()) {
|
||||||
await refreshToken();
|
await refreshToken(inviteCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
|
|
||||||
import { getRoleType } from '@/utils/app';
|
import { getRoleTypeWithDefault } from '@/utils/app';
|
||||||
import { isDev } from '@/utils/common';
|
import { isDev } from '@/utils/common';
|
||||||
|
|
||||||
import { getToken } from './utils';
|
import { getToken } from './utils';
|
||||||
@ -20,7 +20,7 @@ const tokenInterceptor: Taro.interceptor = (chain: Taro.Chain) => {
|
|||||||
|
|
||||||
const roleInterceptor: Taro.interceptor = (chain: Taro.Chain) => {
|
const roleInterceptor: Taro.interceptor = (chain: Taro.Chain) => {
|
||||||
const requestParams = chain.requestParams;
|
const requestParams = chain.requestParams;
|
||||||
const roleType = getRoleType();
|
const roleType = getRoleTypeWithDefault();
|
||||||
requestParams.header = {
|
requestParams.header = {
|
||||||
...requestParams.header,
|
...requestParams.header,
|
||||||
'role-type': roleType,
|
'role-type': roleType,
|
||||||
|
@ -24,10 +24,10 @@ const clearToken = () => {
|
|||||||
Taro.setStorageSync(TOKEN_EXPIRES_TIME, 0);
|
Taro.setStorageSync(TOKEN_EXPIRES_TIME, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
const requestToken = (): Promise<string> => {
|
const requestToken = (inviteCode?: string): Promise<string> => {
|
||||||
return getCode()
|
return getCode()
|
||||||
.then(code => {
|
.then(code => {
|
||||||
return http.post<LoginResponse>(API.LOGIN, { data: { code } }).then(data => {
|
return http.post<LoginResponse>(API.LOGIN, { data: { code, inviteCode } }).then(data => {
|
||||||
const newToken = data?.token || '';
|
const newToken = data?.token || '';
|
||||||
const expires = data?.expires || 0;
|
const expires = data?.expires || 0;
|
||||||
if (newToken) {
|
if (newToken) {
|
||||||
@ -47,12 +47,12 @@ const requestToken = (): Promise<string> => {
|
|||||||
|
|
||||||
export const isTokenExpired = () => (Taro.getStorageSync(TOKEN_EXPIRES_TIME) || 0) < Date.now();
|
export const isTokenExpired = () => (Taro.getStorageSync(TOKEN_EXPIRES_TIME) || 0) < Date.now();
|
||||||
|
|
||||||
export const refreshToken = () => {
|
export const refreshToken = (inviteCode?: string) => {
|
||||||
if (_fetchTokenPromise) {
|
if (_fetchTokenPromise) {
|
||||||
return _fetchTokenPromise;
|
return _fetchTokenPromise;
|
||||||
}
|
}
|
||||||
clearToken();
|
clearToken();
|
||||||
_fetchTokenPromise = requestToken();
|
_fetchTokenPromise = requestToken(inviteCode);
|
||||||
return _fetchTokenPromise;
|
return _fetchTokenPromise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,8 +27,7 @@ import { logWithPrefix } from '@/utils/common';
|
|||||||
import { getLastSelectMyJobId, requestJobManageList, setLastSelectMyJobId } from '@/utils/job';
|
import { getLastSelectMyJobId, requestJobManageList, setLastSelectMyJobId } from '@/utils/job';
|
||||||
import { getWxLocation } from '@/utils/location';
|
import { getWxLocation } from '@/utils/location';
|
||||||
import { requestUnreadMessageCount } from '@/utils/message';
|
import { requestUnreadMessageCount } from '@/utils/message';
|
||||||
import { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
import { navigateTo } from '@/utils/route';
|
||||||
import { getPageQuery, navigateTo } from '@/utils/route';
|
|
||||||
import { getCommonShareMessage } from '@/utils/share';
|
import { getCommonShareMessage } from '@/utils/share';
|
||||||
import Toast from '@/utils/toast';
|
import Toast from '@/utils/toast';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
@ -165,9 +164,6 @@ export default function AnchorPage() {
|
|||||||
}, [location]);
|
}, [location]);
|
||||||
|
|
||||||
useLoad(async () => {
|
useLoad(async () => {
|
||||||
const query = getPageQuery();
|
|
||||||
getInviteCodeFromQueryAndUpdate(query);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { jobResults = [] } = await requestJobManageList({ status: JobManageStatus.Open });
|
const { jobResults = [] } = await requestJobManageList({ status: JobManageStatus.Open });
|
||||||
if (!jobResults.length) {
|
if (!jobResults.length) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useLoad, useShareAppMessage } from '@tarojs/taro';
|
import { useShareAppMessage } from '@tarojs/taro';
|
||||||
|
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
@ -8,8 +8,6 @@ import { GROUPS } from '@/constants/group';
|
|||||||
import useInviteCode from '@/hooks/use-invite-code';
|
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 { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
|
||||||
import { getPageQuery } from '@/utils/route';
|
|
||||||
import { getCommonShareMessage } from '@/utils/share';
|
import { getCommonShareMessage } from '@/utils/share';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
@ -18,11 +16,6 @@ const PREFIX = 'group-v2-page';
|
|||||||
export default function GroupV2() {
|
export default function GroupV2() {
|
||||||
const inviteCode = useInviteCode();
|
const inviteCode = useInviteCode();
|
||||||
|
|
||||||
useLoad(() => {
|
|
||||||
const query = getPageQuery();
|
|
||||||
getInviteCodeFromQueryAndUpdate(query);
|
|
||||||
});
|
|
||||||
|
|
||||||
useShareAppMessage(() => getCommonShareMessage(true, inviteCode));
|
useShareAppMessage(() => getCommonShareMessage(true, inviteCode));
|
||||||
|
|
||||||
const handleSelectCity = useCallback(cityCode => {
|
const handleSelectCity = useCallback(cityCode => {
|
||||||
|
@ -28,7 +28,6 @@ import { getJobTitle, getJobSalary, postPublishJob, requestJobDetail } from '@/u
|
|||||||
import { calcDistance, isValidLocation } from '@/utils/location';
|
import { calcDistance, isValidLocation } from '@/utils/location';
|
||||||
import { requestProfileDetail } from '@/utils/material';
|
import { requestProfileDetail } from '@/utils/material';
|
||||||
import { isChatWithSelf, postCreateChat } from '@/utils/message';
|
import { isChatWithSelf, postCreateChat } from '@/utils/message';
|
||||||
import { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
|
||||||
import { getJumpUrl, getPageQuery, navigateTo } from '@/utils/route';
|
import { getJumpUrl, getPageQuery, navigateTo } from '@/utils/route';
|
||||||
import { getCommonShareMessage } from '@/utils/share';
|
import { getCommonShareMessage } from '@/utils/share';
|
||||||
import { formatDate } from '@/utils/time';
|
import { formatDate } from '@/utils/time';
|
||||||
@ -219,8 +218,7 @@ export default function JobDetail() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useLoad(async () => {
|
useLoad(async () => {
|
||||||
const query = getPageQuery<Pick<JobDetails, 'id'> & { c: string }>();
|
const query = getPageQuery<Pick<JobDetails, 'id'>>();
|
||||||
getInviteCodeFromQueryAndUpdate(query);
|
|
||||||
const jobId = query?.id;
|
const jobId = query?.id;
|
||||||
if (!jobId) {
|
if (!jobId) {
|
||||||
return;
|
return;
|
||||||
|
@ -17,7 +17,6 @@ import { Coordinate } from '@/types/location';
|
|||||||
import { logWithPrefix } from '@/utils/common';
|
import { logWithPrefix } from '@/utils/common';
|
||||||
import { getWxLocation, isNotNeedAuthorizeLocation, requestLocation } from '@/utils/location';
|
import { getWxLocation, isNotNeedAuthorizeLocation, requestLocation } from '@/utils/location';
|
||||||
import { requestUnreadMessageCount } from '@/utils/message';
|
import { requestUnreadMessageCount } from '@/utils/message';
|
||||||
import { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
|
||||||
import { getJumpUrl, getPageQuery, navigateTo } from '@/utils/route';
|
import { getJumpUrl, getPageQuery, navigateTo } from '@/utils/route';
|
||||||
import { getCommonShareMessage } from '@/utils/share';
|
import { getCommonShareMessage } from '@/utils/share';
|
||||||
import Toast from '@/utils/toast';
|
import Toast from '@/utils/toast';
|
||||||
@ -109,7 +108,6 @@ export default function Job() {
|
|||||||
if (type === SortType.CREATE_TIME) {
|
if (type === SortType.CREATE_TIME) {
|
||||||
setSortType(type);
|
setSortType(type);
|
||||||
}
|
}
|
||||||
getInviteCodeFromQueryAndUpdate(query);
|
|
||||||
if (await isNotNeedAuthorizeLocation()) {
|
if (await isNotNeedAuthorizeLocation()) {
|
||||||
log('not need authorize location');
|
log('not need authorize location');
|
||||||
requestLocation();
|
requestLocation();
|
||||||
|
@ -21,7 +21,6 @@ import { collectEvent } from '@/utils/event';
|
|||||||
import { requestHasPublishedJob, requestJobDetail } from '@/utils/job';
|
import { requestHasPublishedJob, requestJobDetail } from '@/utils/job';
|
||||||
import { getMaterialShareMessage, requestReadProfile, requestShareProfile } from '@/utils/material';
|
import { getMaterialShareMessage, requestReadProfile, requestShareProfile } from '@/utils/material';
|
||||||
import { isChatWithSelf, postCreateChat } from '@/utils/message';
|
import { isChatWithSelf, postCreateChat } from '@/utils/message';
|
||||||
import { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
|
||||||
import { getPageQuery, navigateBack, navigateTo, redirectTo } from '@/utils/route';
|
import { getPageQuery, navigateBack, navigateTo, redirectTo } from '@/utils/route';
|
||||||
import Toast from '@/utils/toast';
|
import Toast from '@/utils/toast';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
@ -142,7 +141,6 @@ export default function MaterialViewPage() {
|
|||||||
|
|
||||||
useLoad(async () => {
|
useLoad(async () => {
|
||||||
const context = getPageQuery<IViewContext | IShareContext>();
|
const context = getPageQuery<IViewContext | IShareContext>();
|
||||||
getInviteCodeFromQueryAndUpdate(context as BL.Anything);
|
|
||||||
try {
|
try {
|
||||||
const profileDetail = await requestProfile(context);
|
const profileDetail = await requestProfile(context);
|
||||||
setProfile(profileDetail);
|
setProfile(profileDetail);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { useShareAppMessage } from '@tarojs/taro';
|
import { useShareAppMessage } from '@tarojs/taro';
|
||||||
|
|
||||||
import { Button, Tabs } from '@taroify/core';
|
import { Button, Tabs } from '@taroify/core';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
@ -6,6 +7,7 @@ import HomePage from '@/components/home-page';
|
|||||||
import SearchCity from '@/components/search-city';
|
import SearchCity from '@/components/search-city';
|
||||||
import UserBatchPublish from '@/components/user-batch-publish';
|
import UserBatchPublish from '@/components/user-batch-publish';
|
||||||
import { GROUPS } from '@/constants/group';
|
import { GROUPS } from '@/constants/group';
|
||||||
|
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';
|
||||||
@ -14,6 +16,8 @@ import './index.less';
|
|||||||
const PREFIX = 'page-biz-service';
|
const PREFIX = 'page-biz-service';
|
||||||
|
|
||||||
export default function BizService() {
|
export default function BizService() {
|
||||||
|
const inviteCode = useInviteCode();
|
||||||
|
|
||||||
const handleOpenService = useCallback(() => {
|
const handleOpenService = useCallback(() => {
|
||||||
openCustomerServiceChat('https://work.weixin.qq.com/kfid/kfcd60708731367168d');
|
openCustomerServiceChat('https://work.weixin.qq.com/kfid/kfcd60708731367168d');
|
||||||
}, []);
|
}, []);
|
||||||
@ -23,7 +27,7 @@ export default function BizService() {
|
|||||||
openCustomerServiceChat(group.serviceUrl);
|
openCustomerServiceChat(group.serviceUrl);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
useShareAppMessage(() => getCommonShareMessage());
|
useShareAppMessage(() => getCommonShareMessage(true, inviteCode));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HomePage>
|
<HomePage>
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { RoleType, PageUrl } from '@/constants/app';
|
import { PageUrl, RoleType } from '@/constants/app';
|
||||||
import { CollectEventName } from '@/constants/event';
|
import { CollectEventName } from '@/constants/event';
|
||||||
import { ANCHOR_TAB_LIST, COMPANY_TAB_LIST } from '@/hooks/use-config';
|
import { ANCHOR_TAB_LIST, COMPANY_TAB_LIST } from '@/hooks/use-config';
|
||||||
import http from '@/http';
|
import http from '@/http';
|
||||||
import { API } from '@/http/api';
|
import { API } from '@/http/api';
|
||||||
import store from '@/store';
|
import store from '@/store';
|
||||||
import { changeRoleType, changeHomePage } from '@/store/actions';
|
import { changeHomePage, changeRoleType } from '@/store/actions';
|
||||||
import { selectRoleType } from '@/store/selector';
|
import { selectRoleType } from '@/store/selector';
|
||||||
import { sleep } from '@/utils/common';
|
import { sleep } from '@/utils/common';
|
||||||
import { collectEvent } from '@/utils/event';
|
import { collectEvent } from '@/utils/event';
|
||||||
@ -18,7 +18,9 @@ const postSwitchRoleType = (appMode: RoleType) => {
|
|||||||
|
|
||||||
export const getRoleType = () => selectRoleType(store.getState());
|
export const getRoleType = () => selectRoleType(store.getState());
|
||||||
|
|
||||||
export const isAnchorMode = () => getRoleType() === RoleType.Anchor;
|
export const getRoleTypeWithDefault = () => getRoleType() || RoleType.Anchor;
|
||||||
|
|
||||||
|
export const isAnchorMode = () => getRoleTypeWithDefault() === RoleType.Anchor;
|
||||||
|
|
||||||
export const isCompanyMode = () => getRoleType() === RoleType.Company;
|
export const isCompanyMode = () => getRoleType() === RoleType.Company;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import {
|
|||||||
IChatActionDetail,
|
IChatActionDetail,
|
||||||
ChatWatchRequest,
|
ChatWatchRequest,
|
||||||
} from '@/types/message';
|
} from '@/types/message';
|
||||||
import { getRoleType } from '@/utils/app';
|
import { getRoleTypeWithDefault } from '@/utils/app';
|
||||||
import { logWithPrefix, oncePromise } from '@/utils/common';
|
import { logWithPrefix, oncePromise } from '@/utils/common';
|
||||||
import { collectEvent } from '@/utils/event';
|
import { collectEvent } from '@/utils/event';
|
||||||
import { navigateTo } from '@/utils/route';
|
import { navigateTo } from '@/utils/route';
|
||||||
@ -60,12 +60,12 @@ export const requestMessageList = oncePromise(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const requestChatDetail = (chatId: string) => {
|
export const requestChatDetail = (chatId: string) => {
|
||||||
const data = { chatId, roleType: getRoleType() };
|
const data = { chatId, roleType: getRoleTypeWithDefault() };
|
||||||
return http.post<IChatInfo>(API.MESSAGE_CHAT, { data, contentType: 'application/x-www-form-urlencoded' });
|
return http.post<IChatInfo>(API.MESSAGE_CHAT, { data, contentType: 'application/x-www-form-urlencoded' });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const requestNewChatMessages = (params: GetNewChatMessagesRequest) => {
|
export const requestNewChatMessages = (params: GetNewChatMessagesRequest) => {
|
||||||
const data = { ...params, roleType: getRoleType() };
|
const data = { ...params, roleType: getRoleTypeWithDefault() };
|
||||||
return http.post<IChatMessage[]>(API.MESSAGE_CHAT_NEW, { data });
|
return http.post<IChatMessage[]>(API.MESSAGE_CHAT_NEW, { data });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import http from '@/http';
|
|||||||
import { API } from '@/http/api';
|
import { API } from '@/http/api';
|
||||||
import store from '@/store';
|
import store from '@/store';
|
||||||
import { setInviteCode } from '@/store/actions/partner';
|
import { setInviteCode } from '@/store/actions/partner';
|
||||||
|
import { IPaginationRequest } from '@/types/common';
|
||||||
import {
|
import {
|
||||||
GetProfitRequest,
|
GetProfitRequest,
|
||||||
InviteUserInfo,
|
InviteUserInfo,
|
||||||
@ -51,8 +52,11 @@ export const getPartnerQrcode = async () => {
|
|||||||
export const getPartnerProfitStat = async () => {
|
export const getPartnerProfitStat = async () => {
|
||||||
return await http.post<PartnerProfitsState>(API.GET_PROFIT_STAT);
|
return await http.post<PartnerProfitsState>(API.GET_PROFIT_STAT);
|
||||||
};
|
};
|
||||||
export const getPartnerInviteList = async () => {
|
export const getPartnerInviteList = async (data: IPaginationRequest) => {
|
||||||
return await http.post<InviteUserInfo[]>(API.GET_INVITE_LIST);
|
return await http.post<{ content: InviteUserInfo[]; totalPages: number }>(API.GET_INVITE_LIST, {
|
||||||
|
data,
|
||||||
|
contentType: 'application/x-www-form-urlencoded',
|
||||||
|
});
|
||||||
};
|
};
|
||||||
export const dispatchUpdateInviteCode = (code: string) => store.dispatch(setInviteCode(code));
|
export const dispatchUpdateInviteCode = (code: string) => store.dispatch(setInviteCode(code));
|
||||||
export const getInviteCode = async () => {
|
export const getInviteCode = async () => {
|
||||||
@ -77,7 +81,7 @@ export const formatMoney = (cents: number) => {
|
|||||||
};
|
};
|
||||||
export function formatTimestamp(timestamp: string): string {
|
export function formatTimestamp(timestamp: string): string {
|
||||||
// 创建 Date 对象
|
// 创建 Date 对象
|
||||||
const date = new Date(timestamp);
|
const date = new Date(/^\d+$/.test(timestamp) ? Number(timestamp) : timestamp);
|
||||||
|
|
||||||
// 获取年、月、日、时、分、秒
|
// 获取年、月、日、时、分、秒
|
||||||
const YYYY = date.getFullYear();
|
const YYYY = date.getFullYear();
|
||||||
|
Loading…
Reference in New Issue
Block a user