diff --git a/src/pages/user-batch-publish/index.tsx b/src/pages/user-batch-publish/index.tsx
index 4d15a67..999b966 100644
--- a/src/pages/user-batch-publish/index.tsx
+++ b/src/pages/user-batch-publish/index.tsx
@@ -1,27 +1,30 @@
import { Image } from '@tarojs/components';
-import Taro, { useShareAppMessage } from '@tarojs/taro';
+import Taro, { useLoad, useShareAppMessage } from '@tarojs/taro';
import { Button, Tabs } from '@taroify/core';
-import { useCallback } from 'react';
+import { useCallback, useState } from 'react';
import HomePage from '@/components/home-page';
import SearchCity from '@/components/search-city';
-import { PageUrl } from '@/constants/app';
+import { PageType, PageUrl, RoleType } from '@/constants/app';
import { GROUPS } from '@/constants/group';
import useInviteCode from '@/hooks/use-invite-code';
+import { switchRoleType } from '@/utils/app';
import { openCustomerServiceChat } from '@/utils/common';
import { getCurrentCityCode } from '@/utils/location';
-import { navigateTo } from '@/utils/route';
+import { getPageQuery, navigateTo } from '@/utils/route';
import { getCommonShareMessage } from '@/utils/share';
import { checkCityCode } from '@/utils/user';
import './index.less';
+import { SortType } from '@/constants/job';
const PREFIX = 'page-biz-service';
const EXAMPLE_IMAGE = 'https://publiccdn.neighbourhood.com.cn/img/delegate-example.png';
const COMMENT_IMAGE = 'https://publiccdn.neighbourhood.com.cn/img/delegate-comments.png';
export default function BizService() {
const inviteCode = useInviteCode();
+ const [value, setValue] = useState('0');
const handleClickDelegate = useCallback(() => {
navigateTo(PageUrl.GroupDelegatePublish);
@@ -44,13 +47,33 @@ export default function BizService() {
openCustomerServiceChat(group.serviceUrl);
}
}, []);
- useShareAppMessage(() => getCommonShareMessage({ inviteCode }));
+ const handleChange = useCallback(v => {
+ setValue(v);
+ }, []);
+
+ useLoad(() => {
+ switchRoleType(RoleType.Company);
+
+ const query = getPageQuery<{ tab?: string }>();
+ if (query.tab) {
+ handleChange(query.tab);
+ }
+ });
+
+ useShareAppMessage(() =>
+ getCommonShareMessage({
+ inviteCode,
+ path: PageUrl.UserBatchPublish,
+ title: '邀请你加入本地主播求职招聘群',
+ params: { tab: '1' },
+ })
+ );
return (
-
+
-
-
+
+
免费招
@@ -96,7 +119,7 @@ export default function BizService() {
banner="点击城市名称,进本地通告群,免费招主播"
/>
-
+
服务城市
diff --git a/src/pages/user/index.tsx b/src/pages/user/index.tsx
index 6c0168d..1010f1e 100644
--- a/src/pages/user/index.tsx
+++ b/src/pages/user/index.tsx
@@ -9,7 +9,7 @@ import LoginButton from '@/components/login-button';
import PartnerEntry from '@/components/partner-entry';
import Slogan from '@/components/slogan';
import SwitchBar from '@/components/switch-bar';
-import { RoleType, PageUrl } from '@/constants/app';
+import { RoleType, PageUrl, PageType } from '@/constants/app';
import AnchorFragment from '@/fragments/user/anchor';
import CompanyFragment from '@/fragments/user/company';
import useUserInfo from '@/hooks/use-user-info';
@@ -41,7 +41,7 @@ export default function User() {
useShareAppMessage(() => getCommonShareMessage({ useCapture: false }));
return (
-
+
diff --git a/src/utils/app.ts b/src/utils/app.ts
index 8248677..7d24da7 100644
--- a/src/utils/app.ts
+++ b/src/utils/app.ts
@@ -37,12 +37,19 @@ export const switchDefaultTab = async () => {
};
export const switchRoleType = async (appMode?: RoleType) => {
+ const curMode = getRoleType();
+
+ if (curMode && appMode === curMode) {
+ console.log('[utils:app] skip switch role because of role type is equal to that of local');
+ return;
+ }
+
if (!appMode) {
- const curMode = getRoleType();
+ console.log('[utils:app] no app mode from arguments');
appMode = curMode === RoleType.Anchor ? RoleType.Company : RoleType.Anchor;
}
- console.log('switchRoleType', appMode);
+ console.log('[utils:app] switchRoleType', appMode);
try {
await postSwitchRoleType(appMode);
store.dispatch(changeRoleType(appMode));
diff --git a/src/utils/common.ts b/src/utils/common.ts
index ce0f35d..499f237 100644
--- a/src/utils/common.ts
+++ b/src/utils/common.ts
@@ -4,12 +4,12 @@ export const isDev = () => process.env.NODE_ENV === 'development';
// export const isDev = () => true;
export const isIPhone = (() => {
- const info = Taro.getSystemInfoSync();
+ const info = Taro.getDeviceInfo();
return info.platform === 'ios';
})();
export const isDesktop = (() => {
- const info = Taro.getSystemInfoSync();
+ const info = Taro.getDeviceInfo();
return info.platform === 'windows' || info.platform === 'mac';
})();
diff --git a/src/utils/message.ts b/src/utils/message.ts
index cb82ee2..a3f48cd 100644
--- a/src/utils/message.ts
+++ b/src/utils/message.ts
@@ -101,6 +101,7 @@ export const postAddMessageTimes = async (source: string) => {
await postSubscribe(MessageSubscribeIds, successIds);
};
+
export const postCreateChat = (toUserId: string) => {
return http.post(API.MESSAGE_CREATE_CHAT, { data: { toUserId } });
};
diff --git a/src/utils/subscribe.ts b/src/utils/subscribe.ts
index df29d17..bbb258f 100644
--- a/src/utils/subscribe.ts
+++ b/src/utils/subscribe.ts
@@ -7,24 +7,35 @@ import { logWithPrefix } from '@/utils/common';
const log = logWithPrefix('subscribe-utils');
-export const isSubscribeRefused = async (tempId: SubscribeTempId | SubscribeTempId[]) => {
+export const isSubscribeRefused = async (
+ tempId: SubscribeTempId | SubscribeTempId[]
+): Promise<[boolean, SubscribeTempId[]]> => {
tempId = Array.isArray(tempId) ? tempId : [tempId];
const { subscriptionsSetting } = await Taro.getSetting({ withSubscriptions: true });
log('isSubscribeRefuse subscriptionsSetting:', subscriptionsSetting);
if (!subscriptionsSetting) {
- return false;
+ return [false, []];
}
const { mainSwitch, itemSettings = {} } = subscriptionsSetting;
if (!mainSwitch) {
- return true;
+ return [true, []];
}
- return tempId.some(id => {
+ const acceptedIds: SubscribeTempId[] = [];
+ let refused = false;
+ tempId.some(id => {
const item = itemSettings[id];
- if (!item) {
- return false;
+ if (item === 'accept') {
+ acceptedIds.push(id);
}
- return item === 'reject';
+
+ if (refused) {
+ return;
+ }
+
+ refused = item === 'reject';
});
+
+ return [refused || false, acceptedIds];
};
export const subscribeMessage = async (tempIds: SubscribeTempId[]) => {