小程序预约改动

This commit is contained in:
zhanchao 2026-07-29 17:30:30 +08:00
parent f353daccaa
commit cc069d0af1
7 changed files with 610 additions and 3 deletions

View File

@ -197,6 +197,26 @@
}
]
},
{
"root": "pages/record",
"name": "record",
"pages": [
{
"path": "treatment-record",
"style": {
"navigationBarTitleText": "治疗记录",
"disableScroll": true
}
},
{
"path": "appointment-record",
"style": {
"navigationBarTitleText": "预约记录",
"disableScroll": true
}
}
]
},
{
"root": "pages/archive",
"name": "archive",

View File

@ -99,6 +99,13 @@ function buildTargetUrl(item) {
if (target.value === "health") {
return `/pages/health/list?teamId=${team}&corpId=${corp}&id=${customer}&name=${name}`;
}
if (target.value === "treatment") {
return `/pages/record/treatment-record?teamId=${team}&corpId=${corp}&customerId=${customer}&name=${name}`;
}
if (target.value === "appointment") {
const corpName = encodeURIComponent(item.corpName || "");
return `/pages/record/appointment-record?teamId=${team}&corpId=${corp}&customerId=${customer}&name=${name}&corpName=${corpName}`;
}
return `/pages/experience-coupon/my-rights?corpId=${corp}&teamId=${team}&customerId=${customer}&name=${name}`;
}

View File

@ -25,12 +25,18 @@
</view>
<text class="shortcut-title">我的体验券</text>
</view>
<view class="shortcut-item" @click="openHealthRecord">
<view class="shortcut-item" @click="openTreatmentRecord">
<view class="shortcut-icon shortcut-icon--record">
<uni-icons type="compose" size="28" color="#19be6b"></uni-icons>
</view>
<text class="shortcut-title">治疗记录</text>
</view>
<view class="shortcut-item" @click="openAppointmentRecord">
<view class="shortcut-icon shortcut-icon--appointment">
<uni-icons type="calendar" size="28" color="#7c3aed"></uni-icons>
</view>
<text class="shortcut-title">预约记录</text>
</view>
</view>
<view class="menu-container">
@ -257,8 +263,12 @@ async function openCouponWallet() {
await openWithArchive("coupons");
}
async function openHealthRecord() {
await openWithArchive("health");
async function openTreatmentRecord() {
await openWithArchive("treatment");
}
async function openAppointmentRecord() {
await openWithArchive("appointment");
}
function toPage(url) {
@ -363,6 +373,10 @@ page {
background: #ecfff5;
}
.shortcut-icon--appointment {
background: #f3edff;
}
.shortcut-title {
font-size: 14px;
line-height: 20px;

View File

@ -0,0 +1,346 @@
<template>
<full-page pageClass="record-page" :customScroll="true">
<view class="page-body">
<view class="profile-card" @click="switchArchive">
<view class="avatar-wrap">
<view class="avatar-placeholder">{{ avatarText }}</view>
</view>
<view class="profile-main">
<view class="profile-title">{{ customerName || "请选择档案" }}</view>
<view class="profile-sub">所属机构{{ corpName || "-" }}</view>
</view>
<view class="profile-arrow">&gt;</view>
</view>
<picker mode="date" fields="month" :value="selectedMonth" @change="handleMonthChange">
<view class="month-bar">
<text>{{ monthText }}</text>
<text class="month-arrow"></text>
</view>
</picker>
<view v-if="loading" class="empty">加载中...</view>
<view v-else-if="!records.length" class="empty">暂无预约记录</view>
<view v-else class="record-list">
<view v-for="item in records" :key="item._id" class="record-card">
<view class="record-status">{{ statusText(item) }}</view>
<view class="record-row">
<text class="row-label">预约类型</text>
<text class="row-value strong">{{ appointmentTypeText(item) }}</text>
</view>
<view class="record-row">
<text class="row-label">{{ practitionerLabel(item) }}</text>
<text class="row-value strong">{{ practitionerText(item) }}</text>
</view>
<view class="record-row">
<text class="row-label">预约日期</text>
<text class="row-value">{{ appointmentDateText(item) }}</text>
</view>
<view class="record-row">
<text class="row-label">预约时间</text>
<text class="row-value">{{ item.timeRange || "-" }}</text>
</view>
<view class="record-row">
<text class="row-label">预约项目</text>
<text class="row-value">{{ projectText(item) }}</text>
</view>
</view>
</view>
</view>
</full-page>
</template>
<script setup>
import { computed, ref } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import api from "@/utils/api";
import { normalizeCorpId } from "@/utils/api-base-config";
import { toast } from "@/utils/widget";
import FullPage from "@/components/full-page.vue";
const corpId = ref("");
const teamId = ref("");
const customerId = ref("");
const customerName = ref("");
const corpName = ref("");
const selectedMonth = ref(formatMonth(Date.now()));
const records = ref([]);
const staffNameMap = ref({});
const loading = ref(false);
const statusMap = {
pending: { label: "未到院" },
confirmed: { label: "已到院" },
no_show: { label: "爽约" },
};
const avatarText = computed(() => (customerName.value || "档案").slice(0, 1));
const monthText = computed(() => selectedMonth.value.replace("-", "年") + "月");
function pad(value) {
return String(value).padStart(2, "0");
}
function toDate(ts) {
if (!ts) return null;
const d = new Date(Number(ts));
return Number.isNaN(d.getTime()) ? null : d;
}
function formatMonth(ts) {
const d = toDate(ts) || new Date();
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}`;
}
function formatDate(ts) {
const d = toDate(ts);
if (!d) return "";
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
}
function monthRange(month) {
const [year, monthIndex] = String(month || "").split("-").map(Number);
const start = new Date(year, monthIndex - 1, 1);
const end = new Date(year, monthIndex, 0);
return {
start: `${start.getFullYear()}-${pad(start.getMonth() + 1)}-01`,
end: `${end.getFullYear()}-${pad(end.getMonth() + 1)}-${pad(end.getDate())}`,
};
}
function appointmentDateText(item) {
return item?.appointmentDateStr || formatDate(item?.appointmentDate || item?.startTime || item?.registrationTime) || "-";
}
function statusText(item) {
return statusMap[item?.status || "pending"]?.label || "未到院";
}
function appointmentTypeText(item) {
if (item?.appointmentType === "schedule") return item?.scheduleTtile || "排班";
if (item?.appointmentType === "medical") return "复诊预约";
return "治疗预约";
}
function practitionerLabel(item) {
return item?.appointmentType === "medical" ? "医生" : "治疗师";
}
function practitionerText(item) {
const id = item?.therapistUserId || "";
if (item?.therapistName) return item.therapistName;
if (id === "none-therapist" || id === "none-doctor") return "未指定人员";
return staffNameMap.value[id] || id || "未指定人员";
}
function projectText(item) {
const projects = item?.treatmentProject;
if (Array.isArray(projects)) {
const names = projects
.map((project) => {
if (!project) return "";
if (typeof project === "string") return project;
return project.projectName || project.name || project.title || "";
})
.filter(Boolean);
return names.length ? names.join("、") : "无";
}
if (typeof projects === "string" && projects) return projects;
return "无";
}
function switchArchive() {
const corp = encodeURIComponent(corpId.value || "");
const team = encodeURIComponent(teamId.value || "");
const customer = encodeURIComponent(customerId.value || "");
uni.navigateTo({
url: `/pages/experience-coupon/select-rights-archive?mode=target&target=appointment&corpId=${corp}&teamId=${team}&customerId=${customer}`,
});
}
async function loadStaffNameMap() {
if (!corpId.value) {
staffNameMap.value = {};
return;
}
const res = await api("getAllCorpMemberIncludeDeleted", { corpId: corpId.value }, false);
const list = res?.success && Array.isArray(res.data) ? res.data : [];
staffNameMap.value = list.reduce((map, staff) => {
if (staff?.userid) {
map[staff.userid] = staff.anotherName || staff.name || staff.userid;
}
return map;
}, {});
}
async function loadRecords() {
if (!corpId.value || !customerId.value) {
records.value = [];
return;
}
loading.value = true;
try {
const range = monthRange(selectedMonth.value);
const res = await api(
"getAppointmentRegistration",
{
corpId: corpId.value,
customerId: customerId.value,
appointmentDateStart: range.start,
appointmentDateEnd: range.end,
page: 1,
pageSize: 200,
sortBy: "appointmentDate",
sortOrder: "desc",
},
false
);
if (!res?.success) {
toast(res?.message || "加载预约记录失败");
records.value = [];
return;
}
records.value = (Array.isArray(res.data) ? res.data : []).sort((a, b) => {
const aTime = Number(a.appointmentDate || a.startTime || a.registrationTime || 0);
const bTime = Number(b.appointmentDate || b.startTime || b.registrationTime || 0);
return bTime - aTime;
});
} finally {
loading.value = false;
}
}
async function handleMonthChange(event) {
selectedMonth.value = event?.detail?.value || selectedMonth.value;
await loadRecords();
}
onLoad(async (options = {}) => {
uni.setNavigationBarTitle({ title: "预约记录" });
corpId.value = normalizeCorpId(options.corpId || "");
teamId.value = options.teamId || "";
customerId.value = options.customerId || options.id || "";
customerName.value = options.name ? decodeURIComponent(options.name) : "";
corpName.value = options.corpName ? decodeURIComponent(options.corpName) : "";
if (options.month) selectedMonth.value = options.month;
await loadStaffNameMap();
await loadRecords();
});
onShow(() => {
if (corpId.value && customerId.value) loadRecords();
});
</script>
<style scoped>
.page-body {
min-height: 100%;
box-sizing: border-box;
background: #eef1f6;
}
.profile-card {
display: flex;
align-items: center;
gap: 18rpx;
padding: 20rpx 24rpx;
background: #fff;
border-bottom: 1rpx solid #d9dde5;
}
.avatar-wrap {
width: 72rpx;
height: 72rpx;
border-radius: 50%;
background: #d8d8d8;
overflow: hidden;
}
.avatar-placeholder {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 30rpx;
font-weight: 600;
}
.profile-main {
flex: 1;
min-width: 0;
}
.profile-title {
font-size: 30rpx;
font-weight: 600;
color: #333;
line-height: 40rpx;
}
.profile-sub {
margin-top: 4rpx;
font-size: 24rpx;
color: #999;
line-height: 34rpx;
}
.profile-arrow {
flex-shrink: 0;
color: #b4b7bf;
font-size: 32rpx;
}
.month-bar {
display: flex;
align-items: center;
gap: 8rpx;
height: 70rpx;
padding: 0 24rpx;
background: #e2e6ec;
color: #333;
font-size: 30rpx;
font-weight: 600;
border-bottom: 1rpx solid #d5dae3;
}
.month-arrow {
font-size: 18rpx;
color: #333;
}
.record-list {
padding-bottom: 24rpx;
}
.record-card {
position: relative;
padding: 20rpx 24rpx 20rpx 34rpx;
background: #fff;
border-bottom: 1rpx solid #d9dde5;
border-top: 14rpx solid #eef1f6;
}
.record-status {
position: absolute;
top: 22rpx;
right: 24rpx;
color: #333;
font-size: 26rpx;
}
.record-row {
display: flex;
align-items: flex-start;
padding: 7rpx 110rpx 7rpx 0;
font-size: 27rpx;
line-height: 36rpx;
}
.row-label {
flex-shrink: 0;
color: #666;
font-weight: 600;
}
.row-value {
min-width: 0;
color: #333;
word-break: break-all;
}
.strong {
font-weight: 600;
}
.empty {
padding: 120rpx 0;
text-align: center;
font-size: 28rpx;
color: #999;
}
</style>

View File

@ -0,0 +1,209 @@
<template>
<full-page pageClass="record-page" :customScroll="true">
<view class="page-body">
<view class="profile-card">
<view class="profile-title">{{ customerName || "未选择档案" }}</view>
<view class="profile-sub">治疗记录</view>
</view>
<view v-if="loading" class="empty">加载中...</view>
<view v-else-if="!records.length" class="empty">暂无治疗记录</view>
<view v-else class="record-list">
<view v-for="item in records" :key="item._id" class="record-card">
<view class="record-head">
<view class="record-title">{{ item.projectName || "未命名项目" }}</view>
<view class="status-tag" :class="statusClass(item)">{{ statusText(item) }}</view>
</view>
<view class="record-row">
<text class="row-label">治疗科室</text>
<text class="row-value">{{ item.treatmentDeptName || "-" }}</text>
</view>
<view class="record-row">
<text class="row-label">购买数量</text>
<text class="row-value">{{ item.usageCount || 0 }}</text>
</view>
<view class="record-row">
<text class="row-label">剩余数量</text>
<text class="row-value strong">{{ item.restUsageCount || 0 }}</text>
</view>
<view class="record-row">
<text class="row-label">有效期</text>
<text class="row-value">{{ formatValidTime(item.validTime) }}</text>
</view>
<view class="record-row">
<text class="row-label">购买日期</text>
<text class="row-value">{{ formatTime(item.createTreatementTime || item.billTime) }}</text>
</view>
<view v-if="item.packageName" class="record-row">
<text class="row-label">所属套餐</text>
<text class="row-value">{{ item.packageName }}</text>
</view>
</view>
</view>
</view>
</full-page>
</template>
<script setup>
import { ref } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import api from "@/utils/api";
import { normalizeCorpId } from "@/utils/api-base-config";
import { toast } from "@/utils/widget";
import FullPage from "@/components/full-page.vue";
const corpId = ref("");
const customerId = ref("");
const customerName = ref("");
const records = ref([]);
const loading = ref(false);
const statusMap = {
init: { label: "待治疗", className: "status-wait" },
pending: { label: "治疗中", className: "status-doing" },
treated: { label: "已治疗", className: "status-done" },
void: { label: "已作废", className: "status-cancel" },
};
function formatTime(ts) {
if (!ts) return "-";
const d = new Date(Number(ts));
if (Number.isNaN(d.getTime())) return "-";
const y = d.getFullYear();
const m = String(d.getMonth() + 1).padStart(2, "0");
const day = String(d.getDate()).padStart(2, "0");
const h = String(d.getHours()).padStart(2, "0");
const min = String(d.getMinutes()).padStart(2, "0");
return `${y}-${m}-${day} ${h}:${min}`;
}
function formatValidTime(ts) {
if (!ts) return "无限期";
return formatTime(ts).slice(0, 10);
}
function statusText(item) {
return statusMap[item?.treatmentStatus]?.label || item?.treatmentStatusStr || "-";
}
function statusClass(item) {
return statusMap[item?.treatmentStatus]?.className || "status-wait";
}
async function loadRecords() {
if (!corpId.value || !customerId.value) {
records.value = [];
return;
}
loading.value = true;
try {
const res = await api(
"getTreatmentRecord",
{
corpId: corpId.value,
customerId: customerId.value,
page: 1,
pageSize: 200,
},
false
);
if (!res?.success) {
toast(res?.message || "加载治疗记录失败");
records.value = [];
return;
}
records.value = res.list || res.data?.list || [];
} finally {
loading.value = false;
}
}
onLoad(async (options = {}) => {
uni.setNavigationBarTitle({ title: "治疗记录" });
corpId.value = normalizeCorpId(options.corpId || "");
customerId.value = options.customerId || options.id || "";
customerName.value = options.name ? decodeURIComponent(options.name) : "";
await loadRecords();
});
onShow(() => {
if (corpId.value && customerId.value) loadRecords();
});
</script>
<style scoped>
.page-body {
min-height: 100%;
padding: 24rpx;
box-sizing: border-box;
background: #f5f6fa;
}
.profile-card,
.record-card {
background: #fff;
border-radius: 18rpx;
padding: 24rpx;
margin-bottom: 20rpx;
box-shadow: 0 8rpx 24rpx rgba(15, 23, 42, 0.06);
}
.profile-title {
font-size: 34rpx;
font-weight: 600;
color: #1f2329;
}
.profile-sub {
margin-top: 8rpx;
font-size: 24rpx;
color: #8a8f99;
}
.record-head,
.record-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20rpx;
}
.record-head {
margin-bottom: 18rpx;
}
.record-title {
flex: 1;
min-width: 0;
font-size: 32rpx;
font-weight: 600;
color: #1f2329;
}
.status-tag {
flex-shrink: 0;
padding: 6rpx 16rpx;
border-radius: 999rpx;
font-size: 22rpx;
}
.status-wait { color: #065bd6; background: rgba(6, 91, 214, 0.1); }
.status-doing { color: #d97706; background: rgba(217, 119, 6, 0.12); }
.status-done { color: #16a34a; background: rgba(22, 163, 74, 0.12); }
.status-cancel { color: #8a8f99; background: #f1f2f4; }
.record-row {
padding: 10rpx 0;
font-size: 26rpx;
}
.row-label {
flex-shrink: 0;
color: #8a8f99;
}
.row-value {
min-width: 0;
text-align: right;
color: #1f2329;
}
.strong {
color: #065bd6;
font-weight: 600;
}
.empty {
padding: 120rpx 0;
text-align: center;
font-size: 28rpx;
color: #999;
}
</style>

View File

@ -32,6 +32,14 @@ export default [
path: 'pages/experience-coupon/wallet',
meta: { title: '我的卡包', login: true }
},
{
path: 'pages/record/treatment-record',
meta: { title: '治疗记录', login: true }
},
{
path: 'pages/record/appointment-record',
meta: { title: '预约记录', login: true }
},
{
path: 'pages/archive/archive-manage',
meta: { title: '档案管理', login: true }

View File

@ -13,6 +13,7 @@ const urlsConfig = {
bindWxappWithTeam: 'bindWxappWithTeam',
getWxappRelateTeams: 'getWxappRelateTeams',
getTeamMemberAvatarsAndName: "getTeamMemberAvatarsAndName",
getAllCorpMemberIncludeDeleted: "getAllCorpMemberIncludeDeleted",
getMiniAppHomeStats: "getMiniAppHomeStats",
getResponsiblePerson: 'getTeamResponsiblePerson',
relateWxappTeamByExternalUserId: 'relateWxappTeamByExternalUserId'
@ -59,6 +60,8 @@ const urlsConfig = {
getMiniAppCustomers: 'getMiniAppCustomers',
getTeamCustomers: 'getTeamCustomers',
getTreatmentRecord: "getTreatmentRecord",
getAppointmentRecord: "getAppointmentRecord",
getAppointmentRegistration: "getAppointmentRegistration",
getUnbindMiniAppCustomers: 'getUnbindMiniAppCustomers',
getCustomerMedicalRecord: 'getCustomerMedicalRecord',
getMedicalRecordById: 'getMedicalRecordById',