Przeglądaj źródła

新增我的预约功能

wangfumin 2 miesięcy temu
rodzic
commit
681c46cb6f

+ 0 - 9
pages/user/feedback/index.js

@@ -7,7 +7,6 @@ Page({
       content: '',
       name: '',
       email: '',
-      captcha: '',
       feedbackId: 0
     }
   },
@@ -44,13 +43,6 @@ Page({
     });
   },
 
-  // 验证码输入
-  onCaptchaInput(e) {
-    this.setData({
-      'formData.captcha': e.detail.value
-    });
-  },
-
   // 验证表单
   validateForm() {
     const { title, content, name, email } = this.data.formData;
@@ -133,7 +125,6 @@ Page({
             content: '',
             name: '',
             email: '',
-            captcha: '',
             feedbackId: 0
           }
         });

+ 2 - 2
pages/user/feedback/index.wxml

@@ -27,13 +27,13 @@
     </view>
     
     <!-- 验证码 -->
-    <view class="form-item captcha-item">
+    <!-- <view class="form-item captcha-item">
       <view class="form-label">验证码</view>
       <view class="captcha-container">
         <input class="captcha-input" placeholder="请输入验证码" value="{{formData.captcha}}" bindinput="onCaptchaInput" />
         <view class="captcha-code">UW6</view>
       </view>
-    </view>
+    </view> -->
   </view>
   
   <!-- 提交按钮 -->

+ 1 - 0
pages/user/index.wxss

@@ -3,6 +3,7 @@ page {
   height: 100vh;
   display: flex;
   flex-direction: column;
+  background-image: url('https://swkz-1332577016.cos.ap-guangzhou.myqcloud.com/karamay/bg.png');
 }
 .user-container{
   height: 100%;

+ 28 - 13
pages/user/my-preview/index.js

@@ -155,7 +155,7 @@ Page({
         type: item.type === 1 ? 'normal' : 'activity', // 1-参观,2-活动
         date: this.formatDate(item.appointmentTime),
         time: item.time || '',
-        activityName: item.activityId || '',
+        activityName: item.activityTitle || '',
         status: item.status,
         visitors: item.visitors || [],
         isExpired: isExpired
@@ -197,24 +197,39 @@ Page({
    * 执行取消预约操作
    */
   performCancelReservation(reservationId) {
-    // 模拟API调用
     wx.showLoading({
       title: '取消中...'
     });
     
-    setTimeout(() => {
+    museumApi.cancelReservation(reservationId).then(res => {
       wx.hideLoading();
-      
-      // 从列表中移除已取消的预约
-      const reservations = this.data.reservations.filter(item => item.id !== reservationId);
-      this.setData({
-        reservations
-      });
-      
+      console.log('取消预约结果:', res);
+      if (res) {
+        wx.showToast({
+          title: '取消成功',
+          icon: 'success'
+        });
+        
+        // 重新获取列表数据
+        this.setData({
+          reservations: [],
+          pageNum: 1,
+          hasMore: true
+        });
+        this.loadReservations();
+      } else {
+        wx.showToast({
+          title: res.message || '取消失败',
+          icon: 'none'
+        });
+      }
+    }).catch(error => {
+      wx.hideLoading();
+      console.error('取消预约失败:', error);
       wx.showToast({
-        title: '取消成功',
-        icon: 'success'
+        title: '网络错误,请重试',
+        icon: 'none'
       });
-    }, 1000);
+    });
   }
 })

+ 4 - 1
pages/user/my-preview/index.wxml

@@ -22,12 +22,15 @@
         </view>
         
         <!-- 取消按钮 (仅普通预约且未过期显示) -->
-        <view wx:if="{{!item.isExpired}}" class="cancel-btn" bindtap="cancelReservation" data-id="{{item.id}}">
+        <view wx:if="{{!item.isExpired && item.status !== -1}}" class="cancel-btn" bindtap="cancelReservation" data-id="{{item.id}}">
           <text>取消</text>
         </view>
         
         <!-- 印章图标 (活动预约或已过期的普通预约显示) -->
         <view wx:if="{{item.isExpired}}" class="stamp-icon">
+          <image src="https://swkz-1332577016.cos.ap-guangzhou.myqcloud.com/imgs/icon_end.png" mode="aspectFit"></image>
+        </view>
+        <view wx:if="{{item.status == -1}}" class="stamp-icon">
           <image src="https://swkz-1332577016.cos.ap-guangzhou.myqcloud.com/imgs/icon_cancel.png" mode="aspectFit"></image>
         </view>
       </view>

+ 1 - 1
pages/user/my-preview/index.wxss

@@ -107,7 +107,7 @@
   top: 240rpx;
   z-index: 1;
   padding: 0 40rpx 20rpx;
-  max-height: 600rpx;
+  max-height: 440rpx;
   overflow-y: auto;
 }
 

+ 9 - 0
utils/api.js

@@ -312,6 +312,15 @@ const museumApi = {
       data: params,
       useToken: true
     });
+  },
+
+  // 取消预约
+  cancelReservation(id) {
+    return request({
+      url: `/museum/appointment/cancel/${id}`,
+      method: 'POST',
+      useToken: true
+    });
   }
 };