import type { ShareAppMessageReturn } from '@tarojs/taro'; import { PageUrl } from '@/constants/app'; import { getJumpUrl } from './route'; const imageUrl = 'https://neighbourhood.cn/share_d.jpg'; const getRandomCount = () => { const date = new Date(); const year = date.getFullYear(); const month = date.getMonth(); const day = date.getDate(); const seed = (year + month + day) * day; return (seed % 300) + 500; }; interface ShareAppProps { useCapture?: boolean; inviteCode?: string; title?: string; path?: PageUrl; imageUrl?: string; params?: Record; } export const getCommonShareMessage = ({ useCapture = true, inviteCode, title, path, imageUrl: _imageUrl, params = {}, }: ShareAppProps = {}): ShareAppMessageReturn => { const inviteParams = inviteCode ? { c: inviteCode } : undefined; const sharePath = path ? getJumpUrl(path, { ...params, ...inviteParams }) : getJumpUrl(PageUrl.Job, inviteParams); console.log('share share message', sharePath); return { title: title || `昨天新增了${getRandomCount()}条主播通告,宝子快来看看`, path: sharePath, imageUrl: useCapture ? undefined : _imageUrl || imageUrl, }; };