Merge branch 'trunk' of https://git.littlefat.tech/magic-csb/boluo-app-main into trunk
This commit is contained in:
commit
f9af84fb65
@ -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'}
|
||||||
|
@ -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);
|
||||||
|
@ -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 () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user