Files
zhuomi-hui/miniprogram/utils/activity.js
T
Michelle ZanandCursor cd05113755 Add 卓米会 mini program and admin server.
Initial commit of the WeChat mini program, Express backend, and admin console.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-29 19:01:36 +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.poster || item.cover
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
}