张田田 2 месяцев назад
Родитель
Сommit
37e83d344e

+ 1 - 2
miniprogram/i18n/install.ts

@@ -6,9 +6,8 @@ import { flatRecordKeys } from './tool';
 let cache = null;
 
 export default async function request(url?: string) {
-  let env = 'release';
   try {
-    const { locales } = await Get(url ?? `${Locale_URL}/applet.${env}.json`, { notTransform: true, shareRequest: true });
+    const { locales } = await Get(url ?? `${Locale_URL}/applet.${ENV}.json`, { notTransform: true, shareRequest: true });
     return cache = flatRecordKeys(locales), cache;
   } catch (error) {
     return null;

+ 3 - 2
miniprogram/module/care/pages/cancelAppointment/cancelAppointment.scss

@@ -65,7 +65,8 @@
   left: 0;
   right: 0;
   bottom: 0;
-  padding: 24rpx 32rpx calc(24rpx + env(safe-area-inset-bottom));
+  // padding: 24rpx 32rpx calc(24rpx + env(safe-area-inset-bottom));
+  padding: 24rpx 32rpx calc(env(safe-area-inset-bottom));
   background: #f3f3f3;
   box-sizing: border-box;
 }
@@ -173,7 +174,7 @@
 // 预约信息
 .appointment-info {
   margin-bottom: 50rpx;
-  margin-left: 100rpx;
+  margin-left: 20rpx;
 }
 
 .info-item {

+ 8 - 5
miniprogram/module/care/pages/cancelAppointment/cancelAppointment.ts

@@ -2,11 +2,14 @@ Page({
   data: {
     id: "",
     appointmentInfo: {
-      operateTime: '',
-      operateDuration: '',
-      conditioningProgramSupplierName: '',
-      cpSupplierDetailAddress: '',
-      cpSupplierPhone: '',
+      arrangeTime: '2026-03-13 10:00:00',
+      operateTime: '2026-03-13 10:00:00',
+      arrangeDuration: '60 分钟',
+      conditioningProgramSupplierName: '测试机构',
+      cpSupplierDetailAddress: '测试地址',
+      cpSupplierPhone: '13800138000',
+      pieTime: '2026-03-13 10:00:00',
+      cpSupplierQrCode: 'https://www.baidu.com',
     },
   },
   onLoad(options: any) {

+ 8 - 1
miniprogram/module/care/pages/care/verifyRecord.ts

@@ -102,7 +102,14 @@ Page({
   },
 
   onModifyAppointment() {
-    wx.showToast({ title: "功能开发中", icon: "none" });
+    const arrangeTime =
+      (this.data.appointmentInfo as any).arrangeTime ||
+      (this.data.appointmentInfo as any).appointmentTime ||
+      "";
+
+    wx.navigateTo({
+      url: `/module/order/pages/appointment/appointment?mode=edit&arrangeTime=${encodeURIComponent(arrangeTime)}`,
+    });
   },
 
 });

+ 15 - 10
miniprogram/module/care/pages/offlineTreatment/offlineTreatment.ts

@@ -26,7 +26,19 @@ Page({
   },
   // 跳转到核销记录
   onRecord(e: any) {
-    const id = e.currentTarget.dataset.id;
+    console.log(e.currentTarget.dataset.item, "e===");
+    
+    const { item } = e.currentTarget.dataset;
+    const { id, offlineId, conditioningProgramName, offlineDuration, itemImgSecond, estimatedStartDate } = item;
+    const goodsInfo = {
+      name: conditioningProgramName || '',
+      duration: offlineDuration || 0,
+      image: itemImgSecond || '',
+      offlineId: offlineId || '',
+      serviceTime: estimatedStartDate || '',
+    }
+    wx.setStorageSync('goodsInfo', JSON.stringify(goodsInfo));
+    console.log(goodsInfo, "goodsInfo===核销记录页面");
     if (id) {
       wx.navigateTo({
         url: `/module/care/pages/care/verifyRecord?id=${id}`,
@@ -45,11 +57,11 @@ Page({
       offlineId: offlineId || '',
       serviceTime: estimatedStartDate || '',
     }
-    console.log(goodsInfo, "goodsInfo======去预约页面")
     if (offlineId) {
+      wx.setStorageSync('goodsInfo', JSON.stringify(goodsInfo));
       // 去预约页面
       wx.navigateTo({
-        url: `/module/order/pages/appointment/appointment?goodsInfo=${JSON.stringify(goodsInfo)}`,
+        url: `/module/order/pages/appointment/appointment`,
       });
     } else {
       wx.showToast({
@@ -63,21 +75,15 @@ Page({
     this.setData({
       currentTab: progress,
     });
-    // 不立即清空数据,避免空状态闪烁
     this.getOfflineTreatmentList(progress);
   },
   // 获取线下非药物治疗记录列表
   async getOfflineTreatmentList(progress: string) {
-    // 启用加载态,保留当前列表,避免空态闪烁
     this.setData({ isLoading: true });
     try {
       const res = await getOfflineTreatmentListMethod(progress);
-      console.log(res.data, "res.data")
-      // 确保 res.data 是数组,避免 undefined 或 null 导致的错误
       const list = Array.isArray(res?.data) ? res.data : [];
-      // 如果传入了treatmentId,标记匹配的项目为高亮并置顶
       const treatmentId = this.data.treatmentId;
-      console.log(treatmentId, "treatmentId")
       console.log(list, "list")
       if (treatmentId && list.length > 0) {
         const highlightedList = list.map((item: any) => ({
@@ -98,7 +104,6 @@ Page({
     } catch (error: any) {
 
       console.error('获取数据失败:', error);
-      // 只有在真正出错时才显示错误提示
       wx.showToast({
         title: error.errMsg || "获取数据失败",
         icon: "none",

+ 2 - 1
miniprogram/module/care/pages/offlineTreatment/offlineTreatment.wxml

@@ -10,9 +10,10 @@
     </view>
    <view wx:elif="{{treatmentList.length>0}}">
       <block wx:for="{{treatmentList}}" wx:key="id">
-        <view class="treatment-detail-card {{item.isHighlighted ? 'treatment-detail-card--highlighted' : ''}}" bindtap="onRecord" data-id="{{item.id}}">
+        <view class="treatment-detail-card {{item.isHighlighted ? 'treatment-detail-card--highlighted' : ''}}" bindtap="onRecord" data-item="{{item}}">
           <view>
             <view class="row between" wx:if="{{item.conditioningProgramName}}">
+
               <text class="label bold">项目:{{item.conditioningProgramName}}</text>
             </view>
             <view class="row" wx:if="{{item.operateBy}}">

+ 102 - 8
miniprogram/module/order/pages/appointment/appointment.ts

@@ -23,17 +23,59 @@ Page({
     show: false,
     date: '',
     offlineId: "",
+    // 是否为修改预约模式,以及原始预约时间(用于高亮和对比是否有改动)
+    isEditMode: false,
+    originalAppointmentTime: "",
   },
   onLoad(options: any) {
-    // 初始化日期列表(从今天开始5天)
-    this.initDateList();
-    if (options.goodsInfo) {
-      const goodsInfo = JSON.parse(options.goodsInfo);
+    console.log(options, "options===");
+    const goodsInfoFromStorage = wx.getStorageSync('goodsInfo');
+    console.log(goodsInfoFromStorage, "goodsInfo===from storage");
+
+    let parsedGoodsInfo: any = null;
+    if ( goodsInfoFromStorage) {
+      try {
+        parsedGoodsInfo = JSON.parse(goodsInfoFromStorage || '{}');
+        console.log(parsedGoodsInfo, "parsedGoodsInfo===");
+      } catch (e) {
+        console.error("解析 goodsInfo 失败", e);
+      }
+    }
+
+    const originalAppointmentTime =
+      (options.arrangeTime && decodeURIComponent(options.arrangeTime)) ||
+      parsedGoodsInfo?.arrangeTime ||
+      parsedGoodsInfo?.appointmentTime ||
+      "";
+    const isEditMode = options.mode === "edit" || !!originalAppointmentTime;
+
+    // 如果有原始预约时间,则围绕该日期初始化列表;否则从今天开始 5 天
+    if (originalAppointmentTime) {
+      const [datePart] = originalAppointmentTime.split(" ");
+      const baseDate = datePart ? new Date(datePart) : new Date();
+      this.initDateList(baseDate);
+    } else {
+      this.initDateList();
+    }
+
+    if (parsedGoodsInfo) {
+      this.setData({
+        goodsInfo: parsedGoodsInfo,
+        offlineId: parsedGoodsInfo.offlineId || "",
+        isEditMode,
+        originalAppointmentTime,
+      });
+    } else {
       this.setData({
-        goodsInfo: goodsInfo,
-        offlineId: goodsInfo.offlineId,
+        isEditMode,
+        originalAppointmentTime,
       });
     }
+
+    // 修改预约场景:根据原始预约时间高亮默认选中项
+    if (originalAppointmentTime) {
+      this.highlightOriginalAppointmentTime(originalAppointmentTime);
+    }
   },
   // 初始化日期列表
   initDateList(startDate?: Date) {
@@ -89,7 +131,8 @@ Page({
     this.initTimeSlots(dateList[0].date);
   },
   // 初始化时间列表 - 固定8:00-20:00
-  initTimeSlots(selectedDate?: string) {
+  // 可选传入 preSelectedTime,在初始化时高亮该时间段
+  initTimeSlots(selectedDate?: string, preSelectedTime?: string) {
     const timeSlots: Array<{
       time: string;
       isSelected: boolean;
@@ -123,7 +166,7 @@ Page({
 
         timeSlots.push({
           time: timeStr,
-          isSelected: false,
+          isSelected: preSelectedTime ? timeStr === preSelectedTime : false,
           isDisabled,
         });
       }
@@ -131,6 +174,37 @@ Page({
 
     this.setData({ timeSlots });
   },
+  // 根据原始预约时间高亮日期和时间
+  highlightOriginalAppointmentTime(appointmentTime: string) {
+    if (!appointmentTime) return;
+    const [rawDatePart, rawTimePart] = appointmentTime.split(" ");
+    if (!rawDatePart || !rawTimePart) return;
+
+    // 兼容不同格式:2025-03-13 / 2025/03/13 以及带秒的时间 14:30:00
+    const datePart = rawDatePart.replace(/\//g, "-").substring(0, 10);
+    const timePart = rawTimePart.substring(0, 5); // 只取 HH:mm
+
+    // 高亮日期
+    const dateList = this.data.dateList.map((item) => ({
+      ...item,
+      isSelected: item.date === datePart,
+    }));
+
+    // 如果当前 5 天中没有该日期,则直接返回(保持已有逻辑);更复杂的滚动可后续再优化
+    const hasTargetDate = dateList.some((item) => item.isSelected);
+    if (!hasTargetDate) {
+      return;
+    }
+
+    this.setData({
+      dateList,
+      selectedDate: datePart,
+      selectedTime: timePart,
+    });
+
+    // 按该日期重新初始化时间段,并选中对应时间
+    this.initTimeSlots(datePart, timePart);
+  },
   // 选择日期
   onDateSelect(e: any) {
     const index = e.currentTarget.dataset.index;
@@ -194,6 +268,26 @@ Page({
 
     const appointmentTime = `${this.data.selectedDate} ${this.data.selectedTime}`;
     console.log(appointmentTime, "appointmentTime");
+
+    // 归一化原始预约时间为 "YYYY-MM-DD HH:mm" 用于对比
+    let normalizedOriginal = "";
+    if (this.data.originalAppointmentTime) {
+      const [rawDatePart, rawTimePart] = this.data.originalAppointmentTime.split(" ");
+      if (rawDatePart && rawTimePart) {
+        const datePart = rawDatePart.replace(/\//g, "-").substring(0, 10);
+        const timePart = rawTimePart.substring(0, 5); // HH:mm
+        normalizedOriginal = `${datePart} ${timePart}`;
+      }
+    }
+
+    // 修改预约模式下,如果时间未变化,则提示修改失败,不调接口
+    if (this.data.isEditMode && normalizedOriginal && appointmentTime === normalizedOriginal) {
+      wx.showToast({
+        title: "预约时间未修改",
+        icon: "none",
+      });
+      return;
+    }
     console.log(this.data.offlineId, "this.data.offlineId");
     this.setData({
       goodsInfo: {