浏览代码

继续对接接口

任一存 2 年之前
父节点
当前提交
44c0f45623

+ 24 - 20
yfyc/src/api/serveAndMy.js

@@ -1,15 +1,22 @@
 import axios from '../utils/request'
 
+// 查询剩余名额
+export function getRemainingNumber(data) {
+  return axios({
+    method: 'post',
+    url: 'cms/book/residueNum',
+    data,
+  })
+}
+
 // 提交预约
 export function submitBooking(data) {
-  // return axios({
-  //   method: 'post',
-  //   url: 'http://192.168.20.55:8037/api/cms/book/save',
-  //   // url: 'api/cms/book/save',
-  //   data,
-  // })
+  return axios({
+    method: 'post',
+    url: 'cms/book/save',
+    data,
+  })
   return Promise.resolve({
-    data: {
       code: 0,
       data: {
         "buildId": 1,
@@ -26,7 +33,6 @@ export function submitBooking(data) {
         "timeStr": "AM",
         "updateTime": "2022-11-28 17:39:28"
       }
-    }
   })
 }
 
@@ -34,22 +40,21 @@ export function submitBooking(data) {
 export function cancelBooking(id) {
   return axios({
     method: 'get',
-    url: `api/cms/book/cancel/${id}`,
+    url: `cms/book/cancel/${id}`,
   })
 }
 
 // 预约列表
 export function getBookingList() {
-  // return axios({
-  //   method: 'post',
-  //   url: 'api/cms/book/listPage',
-  //   data: {
-  //     pageNum: 1,
-  //     pageSize: 200
-  //   }
-  // })
-  return Promise.resolve({
+  return axios({
+    method: 'post',
+    url: 'cms/book/listPage',
     data: {
+      pageNum: 1,
+      pageSize: 200
+    }
+  })
+  return Promise.resolve({
       code: 0,
       data: {
         "countId": "",
@@ -124,7 +129,6 @@ export function getBookingList() {
         "size": 100,
         "total": 4
       }
-    }
   })
 }
 
@@ -132,6 +136,6 @@ export function getBookingList() {
 export function getBookingDetail(id) {
   return axios({
     method: 'get',
-    url: `api/cms/book/detail/${id}`
+    url: `cms/book/detail/${id}`
   })
 }

+ 1 - 1
yfyc/src/components/BookingSuccess.vue

@@ -11,7 +11,7 @@
         <img class="icon" src="@/assets/img/service/date.png" alt="" draggable="false">
         <div class="text">
           <span class="key">预约日期:</span>
-          <span class="value">{{`${bookingInfo.day} ${bookingInfo.weekDay}`}}</span>
+          <span class="value">{{`${bookingInfo.day} ${globalUtils.dateToWeekday(bookingInfo.day)}`}}</span>
           </div>
       </div>
       <div class="line">

+ 14 - 0
yfyc/src/utils/index.js

@@ -125,10 +125,24 @@ export async function loginOnNeed() {
     location.href = 'https://yifangyice.4dage.com/web/index.html' + location.hash
   }
 }
+const number2String = [
+  '周日',
+  '周一',
+  '周二',
+  '周三',
+  '周四',
+  '周五',
+  '周六',
+]
+export function dateToWeekday(dateStr = '2022-11-29') {
+  const date = new Date(dateStr)
+  return number2String[date.getDay()]
+}
 
 export default {
   debounce,
   getUserCode,
   checkLoginStatus,
   loginOnNeed,
+  dateToWeekday,
 }

+ 3 - 3
yfyc/src/views/My/MyBookings.vue

@@ -27,7 +27,7 @@
             <img class="icon" src="@/assets/img/service/date.png" alt="" draggable="false">
             <div class="text">
               <span class="key">参观日期:</span>
-              <span class="value">{{item.day}}</span>
+              <span class="value">{{`${item.day} ${globalUtils.dateToWeekday(item.day)}`}}</span>
             </div>
           </div>
           <div class="line">
@@ -127,7 +127,7 @@ export default {
       cancelBooking(id).then(() => {
         Toast('操作成功')
         getBookingList().then((res) => {
-          this.bookingListRaw = res.data.data.records
+          this.bookingListRaw = res.data.records
         })
       })
     }
@@ -135,7 +135,7 @@ export default {
   mounted() {
     globalUtils.loginOnNeed()
     getBookingList().then((res) => {
-      this.bookingListRaw = res.data.data.records
+      this.bookingListRaw = res.data.records
     })
   }
 }

+ 24 - 7
yfyc/src/views/Serve/Booking.vue

@@ -28,7 +28,7 @@
               @click="handleClickTime(index)"
             >
               <span>{{item.time}}</span><br>
-              <span>{{item.remain ? `剩余${item.remain}` : `已结束`}}</span>
+              <span>{{item.remain !== null ? `剩余${item.remain}` : ``}}</span>
             </button>
           </div>
         </div>
@@ -87,7 +87,7 @@
 <script>
 import Swiper from "../../assets/libs/swiper.js";
 import BookingSuccess from "@/components/BookingSuccess.vue";
-import { submitBooking } from "@/api/serveAndMy.js";
+import { submitBooking, getRemainingNumber } from "@/api/serveAndMy.js";
 
 const weekDayList = [
   '周一',
@@ -113,15 +113,15 @@ export default {
       timeList: [
         {
           time: '8:30-12:00',
-          remain: 100,
+          remain: null,
         },
         {
           time: '12:00-18:30',
-          remain: 100,
+          remain: null,
         },
       ],
       timeIdx: null,
-      name: ',',
+      name: '',
       idCard: '',
       phone: '',
       age: '',
@@ -156,6 +156,23 @@ export default {
     this.month = (today.getMonth() + 1).toString().padStart(2, '0')
     this.day = today.getDate().toString().padStart(2, '0')
     this.weekDay = weekDayList[today.getDay() + 1]
+
+    getRemainingNumber({
+      buildId: this.attractionId,
+      day: `${this.year}-${this.month}-${this.day}`,
+      timeStr: 'AM',
+    }).then((res) => {
+      console.log(res);
+      this.timeList[0].remain = res.data
+    })
+    getRemainingNumber({
+      buildId: this.attractionId,
+      day: `${this.year}-${this.month}-${this.day}`,
+      timeStr: 'PM',
+    }).then((res) => {
+      console.log(res);
+      this.timeList[1].remain = res.data
+    })
   },
   methods: {
     onConfirmDate(date) {
@@ -177,8 +194,8 @@ export default {
         "phone": this.phone,
         "timeStr": this.timeIdx === 0 ? 'AM' : this.timeIdx === 1 ? 'PM' : undefined,
       }).then((res) => {
-        if (res.data.code === 0) {
-          this.bookingRes = res.data.data
+        if (res.code === 0) {
+          this.bookingRes = res.data
           this.isShowSuccess = true
         }
       })