feat: 搭建微信小程序展示端
- 初始化小程序工程配置与类型声明 - 增加首页、律所、律师列表、详情与历史页面 - 补充公共组件、运行时配置与示例素材
This commit is contained in:
71
frontend_miniprogram/miniprogram/pages/firm/index.ts
Normal file
71
frontend_miniprogram/miniprogram/pages/firm/index.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
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' });
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user