东莞心理咨询小程序预约系统全栈实战—东莞辰诉心理咨询中心
引言
在移动互联网时代,小程序以其"即用即走"的轻量特性,成为心理咨询机构数字化转型的首选载体。对于东莞这样外来人口密集、制造业企业众多的城市,心理咨询服务更需要突破时空限制,让忙碌的职场人能够随时随地获得专业帮助。本文将以辰诉心理咨询中心的小程序预约系统为蓝本,从需求分析、架构设计到前后端代码实现,完整呈现一套生产级心理咨询预约系统的技术构建过程。
一、需求分析与系统设计
1.1 辰诉心理咨询的业务场景
辰诉心理咨询中心扎根东莞凤岗镇,服务覆盖情绪压力、婚姻家庭情感、儿童青少年心理、职场发展四大核心领域。其小程序需要满足以下业务诉求:
匿名预约:降低来访者心理门槛,支持虚拟身份咨询
智能匹配:基于需求标签推荐合适的咨询师
时段管理:精确到30分钟的咨询师排班系统
危机预警:自动识别高风险关键词,触发紧急响应
企业EAP:支持制造业批量员工心理服务预约
1.2 系统功能架构
plain
复制
┌─────────────────────────────────────────────────────────────┐
│ 小程序前端层 │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ 首页/测评 │ │ 咨询师列表│ │ 预约流程 │ │ 个人中心 │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
├─────────────────────────────────────────────────────────────┤
│ SpringBoot后端服务层 │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ 用户服务 │ │ 预约服务 │ │ 支付服务 │ │ 消息服务 │ │
│ ├──────────┤ ├──────────┤ ├──────────┤ ├──────────┤ │
│ │ 咨询师服务│ │ 测评服务 │ │ 企业EAP │ │ 通知服务 │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
├─────────────────────────────────────────────────────────────┤
│ 数据存储层 │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ MySQL │ │ Redis │ │ MinIO │ │
│ │ 业务数据 │ │ 缓存/会话│ │ 文件存储 │ │
│ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────────────────────┘
二、微信小程序前端实现
2.1 项目结构与核心页面
plain
复制
chengsu-miniprogram/
├── app.js # 全局入口
├── app.json # 全局配置
├── app.wxss # 全局样式
├── pages/
│ ├── index/ # 首页
│ ├── counselors/ # 咨询师列表
│ ├── booking/ # 预约流程
│ ├── assessment/ # 心理测评
│ ├── chat/ # 匿名咨询聊天
│ └── profile/ # 个人中心
├── components/
│ ├── counselor-card/ # 咨询师卡片
│ ├── time-picker/ # 时段选择器
│ └── privacy-mask/ # 隐私遮罩
├── utils/
│ ├── api.js # API封装
│ ├── crypto.js # 加密工具
│ └── auth.js # 认证管理
└── services/
├── websocket.js # WebSocket服务
└── payment.js # 支付服务
2.2 首页与心理测评入口
JSON
复制
// app.json - 全局配置
{
"pages": [
"pages/index/index",
"pages/counselors/counselors",
"pages/booking/booking",
"pages/assessment/assessment",
"pages/chat/chat",
"pages/profile/profile"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#1a7a6b",
"navigationBarTitleText": "辰诉心理咨询",
"navigationBarTextStyle": "white"
},
"tabBar": {
"color": "#999999",
"selectedColor": "#1a7a6b",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "images/home.png",
"selectedIconPath": "images/home-active.png"
},
{
"pagePath": "pages/counselors/counselors",
"text": "找咨询师",
"iconPath": "images/counselor.png",
"selectedIconPath": "images/counselor-active.png"
},
{
"pagePath": "pages/profile/profile",
"text": "我的",
"iconPath": "images/profile.png",
"selectedIconPath": "images/profile-active.png"
}
]
},
"requiredBackgroundModes": ["audio"],
"permission": {
"scope.record": {
"desc": "用于语音咨询功能"
}
}
}
JavaScript
复制
// pages/index/index.js - 首页逻辑
const api = require('../../utils/api.js');
const auth = require('../../utils/auth.js');
Page({
data: {
banners: [],
consultTypes: [
{ id: 'emotion', icon: '/images/icon-emotion.png', title: '情绪压力', desc: '焦虑抑郁疏导', color: '#e8f5f3' },
{ id: 'marriage', icon: '/images/icon-marriage.png', title: '婚姻家庭', desc: '夫妻关系调解', color: '#fff5f5' },
{ id: 'youth', icon: '/images/icon-youth.png', title: '青少年心理', desc: '厌学网瘾干预', color: '#f0f7ff' },
{ id: 'career', icon: '/images/icon-career.png', title: '职场发展', desc: '职业规划咨询', color: '#fff8e6' }
],
hotCounselors: [],
assessmentEntry: {
title: '3分钟心理自测',
subtitle: 'SCL-90症状自评量表',
participants: 12847
},
isAnonymous: true,
showPrivacyModal: false
},
onLoad() {
this.checkAnonymousStatus();
this.loadHomeData();
this.checkFirstVisit();
},
// 检查匿名状态
checkAnonymousStatus() {
const isAnonymous = wx.getStorageSync('anonymous_mode');
this.setData({ isAnonymous: isAnonymous !== false });
},
// 加载首页数据
async loadHomeData() {
try {
const [banners, counselors] = await Promise.all([
api.get('/api/v1/banners'),
api.get('/api/v1/counselors/hot?limit=4')
]);
this.setData({
banners: banners.data,
hotCounselors: counselors.data.map(c => ({
...c,
// 脱敏处理
displayName: this.data.isAnonymous ? c.alias : c.name,
rating: c.rating.toFixed(1)
}))
});
} catch (err) {
console.error('加载首页数据失败:', err);
}
},
// 首次访问隐私提示
checkFirstVisit() {
const hasAgreed = wx.getStorageSync('privacy_agreed');
if (!hasAgreed) {
this.setData({ showPrivacyModal: true });
}
},
// 同意隐私协议
agreePrivacy() {
wx.setStorageSync('privacy_agreed', true);
this.setData({ showPrivacyModal: false });
},
// 切换匿名模式
toggleAnonymous(e) {
const isAnonymous = e.detail.value;
wx.setStorageSync('anonymous_mode', isAnonymous);
this.setData({ isAnonymous });
this.loadHomeData(); // 重新加载数据
},
// 点击咨询类型
onTypeTap(e) {
const { id, title } = e.currentTarget.dataset;
wx.navigateTo({
url: /pages/counselors/counselors?type=${id}&title=${title}
});
},
// 快速心理测评入口
onAssessmentTap() {
// 记录测评意图(用于后续咨询师匹配)
wx.setStorageSync('assessment_intent', true);
wx.navigateTo({
url: '/pages/assessment/assessment?type=scl90'
});
},
// 企业EAP快速入口
onEapTap() {
wx.navigateTo({
url: '/pages/eap/eap-entry'
});
},

浙公网安备 33010602011771号