feat: 搭建微信小程序展示端

- 初始化小程序工程配置与类型声明

- 增加首页、律所、律师列表、详情与历史页面

- 补充公共组件、运行时配置与示例素材
This commit is contained in:
2026-03-20 12:44:31 +08:00
parent 86c321e832
commit 9605384edc
87 changed files with 26373 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
import { clearCardViewHistory, getCardViewHistory } from '../../utils/history';
import { formatTime } from '../../utils/util';
import type { Lawyer } from '../../types/card';
interface HistoryCardItem {
lawyer: Lawyer;
viewedAt: number;
timeText: string;
}
function createFallbackLawyer(lawyerId: string): Lawyer {
return {
id: lawyerId,
name: '历史浏览名片',
title: '',
office: '',
phone: '',
email: '',
address: '',
avatar: '',
coverImage: '',
specialties: [],
bio: '',
wechatQrImage: '',
};
}
Page({
data: {
items: [] as HistoryCardItem[],
},
onShow() {
this.loadHistory();
},
loadHistory() {
const history = getCardViewHistory();
if (!history.length) {
this.setData({ items: [] });
return;
}
const items = history
.map((record) => ({
lawyer: record.lawyer || createFallbackLawyer(record.lawyerId),
viewedAt: record.viewedAt,
timeText: formatTime(new Date(record.viewedAt)),
}));
this.setData({ items });
},
handleLawyerSelect(event: WechatMiniprogram.CustomEvent<{ id: string }>) {
const lawyerId = event.detail.id;
if (!lawyerId) {
return;
}
wx.navigateTo({
url: `/pages/lawyer-detail/index?id=${lawyerId}`,
});
},
clearHistory() {
if (!this.data.items.length) {
return;
}
wx.showModal({
title: '清空记录',
content: '确定清空所有名片查看记录吗?',
success: (res) => {
if (res.confirm) {
clearCardViewHistory();
this.setData({ items: [] });
wx.showToast({ title: '已清空', icon: 'success' });
}
},
});
},
});