Files
zhuomi-hui/miniprogram/utils/activity.js
T
Michelle ZanandCursor 0ca2e87bf2 Ship signup sheet, subscribe reminders, cover crop, and theme updates.
Wire real WeChat app config, prefer activity cover over posters, and add admin cover cropping for the home banner.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-08 13:06:43 +08:00

45 lines
1.2 KiB
JavaScript

const media = require('./media')
function openMap(activity) {
if (!activity || activity.latitude == null || activity.longitude == null) {
wx.showToast({ title: '暂无会场坐标', icon: 'none' })
return
}
wx.openLocation({
latitude: Number(activity.latitude),
longitude: Number(activity.longitude),
name: activity.title,
address: activity.address,
scale: 16
})
}
function goSignup(activity) {
if (!activity || !activity.id) return
wx.navigateTo({ url: '/pages/signup/signup?id=' + activity.id })
}
// Shared links always land on the detail page and carry the sharer's openid for attribution.
function shareMessage(activity, fallbackId) {
const item = activity || {}
const openid = wx.getStorageSync('openid') || ''
const cover = item.cover || item.poster
const message = {
title: item.title || '卓米会',
path: '/pages/detail/detail?id=' + (item.id || fallbackId || '') + '&sharer=' + openid
}
if (cover) message.imageUrl = media.absUrl(cover)
return message
}
function toast(error) {
wx.showToast({ title: (error && error.message) || '操作失败', icon: 'none' })
}
module.exports = {
openMap: openMap,
goSignup: goSignup,
shareMessage: shareMessage,
toast: toast
}