45 lines
1.2 KiB
JavaScript
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
|
||
|
|
}
|