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,8 @@
{
"usingComponents": {
"app-header": "/components/app-header/app-header",
"lawyer-card": "/components/lawyer-card/lawyer-card",
"filter-bar": "/components/filter-bar/filter-bar",
"empty-state": "/components/empty-state/empty-state"
}
}

View File

@@ -0,0 +1,116 @@
.lawyer-list-page {
background: var(--bg-page);
}
.sticky-header {
position: sticky;
top: 0;
z-index: 10;
background: var(--bg-page);
padding-bottom: var(--spacing-sm);
}
.search-wrap {
padding: var(--spacing-sm) var(--spacing-md);
background: #fff;
}
.search-box {
height: 80rpx;
border-radius: 40rpx;
background: var(--bg-surface);
display: flex;
align-items: center;
padding: 0 24rpx;
gap: 12rpx;
border: 1rpx solid transparent;
transition: all 0.2s;
}
.search-box:active {
background: #fff;
border-color: var(--primary-color);
}
.search-input {
flex: 1;
min-width: 0;
font-size: 28rpx;
color: var(--text-main);
height: 100%;
}
.search-placeholder {
color: var(--text-placeholder);
}
.quick-actions {
display: flex;
gap: var(--spacing-md);
padding: 0 var(--spacing-md) var(--spacing-md);
}
.action-btn {
flex: 1;
height: 80rpx;
border-radius: var(--border-radius-base);
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
font-weight: 500;
transition: opacity 0.2s;
}
.action-btn:active {
opacity: 0.8;
}
.hotline-btn {
background: rgba(142, 34, 48, 0.06);
/* Burgundy tint */
color: var(--primary-color);
}
.map-btn {
background: #fff;
color: var(--text-secondary);
border: 1rpx solid var(--border-color);
}
.list-wrap {
padding: 0 var(--spacing-md);
}
.card-item {
margin-bottom: var(--spacing-md);
background: #fff;
/* Ensure card background is white */
border-radius: var(--border-radius-base);
}
.list-bottom-space {
height: 120rpx;
}
/* History Floating Action Button styling */
.history-fab {
position: fixed;
right: var(--spacing-md);
bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom));
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
padding: 16rpx 32rpx;
border-radius: 40rpx;
box-shadow: var(--shadow-lg);
display: flex;
align-items: center;
z-index: 20;
border: 1rpx solid var(--border-color);
}
.history-text {
font-size: 26rpx;
color: var(--text-main);
font-weight: 500;
}

View File

@@ -0,0 +1,147 @@
import { getFirmProfile, listLawyers } from '../../api/open';
import type { Lawyer } from '../../types/card';
const ALL_OFFICES = '所有办公机构';
const ALL_AREAS = '全部专业领域';
let searchDebounceTimer: number | null = null;
Page({
data: {
firmName: '',
firmAddress: '',
firmLatitude: 0,
firmLongitude: 0,
keyword: '',
selectedOffice: ALL_OFFICES,
selectedArea: ALL_AREAS,
officeOptions: [ALL_OFFICES],
areaOptions: [ALL_AREAS],
filteredLawyers: [] as Lawyer[],
hotlinePhone: '',
loading: false,
},
onLoad() {
this.initializePage();
},
async initializePage() {
this.setData({ loading: true });
try {
const firm = await getFirmProfile();
this.setData({
firmName: firm.name,
firmAddress: firm.hqAddress,
firmLatitude: firm.hqLatitude,
firmLongitude: firm.hqLongitude,
hotlinePhone: firm.hotlinePhone,
officeOptions: [ALL_OFFICES, ...firm.officeList],
areaOptions: [ALL_AREAS, ...firm.practiceAreas],
});
await this.loadLawyers();
} catch (error) {
const message = error instanceof Error ? error.message : '加载列表失败';
wx.showToast({ title: message, icon: 'none' });
} finally {
this.setData({ loading: false });
}
},
onUnload() {
if (searchDebounceTimer !== null) {
clearTimeout(searchDebounceTimer);
searchDebounceTimer = null;
}
},
onSearchInput(event: WechatMiniprogram.CustomEvent<{ value: string }>) {
const keyword = event.detail.value || '';
this.setData({ keyword });
if (searchDebounceTimer !== null) {
clearTimeout(searchDebounceTimer);
}
searchDebounceTimer = setTimeout(() => {
this.loadLawyers();
}, 250) as unknown as number;
},
handleOfficeChange(event: WechatMiniprogram.CustomEvent<{ value: string }>) {
this.setData({ selectedOffice: event.detail.value });
this.loadLawyers();
},
handleAreaChange(event: WechatMiniprogram.CustomEvent<{ value: string }>) {
this.setData({ selectedArea: event.detail.value });
this.loadLawyers();
},
async loadLawyers() {
this.setData({ loading: true });
try {
const filteredLawyers = await listLawyers({
keyword: this.data.keyword.trim() || undefined,
office: this.data.selectedOffice === ALL_OFFICES ? undefined : this.data.selectedOffice,
practiceArea: this.data.selectedArea === ALL_AREAS ? undefined : this.data.selectedArea,
});
this.setData({ filteredLawyers });
} catch (error) {
const message = error instanceof Error ? error.message : '加载律师列表失败';
wx.showToast({ title: message, icon: 'none' });
} finally {
this.setData({ loading: false });
}
},
handleLawyerSelect(event: WechatMiniprogram.CustomEvent<{ id: string }>) {
const lawyerId = event.detail.id;
if (!lawyerId) {
return;
}
wx.navigateTo({
url: `/pages/lawyer-detail/index?id=${lawyerId}`,
});
},
callHotline() {
if (!this.data.hotlinePhone) {
wx.showToast({
title: '暂无联系电话',
icon: 'none',
});
return;
}
wx.makePhoneCall({
phoneNumber: this.data.hotlinePhone,
fail: () => {
wx.showToast({ title: '拨号失败', icon: 'none' });
},
});
},
openOffice() {
if (!this.data.firmLatitude || !this.data.firmLongitude) {
wx.showToast({ title: '暂未配置地图位置', icon: 'none' });
return;
}
wx.openLocation({
latitude: this.data.firmLatitude,
longitude: this.data.firmLongitude,
name: this.data.firmName,
address: this.data.firmAddress,
scale: 18,
fail: () => {
wx.showToast({ title: '打开地图失败', icon: 'none' });
},
});
},
goHistory() {
wx.navigateTo({
url: '/pages/history/index',
});
},
});

View File

@@ -0,0 +1,56 @@
<view class="container-page lawyer-list-page">
<app-header title="专业律师" back="{{true}}" background="#fff"></app-header>
<!-- Sticky Header Wrapper -->
<view class="sticky-header">
<view class="search-wrap">
<view class="search-box">
<icon type="search" size="16" color="#999"></icon>
<input
class="search-input"
placeholder-class="search-placeholder"
placeholder="搜索律师姓名、专业领域..."
value="{{keyword}}"
bindinput="onSearchInput"
/>
</view>
</view>
<filter-bar
office-options="{{officeOptions}}"
area-options="{{areaOptions}}"
selected-office="{{selectedOffice}}"
selected-area="{{selectedArea}}"
bind:officechange="handleOfficeChange"
bind:areachange="handleAreaChange"
></filter-bar>
</view>
<view class="quick-actions">
<view class="action-btn hotline-btn" bindtap="callHotline">
<image class="action-icon" src="/assets/icons/phone.svg" mode="aspectFit" wx:if="{{false}}"></image> <!-- Placeholder for icon -->
<text>联系电话</text>
</view>
<view class="action-btn map-btn" bindtap="openOffice">
<text>总部导航</text>
</view>
</view>
<scroll-view class="page-content list-scroll" scroll-y="true" type="list">
<view class="list-wrap">
<block wx:if="{{filteredLawyers.length}}">
<view class="card-item" wx:for="{{filteredLawyers}}" wx:key="id" wx:for-item="item">
<lawyer-card lawyer="{{item}}" bind:select="handleLawyerSelect"></lawyer-card>
</view>
</block>
<block wx:else>
<empty-state text="未找到匹配的律师"></empty-state>
</block>
<view class="list-bottom-space"></view>
</view>
</scroll-view>
<view class="history-fab" bindtap="goHistory">
<text class="history-text">浏览记录</text>
</view>
</view>