Browse Source

minsudingdan page

邹能昇 4 months ago
parent
commit
4a31e01e8a
2 changed files with 36 additions and 29 deletions
  1. 33 26
      nova-tourism/pages/my/my-order/index.js
  2. 3 3
      nova-tourism/pages/my/my-order/index.wxml

+ 33 - 26
nova-tourism/pages/my/my-order/index.js

@@ -13,14 +13,19 @@ Page({
         bottomNavHeight: 0,
         contentHeight: 0,
 
-        active:0,
-
-        option: [
-            { text: '民宿订单', value: '民宿' },
-            { text: '物品订单', value: '物品' },
-          ],
-          value:'民宿',
-          roomList:[],
+        active: 0,
+
+        option: [{
+                text: '民宿订单',
+                value: '民宿'
+            },
+            {
+                text: '物品订单',
+                value: '物品'
+            },
+        ],
+        value: '民宿',
+        roomList: [],
     },
 
     /**
@@ -28,7 +33,7 @@ Page({
      */
     onLoad: function (options) {
         this.setData({
-            active:Number(options.active)
+            active: Number(options.active)
         })
 
         const systemInfo = wx.getSystemInfoSync();
@@ -38,7 +43,7 @@ Page({
         const customHeight = custom.height + 10 + 2 || 0;
         const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
 
-        const contentHeight = (screenHeight - bottomNavHeight  - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
+        const contentHeight = (screenHeight - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
         this.setData({
             statusBarHeight,
             screenHeight,
@@ -49,29 +54,29 @@ Page({
         this.getRoomOrder()
     },
     //改变民宿或物品
-    change(e){
+    change(e) {
         console.log(this.data.value);
         this.setData({
-            active:0
+            active: 0
         })
-        if(this.data.value=='民宿'){
+        if (this.data.value == '民宿') {
             this.getRoomOrder()
-        }else{
+        } else {
 
         }
     },
     //改变订单状态
-    onChange(event){
+    onChange(event) {
         let active = event.detail.name;
         this.setData({
-          active: active
+            active: active
         });
-        if(this.data.value=='民宿'){
+        if (this.data.value == '民宿') {
             this.getRoomOrder()
-        }else{
+        } else {
 
         }
-        console.log(this.data.active,this.data.value);
+        console.log(this.data.active, this.data.value);
     },
     formatDate2(date1, date2) {
         date1 = new Date(date1);
@@ -89,31 +94,33 @@ Page({
         // 返回格式化的字符串
         return `${year1}年${month1}月${day1}日入住 - ${year2}年${month2}月${day2}日离店`;
     },
-    async getRoomOrder(){
+    async getRoomOrder() {
         let Order = new Parse.Query('RoomOrder');
         Order.equalTo('company', company);
         Order.include('room');
         Order.equalTo('user', Parse.User.current().id);
         Order.include('shopStore');
         if (this.data.active == 0) {
-          Order.equalTo('status', 100);
+            Order.equalTo('status', 100);
         }
         if (this.data.active == 1) {
-          Order.equalTo('status', 200);
+            Order.equalTo('status', 200);
         }
         if (this.data.active == 2) {
-          console.log(this.data.active);
-          Order.equalTo('status', 800);
+            console.log(this.data.active);
+            Order.equalTo('status', 800);
         }
+        // 添加排序条件
+        Order.descending('updatedAt');
         let room = await Order.find();
         let roomList = room.map(async item => {
             let roomItme = item.toJSON();
-            roomItme.tiem = await this.formatDate2(roomItme.startTime.iso,roomItme.endTime.iso)
+            roomItme.tiem = await this.formatDate2(roomItme.startTime.iso, roomItme.endTime.iso)
             return roomItme
         });
         let roomList2 = await Promise.all(roomList);
         this.setData({
-            roomList:roomList2
+            roomList: roomList2
         })
         console.log(this.data.roomList);
     },

+ 3 - 3
nova-tourism/pages/my/my-order/index.wxml

@@ -55,7 +55,7 @@
                     </view>
                 </view>
             </block>
-
+            <van-empty wx:if="{{value=='民宿'&&roomList.length==0}}" description="暂无订单" />
         </van-tab>
 
         <van-tab title="进行中">
@@ -104,7 +104,7 @@
                     </view>
                 </view>
             </block>
-
+            <van-empty wx:if="{{value=='民宿'&&roomList.length==0}}" description="暂无订单" />
         </van-tab>
 
         <van-tab title="已完成">
@@ -153,7 +153,7 @@
                     </view>
                 </view>
             </block>
-
+            <van-empty wx:if="{{value=='民宿'&&roomList.length==0}}" description="暂无订单" />
         </van-tab>
     </van-tabs>
     <!-- 望仙礼遇 -->