import { shareCircle, shareDesignerHome } from '@/core/libs/requests' import { messages } from '@/core/libs/messages' export const useShare = () => { const shareAppMessage = async ({ from, target }) => { console.log('target::::::::', from, target) const res: Page.CustomShareContent = {} if (from === 'button') { if (target.dataset.type === 'homepage') { if (target.dataset.level && target.dataset.level < 2) { uni.showToast({ title: '普通会员无法分享', icon: 'none' }) throw new Error('禁止分享') } await shareDesignerHome({ stylistId: target.dataset.options.homepageId, bizId: target.dataset.options.userId, }) res.title = target.dataset.shareContent.title res.imageUrl = target.dataset.shareContent.imageUrl res.path = target.dataset.shareContent.path } else { if (['1', '2'].includes(target.dataset.options.circleType)) { if (!target.dataset.options.levelId || target.dataset.options.levelId < 2) { uni.showToast({ title: '无法分享普通会员等级作者的圈子内容', icon: 'none' }).then() throw new Error('禁止分享') } await shareCircle(target.dataset.options.id) } res.path = `/pages-sub/home/moment/index?id=${target.dataset.options.id}&isShared=true&circleType=${target.dataset.options.circleType}` res.imageUrl = target.dataset.options.bannerUrls[0] res.title = `${target.dataset.options.stylistName}: ${target.dataset.options.circleType == '2' ? '设计案例-' + target.dataset.options.caseName : target.dataset.options.circleDesc}` } } if (from === 'menu') { console.log('menu::::::::', from, target) res.title = messages.home.shareTitle } return res } return { shareAppMessage } }