import { getFirmProfile } from '../../api/open'; import type { FirmInfo } from '../../types/card'; function createEmptyFirm(): FirmInfo { return { id: '', name: '', logo: '', intro: '', hotlinePhone: '', hqAddress: '', hqLatitude: 0, hqLongitude: 0, officeCount: 0, lawyerCount: 0, heroImage: '', officeList: [], practiceAreas: [], }; } Page({ data: { firm: createEmptyFirm(), loading: false, }, onLoad() { this.loadFirmProfile(); }, async loadFirmProfile() { this.setData({ loading: true }); try { const firm = await getFirmProfile(); this.setData({ firm }); } catch (error) { const message = error instanceof Error ? error.message : '加载事务所信息失败'; wx.showToast({ title: message, icon: 'none', }); } finally { this.setData({ loading: false }); } }, goLawyerList() { wx.navigateTo({ url: '/pages/lawyer-list/index', }); }, openLocation() { const { firm } = this.data; if (!firm.hqLatitude || !firm.hqLongitude) { wx.showToast({ title: '暂未配置地图位置', icon: 'none', }); return; } wx.openLocation({ latitude: firm.hqLatitude, longitude: firm.hqLongitude, name: firm.name, address: firm.hqAddress, scale: 18, fail: () => { wx.showToast({ title: '打开地图失败', icon: 'none' }); }, }); }, });