feat: login
This commit is contained in:
@ -1,63 +1,37 @@
|
||||
import { Image } from '@tarojs/components';
|
||||
import { NodesRef, useShareAppMessage } from '@tarojs/taro';
|
||||
import { useShareAppMessage } from '@tarojs/taro';
|
||||
|
||||
import { List } from '@taroify/core';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import HomePage from '@/components/home-page';
|
||||
import LoginButton from '@/components/login-button';
|
||||
import { APP_TAB_BAR_ID } from '@/constants/app';
|
||||
import SearchCity from '@/components/search-city';
|
||||
import { GROUPS } from '@/constants/group';
|
||||
import useListHeight, { IUseListHeightProps } from '@/hooks/use-list-height';
|
||||
import { GroupItem } from '@/types/group';
|
||||
import { openCustomerServiceChat } from '@/utils/common';
|
||||
import { getCurrentCityCode } from '@/utils/location';
|
||||
import { getCommonShareMessage } from '@/utils/share';
|
||||
|
||||
import './index.less';
|
||||
|
||||
const PREFIX = 'group-v2-page';
|
||||
const LIST_CONTAINER_CLASS = `${PREFIX}__list-container`;
|
||||
const CALC_LIST_PROPS: IUseListHeightProps = {
|
||||
selectors: [`.${LIST_CONTAINER_CLASS}`, `#${APP_TAB_BAR_ID}`],
|
||||
calc: (rects: [NodesRef.BoundingClientRectCallbackResult, NodesRef.BoundingClientRectCallbackResult]) => {
|
||||
const [rect, diffRect] = rects;
|
||||
return diffRect.top - rect.top;
|
||||
},
|
||||
};
|
||||
|
||||
export default function GroupV2() {
|
||||
const listHeight = useListHeight(CALC_LIST_PROPS);
|
||||
|
||||
const handleClick = useCallback((group: GroupItem) => openCustomerServiceChat(group.serviceUrl), []);
|
||||
const handleSelectCity = useCallback(cityCode => {
|
||||
const group = GROUPS.find(g => String(g.cityCode) === cityCode);
|
||||
if (group) {
|
||||
openCustomerServiceChat(group.serviceUrl);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useShareAppMessage(() => getCommonShareMessage());
|
||||
|
||||
return (
|
||||
<HomePage>
|
||||
<div className={PREFIX}>
|
||||
<div className={`${PREFIX}__header`}>
|
||||
<div className={`${PREFIX}__header__left-line`} />
|
||||
<div className={`${PREFIX}__header__title`}>进本地通告群,高薪通告早知道</div>
|
||||
<div className={`${PREFIX}__header__right-line`} />
|
||||
</div>
|
||||
<div className={LIST_CONTAINER_CLASS}>
|
||||
<List style={{ height: `${listHeight}px` }} disabled fixedHeight>
|
||||
{GROUPS.map(group => (
|
||||
<div className={`${PREFIX}__group-card`} key={group.serviceUrl}>
|
||||
<Image
|
||||
mode="aspectFit"
|
||||
className={`${PREFIX}__group-card__avatar`}
|
||||
src="https://neighbourhood.cn/addGroup.jpg"
|
||||
/>
|
||||
<div className={`${PREFIX}__group-card__title`}>{group.title}</div>
|
||||
<LoginButton className={`${PREFIX}__group-card__button`} onClick={() => handleClick(group)}>
|
||||
我要进群
|
||||
</LoginButton>
|
||||
</div>
|
||||
))}
|
||||
<div className={`${PREFIX}__bottom-padding`} />
|
||||
</List>
|
||||
</div>
|
||||
<SearchCity
|
||||
onSelectCity={handleSelectCity}
|
||||
currentCity={getCurrentCityCode()}
|
||||
forGroup
|
||||
offset={72}
|
||||
banner="点击城市加入本地通告群,高薪工作早知道"
|
||||
/>
|
||||
</div>
|
||||
</HomePage>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user