2026-09-17 22:21:31 +08:00
|
|
|
import { serviceStationService } from '../../services'
|
2026-09-14 10:14:05 +08:00
|
|
|
|
|
|
|
|
interface ServiceLocation {
|
|
|
|
|
id: string
|
|
|
|
|
name: string
|
|
|
|
|
shortName?: string
|
|
|
|
|
address?: string
|
|
|
|
|
contactPhone?: string
|
|
|
|
|
contactPhoneDisplay?: string
|
|
|
|
|
openingHoursText?: string
|
|
|
|
|
services?: string[]
|
|
|
|
|
latitude?: number | string
|
|
|
|
|
longitude?: number | string
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-17 22:21:31 +08:00
|
|
|
interface ServiceAnnouncement {
|
|
|
|
|
id: string
|
|
|
|
|
title: string
|
|
|
|
|
content?: string
|
|
|
|
|
expiresAt?: string | null
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-14 10:14:05 +08:00
|
|
|
interface ServiceStationPageData {
|
|
|
|
|
serviceLocation: ServiceLocation | null
|
2026-09-17 22:21:31 +08:00
|
|
|
announcements: ServiceAnnouncement[]
|
2026-09-14 10:14:05 +08:00
|
|
|
loading: boolean
|
|
|
|
|
loadError: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
2026-09-17 22:21:31 +08:00
|
|
|
serviceLocation: null as ServiceLocation | null,
|
|
|
|
|
announcements: [] as ServiceAnnouncement[],
|
2026-09-14 10:14:05 +08:00
|
|
|
loading: true,
|
|
|
|
|
loadError: false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onLoad() {
|
|
|
|
|
this.loadStation()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async loadStation() {
|
|
|
|
|
this.setData({ loading: true, loadError: false })
|
|
|
|
|
try {
|
2026-09-17 22:21:31 +08:00
|
|
|
const station = await serviceStationService.getStation()
|
|
|
|
|
if (!station) {
|
|
|
|
|
this.setData({ serviceLocation: null, announcements: [], loading: false })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// 公告是增强信息:失败降级为空数组,不阻断站点主体信息展示
|
|
|
|
|
const announcements = await serviceStationService.getVisibleAnnouncements(station.id as string)
|
|
|
|
|
this.setData({ serviceLocation: station as ServiceLocation, announcements, loading: false })
|
2026-09-14 10:14:05 +08:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error('加载服务站失败', error)
|
|
|
|
|
this.setData({ loading: false, loadError: true })
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
call() {
|
|
|
|
|
const station = this.data.serviceLocation
|
|
|
|
|
if (!station) return
|
|
|
|
|
const phoneNumber = station.contactPhone || station.contactPhoneDisplay || ''
|
|
|
|
|
const digitCount = phoneNumber.replace(/\D/g, '').length
|
|
|
|
|
if (!phoneNumber || phoneNumber.includes('*') || digitCount < 5) {
|
|
|
|
|
wx.showToast({ title: '联系电话请以预约确认为准', icon: 'none' })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
wx.makePhoneCall({ phoneNumber })
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
openMap() {
|
|
|
|
|
const station = this.data.serviceLocation
|
|
|
|
|
if (!station) return
|
|
|
|
|
const latitude = Number(station.latitude)
|
|
|
|
|
const longitude = Number(station.longitude)
|
|
|
|
|
if (Number.isFinite(latitude) && Number.isFinite(longitude) && latitude && longitude) {
|
|
|
|
|
wx.openLocation({
|
|
|
|
|
latitude,
|
|
|
|
|
longitude,
|
|
|
|
|
name: station.name,
|
|
|
|
|
address: station.address || '',
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (station.address) {
|
|
|
|
|
wx.setClipboardData({ data: station.address })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
wx.showToast({ title: '暂未提供地图位置', icon: 'none' })
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
book() {
|
|
|
|
|
const station = this.data.serviceLocation
|
|
|
|
|
const id = station ? station.id : ''
|
|
|
|
|
const query = id ? `?serviceLocationId=${encodeURIComponent(id)}` : ''
|
|
|
|
|
wx.navigateTo({ url: `/pages/service-appointment/service-appointment${query}` })
|
|
|
|
|
},
|
|
|
|
|
|
2026-09-17 22:21:31 +08:00
|
|
|
/** 公告详情:临时公告正文较长,用弹窗完整展示,避免卡片被截断 */
|
|
|
|
|
onShowAnnouncement(e: WechatMiniprogram.TouchEvent) {
|
|
|
|
|
const id = e.currentTarget.dataset.id as string
|
|
|
|
|
const target = (this.data.announcements as ServiceAnnouncement[]).find((item) => item.id === id)
|
|
|
|
|
if (!target) return
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: target.title || '临时公告',
|
|
|
|
|
content: target.content || target.title || '',
|
|
|
|
|
showCancel: false,
|
|
|
|
|
confirmText: '知道了',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2026-09-14 10:14:05 +08:00
|
|
|
onRetry() {
|
|
|
|
|
this.loadStation()
|
|
|
|
|
},
|
|
|
|
|
})
|