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,5 @@
{
"usingComponents": {
"app-header": "/components/app-header/app-header"
}
}

View File

@@ -0,0 +1,182 @@
.firm-page {
background: var(--bg-page);
}
.hero-section {
position: relative;
height: 520rpx;
width: 100%;
display: flex;
flex-direction: column;
justify-content: flex-end;
padding-bottom: 80rpx;
/* Space for overlap */
}
.hero-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.hero-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
/* Updated gradient to match Burgundy Red */
background: linear-gradient(to bottom, rgba(142, 34, 48, 0.4), rgba(92, 13, 21, 0.9));
z-index: 1;
}
.hero-content {
position: relative;
z-index: 2;
padding: 0 var(--spacing-lg);
display: flex;
flex-direction: column;
margin-bottom: 72rpx;
}
.firm-stats {
display: inline-flex;
align-items: center;
width: fit-content;
padding: 14rpx 22rpx;
border-radius: 20rpx;
border: 1rpx solid rgba(255, 255, 255, 0.32);
background: linear-gradient(120deg, rgba(10, 21, 34, 0.62), rgba(19, 38, 56, 0.36));
box-shadow: 0 10rpx 28rpx rgba(7, 15, 27, 0.35), inset 0 1rpx 0 rgba(255, 255, 255, 0.24);
backdrop-filter: blur(10rpx);
-webkit-backdrop-filter: blur(10rpx);
}
.stat-item {
display: flex;
flex-direction: column;
min-width: 120rpx;
}
.stat-num {
font-size: 44rpx;
font-weight: 700;
color: #fff;
line-height: 1.2;
text-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.35);
}
.stat-label {
font-size: 24rpx;
color: rgba(242, 247, 252, 0.92);
margin-top: 4rpx;
text-shadow: 0 1rpx 8rpx rgba(0, 0, 0, 0.28);
}
.stat-divider {
width: 2rpx;
height: 40rpx;
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.12));
margin: 0 24rpx;
}
.content-container {
position: relative;
z-index: 3;
margin-top: -60rpx;
background: var(--bg-page);
border-radius: 32rpx 32rpx 0 0;
padding: var(--spacing-lg) var(--spacing-md);
min-height: 50vh;
}
.address-card {
display: flex;
align-items: center;
justify-content: space-between;
padding: var(--spacing-md);
margin-bottom: var(--spacing-lg);
background: #fff;
box-shadow: var(--shadow-base);
}
.address-info {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.address-label {
font-size: 24rpx;
color: var(--text-tertiary);
}
.address-text {
font-size: 28rpx;
color: var(--text-main);
font-weight: 500;
}
.address-icon {
font-size: 32rpx;
color: var(--text-tertiary);
}
.section {
margin-bottom: var(--spacing-xl);
}
.intro-text {
font-size: 28rpx;
color: var(--text-secondary);
line-height: 1.8;
text-align: justify;
}
.tags-wrapper {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
}
.area-tag {
font-size: 26rpx;
color: var(--primary-color);
background: rgba(142, 34, 48, 0.08);
/* Primary color opacity */
padding: 10rpx 24rpx;
border-radius: 32rpx;
font-weight: 500;
}
.bottom-bar {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background: #fff;
padding: 20rpx var(--spacing-md);
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.05);
z-index: 10;
box-sizing: border-box;
}
.cta-btn {
background: var(--primary-color);
color: #fff;
font-size: 32rpx;
font-weight: 500;
border-radius: 50rpx;
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 8rpx 20rpx rgba(142, 34, 48, 0.3);
}
.cta-btn::after {
border: none;
}

View 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' });
},
});
},
});

View File

@@ -0,0 +1,60 @@
<view class="container-page firm-page">
<!-- Custom Navigation Bar with transparent background initially if possible, or just standard -->
<app-header title="{{firm.name}}" back="{{false}}" background="rgba(255,255,255,0.9)"></app-header>
<scroll-view class="page-content" scroll-y="true" type="list">
<!-- Hero Section -->
<view class="hero-section">
<image wx:if="{{firm.heroImage}}" class="hero-bg" mode="aspectFill" src="{{firm.heroImage}}"></image>
<view wx:if="{{!firm.heroImage}}" class="hero-overlay"></view>
<view class="hero-content">
<view class="firm-stats">
<view class="stat-item">
<text class="stat-num">{{firm.officeCount}}</text>
<text class="stat-label">办公机构</text>
</view>
<view class="stat-divider"></view>
<view class="stat-item">
<text class="stat-num">{{firm.lawyerCount}}</text>
<text class="stat-label">专业律师</text>
</view>
</view>
</view>
</view>
<!-- Content Container (Overlapping) -->
<view class="content-container">
<!-- Address Card -->
<view class="card address-card" bindtap="openLocation">
<view class="address-info">
<text class="address-label">总部地址</text>
<text class="address-text">{{firm.hqAddress}}</text>
</view>
<text class="address-icon">></text>
</view>
<!-- Intro Section -->
<view class="section">
<view class="section-title">律所简介</view>
<text class="intro-text">{{firm.intro}}</text>
</view>
<!-- Practice Areas -->
<view class="section">
<view class="section-title">专业领域</view>
<view class="tags-wrapper">
<view class="area-tag" wx:for="{{firm.practiceAreas}}" wx:key="*this">{{item}}</view>
</view>
</view>
<view class="safe-area-bottom" style="height: 120rpx;"></view>
</view>
</scroll-view>
<!-- Bottom CTA -->
<view class="bottom-bar safe-area-bottom">
<button class="cta-btn" bindtap="goLawyerList">查找专业律师</button>
</view>
</view>

View File

@@ -0,0 +1,7 @@
{
"usingComponents": {
"app-header": "/components/app-header/app-header",
"lawyer-card": "/components/lawyer-card/lawyer-card",
"empty-state": "/components/empty-state/empty-state"
}
}

View File

@@ -0,0 +1,39 @@
.history-page {
background: var(--theme-bg);
}
.actions {
padding: 14rpx 24rpx 0;
display: flex;
justify-content: flex-end;
}
.clear-btn {
margin: 0;
width: 156rpx;
height: 60rpx;
line-height: 60rpx;
border-radius: 12rpx;
border: 1rpx solid var(--theme-border);
font-size: 24rpx;
color: var(--theme-primary);
background: #fff;
}
.clear-btn::after {
border: none;
}
.history-list {
padding: 16rpx 24rpx 30rpx;
}
.history-item {
margin-bottom: 16rpx;
}
.history-time {
margin: 10rpx 10rpx 0;
font-size: 22rpx;
color: #8e96a6;
}

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' });
}
},
});
},
});

View File

@@ -0,0 +1,22 @@
<view class="container-page history-page">
<app-header title="名片查看记录" back="{{true}}" background="#f6f7fa"></app-header>
<scroll-view class="page-content" scroll-y="true" type="list">
<block wx:if="{{items.length}}">
<view class="actions">
<button class="clear-btn" bindtap="clearHistory">清空记录</button>
</view>
<view class="history-list">
<view class="history-item" wx:for="{{items}}" wx:key="viewedAt" wx:for-item="item">
<lawyer-card lawyer="{{item.lawyer}}" bind:select="handleLawyerSelect"></lawyer-card>
<text class="history-time">查看时间:{{item.timeText}}</text>
</view>
</view>
</block>
<block wx:else>
<empty-state text="还没有名片浏览记录"></empty-state>
</block>
</scroll-view>
</view>

View File

@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}

View File

@@ -0,0 +1,61 @@
/**index.less**/
page {
height: 100vh;
display: flex;
flex-direction: column;
}
.scrollarea {
flex: 1;
overflow-y: hidden;
}
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
color: #aaa;
width: 80%;
}
.userinfo-avatar {
overflow: hidden;
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.usermotto {
margin-top: 200px;
}
.avatar-wrapper {
padding: 0;
width: 56px !important;
border-radius: 8px;
margin-top: 40px;
margin-bottom: 40px;
}
.avatar {
display: block;
width: 56px;
height: 56px;
}
.nickname-wrapper {
display: flex;
width: 100%;
padding: 16px;
box-sizing: border-box;
border-top: .5px solid rgba(0, 0, 0, 0.1);
border-bottom: .5px solid rgba(0, 0, 0, 0.1);
color: black;
}
.nickname-label {
width: 105px;
}
.nickname-input {
flex: 1;
}

View File

@@ -0,0 +1,54 @@
// index.ts
// 获取应用实例
const app = getApp<IAppOption>()
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
Component({
data: {
motto: 'Hello World',
userInfo: {
avatarUrl: defaultAvatarUrl,
nickName: '',
},
hasUserInfo: false,
canIUseGetUserProfile: wx.canIUse('getUserProfile'),
canIUseNicknameComp: wx.canIUse('input.type.nickname'),
},
methods: {
// 事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs',
})
},
onChooseAvatar(e: any) {
const { avatarUrl } = e.detail
const { nickName } = this.data.userInfo
this.setData({
"userInfo.avatarUrl": avatarUrl,
hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
})
},
onInputChange(e: any) {
const nickName = e.detail.value
const { avatarUrl } = this.data.userInfo
this.setData({
"userInfo.nickName": nickName,
hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
})
},
getUserProfile() {
// 推荐使用wx.getUserProfile获取用户信息开发者每次通过该接口获取用户个人信息均需用户确认开发者妥善保管用户快速填写的头像昵称避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
},
})

View File

@@ -0,0 +1,28 @@
<!--index.wxml-->
<navigation-bar title="Weixin" back="{{false}}" color="black" background="#FFF"></navigation-bar>
<scroll-view class="scrollarea" scroll-y type="list">
<view class="container">
<view class="userinfo">
<block wx:if="{{canIUseNicknameComp && !hasUserInfo}}">
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
<image class="avatar" src="{{userInfo.avatarUrl}}"></image>
</button>
<view class="nickname-wrapper">
<text class="nickname-label">昵称</text>
<input type="nickname" class="nickname-input" placeholder="请输入昵称" bind:change="onInputChange" />
</view>
</block>
<block wx:elif="{{!hasUserInfo}}">
<button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
<view wx:else> 请使用2.10.4及以上版本基础库 </view>
</block>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view>
</scroll-view>

View File

@@ -0,0 +1,8 @@
{
"enableShareAppMessage": true,
"usingComponents": {
"app-header": "/components/app-header/app-header",
"action-dock": "/components/action-dock/action-dock",
"empty-state": "/components/empty-state/empty-state"
}
}

View File

@@ -0,0 +1,245 @@
.detail-page {
background: var(--bg-page);
}
.detail-bg {
height: 300rpx;
background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 0;
border-radius: 0 0 40rpx 40rpx;
}
.profile-card {
position: relative;
z-index: 1;
margin: 160rpx var(--spacing-md) 0;
background: #fff;
border-radius: var(--border-radius-lg);
padding: var(--spacing-lg);
box-shadow: var(--shadow-base);
display: flex;
align-items: flex-start;
}
.avatar {
width: 140rpx;
height: 140rpx;
border-radius: 50%;
border: 4rpx solid #fff;
box-shadow: var(--shadow-sm);
margin-top: -60rpx;
/* Overlap effect */
background: #fff;
}
.profile-info {
flex: 1;
margin-left: var(--spacing-md);
padding-top: var(--spacing-xs);
}
.name-row {
display: flex;
align-items: baseline;
flex-wrap: wrap;
gap: 12rpx;
margin-bottom: 8rpx;
}
.name {
font-size: 36rpx;
font-weight: 600;
color: var(--text-main);
}
.title {
font-size: 24rpx;
color: var(--primary-color);
background: rgba(142, 34, 48, 0.08);
/* Primary opacity */
padding: 2rpx 12rpx;
border-radius: 8rpx;
}
.firm-name {
font-size: 24rpx;
color: var(--text-tertiary);
display: block;
}
.qr-btn {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 10rpx;
}
.qr-icon-text {
font-size: 32rpx;
color: var(--text-secondary);
margin-bottom: 4rpx;
}
.qr-btn text {
font-size: 20rpx;
color: var(--text-secondary);
}
.content-body {
padding: var(--spacing-md);
}
.section-card {
background: #fff;
border-radius: var(--border-radius-base);
padding: var(--spacing-md);
margin-bottom: var(--spacing-md);
box-shadow: var(--shadow-sm);
}
.section-header {
font-size: 28rpx;
font-weight: 600;
color: var(--text-secondary);
margin-bottom: var(--spacing-md);
position: relative;
padding-left: 16rpx;
}
.section-header::before {
content: '';
position: absolute;
left: 0;
top: 6rpx;
bottom: 6rpx;
width: 6rpx;
background: var(--accent-color);
border-radius: 4rpx;
}
.contact-item {
display: flex;
align-items: center;
padding: 16rpx 0;
}
.contact-label {
width: 80rpx;
color: var(--text-tertiary);
font-size: 26rpx;
}
.contact-value {
flex: 1;
color: var(--text-main);
font-size: 28rpx;
font-weight: 500;
}
.action-icon {
width: 60rpx;
text-align: center;
font-size: 32rpx;
}
.divider {
height: 1rpx;
background: var(--bg-page);
margin: 0 0;
}
.tags-row {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
}
.tag {
font-size: 24rpx;
color: var(--primary-color);
background: rgba(142, 34, 48, 0.05);
padding: 8rpx 20rpx;
border-radius: 30rpx;
}
.bio-text {
font-size: 28rpx;
color: var(--text-secondary);
line-height: 1.6;
text-align: justify;
white-space: pre-wrap;
}
.bio-scroll {
height: 360rpx;
box-sizing: border-box;
padding-right: 8rpx;
}
.firm-mini-card {
background: #fff;
padding: var(--spacing-md);
border-radius: var(--border-radius-base);
display: flex;
align-items: center;
gap: 20rpx;
}
.firm-logo-mini-placeholder {
height: 60rpx;
width: 140rpx;
background: var(--bg-surface);
border-radius: 8rpx;
display: flex;
align-items: center;
justify-content: center;
}
.mini-logo-text {
font-size: 24rpx;
font-weight: 700;
color: var(--primary-color);
font-family: serif;
}
.firm-mini-info {
flex: 1;
display: flex;
flex-direction: column;
}
.firm-mini-name {
font-size: 26rpx;
color: var(--text-main);
font-weight: 500;
}
.firm-mini-address {
font-size: 22rpx;
color: var(--text-tertiary);
}
.arrow {
color: var(--text-placeholder);
}
.detail-bottom-space {
height: 160rpx;
}
.not-found-action {
padding: var(--spacing-lg);
text-align: center;
}
.back-btn {
background: var(--primary-color);
color: #fff;
font-size: 28rpx;
border-radius: 40rpx;
}

View File

@@ -0,0 +1,188 @@
import { getLawyerDetail, recordCardShare } from '../../api/open';
import type { FirmInfo } from '../../types/card';
import type { Lawyer } from '../../types/card';
import { appendCardViewRecord } from '../../utils/history';
function createEmptyFirm(): FirmInfo {
return {
id: '',
name: '',
logo: '',
intro: '',
hotlinePhone: '',
hqAddress: '',
hqLatitude: 0,
hqLongitude: 0,
officeCount: 0,
lawyerCount: 0,
heroImage: '',
officeList: [],
practiceAreas: [],
};
}
function buildDetailBgStyle(coverImage?: string): string {
const cover = typeof coverImage === 'string' ? coverImage.trim() : '';
if (!cover) {
return '';
}
return `background-image: url("${cover}"); background-size: cover; background-position: center;`;
}
function shouldUseBioScroll(bio?: string): boolean {
const text = typeof bio === 'string' ? bio.trim() : '';
return text.length > 180;
}
Page({
data: {
firm: createEmptyFirm(),
lawyer: null as Lawyer | null,
notFound: false,
specialtiesText: '',
detailBgStyle: '',
bioScrollable: false,
loading: false,
},
async onLoad(options: Record<string, string | undefined>) {
const lawyerId = typeof options.id === 'string' ? options.id : '';
const sourceType = typeof options.sourceType === 'string' ? options.sourceType : 'DIRECT';
const shareFromCardId = typeof options.shareFromCardId === 'string' ? options.shareFromCardId : '';
if (!lawyerId) {
this.setData({ notFound: true, specialtiesText: '', detailBgStyle: '', bioScrollable: false });
return;
}
this.setData({ loading: true });
try {
const payload = await getLawyerDetail(lawyerId, sourceType, shareFromCardId);
this.setData({
firm: payload.firm,
lawyer: payload.lawyer,
notFound: false,
specialtiesText: payload.lawyer.specialties.join(''),
detailBgStyle: buildDetailBgStyle(payload.lawyer.coverImage),
bioScrollable: shouldUseBioScroll(payload.lawyer.bio),
});
appendCardViewRecord(payload.lawyer);
wx.showShareMenu({ menus: ['shareAppMessage'] });
} catch (error) {
const message = error instanceof Error ? error.message : '律师信息不存在';
this.setData({ notFound: true, specialtiesText: '', detailBgStyle: '', bioScrollable: false });
wx.showToast({
title: message,
icon: 'none',
});
} finally {
this.setData({ loading: false });
}
},
handleDockAction(event: WechatMiniprogram.CustomEvent<{ action: string }>) {
const action = event.detail.action;
switch (action) {
case 'save':
this.saveContact();
break;
case 'location':
this.navigateOffice();
break;
default:
break;
}
},
saveContact() {
const lawyer = this.data.lawyer;
if (!lawyer) {
return;
}
wx.addPhoneContact({
firstName: lawyer.name,
mobilePhoneNumber: lawyer.phone,
email: lawyer.email,
organization: this.data.firm.name,
title: lawyer.title,
workAddressStreet: lawyer.address,
remark: lawyer.specialties.join('、'),
success: () => {
wx.showToast({ title: '已添加到通讯录', icon: 'success' });
},
fail: () => {
wx.showToast({ title: '添加失败', icon: 'none' });
},
});
},
callPhone() {
const phone = this.data.lawyer ? this.data.lawyer.phone : '';
if (!phone) {
wx.showToast({ title: '暂无联系电话', icon: 'none' });
return;
}
wx.makePhoneCall({
phoneNumber: phone,
fail: () => {
wx.showToast({ title: '拨号失败', icon: 'none' });
},
});
},
navigateOffice() {
if (!this.data.firm.hqLatitude || !this.data.firm.hqLongitude) {
wx.showToast({ title: '暂未配置地图位置', icon: 'none' });
return;
}
wx.openLocation({
latitude: this.data.firm.hqLatitude,
longitude: this.data.firm.hqLongitude,
name: this.data.firm.name,
address: this.data.firm.hqAddress,
scale: 18,
fail: () => {
wx.showToast({ title: '打开地图失败', icon: 'none' });
},
});
},
previewWechatQr() {
const url = this.data.lawyer ? this.data.lawyer.wechatQrImage : '';
if (!url) {
wx.showToast({ title: '二维码未配置', icon: 'none' });
return;
}
wx.previewImage({
current: url,
urls: [url],
});
},
goLawyerList() {
wx.navigateTo({ url: '/pages/lawyer-list/index' });
},
onShareAppMessage() {
const lawyer = this.data.lawyer;
if (!lawyer) {
return {
title: `${this.data.firm.name || '电子名片'}电子名片`,
path: '/pages/firm/index',
};
}
const sharePath = `/pages/lawyer-detail/index?id=${lawyer.id}&sourceType=SHARE&shareFromCardId=${lawyer.id}`;
recordCardShare(lawyer.id, sharePath).catch(() => {
// 分享埋点失败不阻断分享动作
});
return {
title: `${lawyer.name}律师电子名片`,
path: sharePath,
imageUrl: lawyer.avatar,
};
},
});

View File

@@ -0,0 +1,79 @@
<view class="container-page detail-page">
<app-header title="名片详情" back="{{true}}" background="transparent"></app-header>
<block wx:if="{{notFound}}">
<view class="page-content">
<empty-state text="未找到律师信息"></empty-state>
<view class="not-found-action">
<button class="back-btn" bindtap="goLawyerList">返回律师列表</button>
</view>
</view>
</block>
<block wx:else>
<scroll-view class="page-content" scroll-y="true" type="list">
<!-- Top Background -->
<view class="detail-bg" style="{{detailBgStyle}}"></view>
<!-- Profile Card (Overlapping) -->
<view class="profile-card">
<image class="avatar" src="{{lawyer.avatar}}" mode="aspectFill"></image>
<view class="profile-info">
<view class="name-row">
<text class="name">{{lawyer.name}}</text>
<text class="title">{{lawyer.title}}</text>
</view>
<text class="firm-name">{{firm.name}} | {{lawyer.office}}</text>
</view>
<view class="qr-btn" bindtap="previewWechatQr">
<!-- Replaced icon with text for simplicity if icon missing -->
<text class="qr-icon-text">⚲</text>
<text>二维码</text>
</view>
</view>
<!-- Content Sections -->
<view class="content-body">
<!-- Contact Section -->
<view class="section-card">
<view class="section-header">联系方式</view>
<view class="contact-item" bindtap="callPhone">
<text class="contact-label">电话</text>
<text class="contact-value">{{lawyer.phone}}</text>
<view class="action-icon phone">📞</view>
</view>
<view class="divider"></view>
<view class="contact-item">
<text class="contact-label">邮箱</text>
<text class="contact-value">{{lawyer.email}}</text>
</view>
</view>
<!-- Practise Areas -->
<view class="section-card">
<view class="section-header">执业领域</view>
<view class="tags-row">
<text class="tag" wx:for="{{lawyer.specialties}}" wx:key="*this">{{item}}</text>
</view>
</view>
<!-- Bio -->
<view class="section-card">
<view class="section-header">个人简介</view>
<scroll-view wx:if="{{bioScrollable}}" class="bio-scroll" scroll-y="true" show-scrollbar="true">
<view class="bio-text">{{lawyer.bio}}</view>
</scroll-view>
<view wx:else class="bio-text">{{lawyer.bio}}</view>
</view>
<view class="detail-bottom-space"></view>
</view>
</scroll-view>
<!-- Fixed Action Dock -->
<action-dock bind:action="handleDockAction"></action-dock>
</block>
</view>

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>

View File

@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}

View File

@@ -0,0 +1,16 @@
page {
height: 100vh;
display: flex;
flex-direction: column;
}
.scrollarea {
flex: 1;
overflow-y: hidden;
}
.log-item {
margin-top: 20rpx;
text-align: center;
}
.log-item:last-child {
padding-bottom: env(safe-area-inset-bottom);
}

View File

@@ -0,0 +1,21 @@
// logs.ts
// const util = require('../../utils/util.js')
import { formatTime } from '../../utils/util'
Component({
data: {
logs: [],
},
lifetimes: {
attached() {
this.setData({
logs: (wx.getStorageSync('logs') || []).map((log: string) => {
return {
date: formatTime(new Date(log)),
timeStamp: log
}
}),
})
}
},
})

View File

@@ -0,0 +1,7 @@
<!--logs.wxml-->
<navigation-bar title="查看启动日志" back="{{true}}" color="black" background="#FFF"></navigation-bar>
<scroll-view class="scrollarea" scroll-y type="list">
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
<view class="log-item">{{index + 1}}. {{log.date}}</view>
</block>
</scroll-view>