Преглед изворни кода

fix:订单生成跟订单页面的bug

sunshine1130 пре 4 година
родитељ
комит
f82ff62f0b

+ 5 - 0
api/order.js

@@ -17,6 +17,11 @@ class order extends request {
         return res.data
     }
 
+    
+    static async createOrder(data) {
+        const res = await this.postRequest(`${this.BASE_URL}Order/createOrder`,data)
+        return res.data
+    }
 
 }
 

+ 29 - 20
pages/appointment/appointment.js

@@ -2,6 +2,8 @@ const app = getApp();
 import productApi from '../../api/product'
 import storeApi from '../../api/store'
 import createTimeApi from '../../utils/date'
+import orderApi from '../../api/order'
+import until from '../../utils/util'
 Page({
 
   /**
@@ -12,7 +14,7 @@ Page({
     activeTab: 0,
     shopInfo: {},
     shopId: 0,
-    storeName:'',
+    storeName: '',
     productId: 0,
     productImg: '',
     productName: '',
@@ -21,6 +23,7 @@ Page({
     orderTime: "",
     orderTimeHeight: 0,
     days: [],
+    hasMobile: false
 
 
   },
@@ -46,15 +49,28 @@ Page({
 
   },
   checkAuth: async function () {
-    console.log(this)
+    const self = this
     const isAuth = await app.isAuth()
     if (!isAuth) {
       wx.redirectTo({
         url: '/pages/prompt/prompt?page=' + this.route,
       })
     }
-  },
+    console.log(self.productInfo)
+    let data = {
+      productId: self.data.productId,
+      storeId: self.data.shopId,
+      appointmentTime: self.data.orderTime,
+      num: self.data.peopleNum,
+      mobile: 15656942279
+    }
+    const rs = await orderApi.createOrder(data)
+   
 
+  },
+  getMobile:function (params) {
+    
+  },
 
   onSlideChangeEnd: function (e) {
     var that = this;
@@ -62,7 +78,8 @@ Page({
       activeTab: e.detail.index
     })
   },
- 
+
+  //生成当前可预约的时间
   createTimeList: async function () {
     var storeId = this.data.shopId;
     var price = this.data.price;
@@ -71,22 +88,19 @@ Page({
     var closeTime = shopInfo.info.closeTime;
     var date = await storeApi.getStoreAppointTime(storeId);
     var days = date.date;
-    console.log(days) 
+    console.log(days)
     const tabs = createTimeApi.createTimeList(openTime, closeTime, days, price);
     console.log(tabs)
     this.setData({
-      storeName:shopInfo.info.storeName,
+      storeName: shopInfo.info.storeName,
       days,
       tabs
     })
   },
 
- 
+
 
   getOrderTime: function (e) {
-    // var date = document.getElementById("orderDate");
-    // console.log(date.target)
-    // console.log(e.currentTarget)
     //选中日期的下标
     var i = this.data.activeTab;
     //选中时间的下标
@@ -94,7 +108,9 @@ Page({
     //获取选中的日期
     var date = this.data.days[i];
     var time = e.currentTarget.dataset.time;
-    var oTime = date + '/' + time;
+    var year = (new Date()).getFullYear()
+
+    var oTime = year + '-' + date + ' ' + time;
 
     //设置选中的样式
     var tabs = this.data.tabs;
@@ -134,7 +150,7 @@ Page({
     })
   },
 
-
+  
 
   /**
    * 生命周期函数--监听页面初次渲染完成
@@ -185,12 +201,5 @@ Page({
   onShareAppMessage: function () {
 
   },
-   //动态生成产品的父盒子高度
- /*   getOrderHeight: function () {
-    var activeTab = this.data.activeTab;
-    var orderTimeHeight = (this.data.tabs[activeTab].list.length) / 5 * 130;
-    this.setData({
-      orderTimeHeight
-    })
-  }, */
+
 })

+ 54 - 22
pages/appointment/appointment.scss

@@ -2,12 +2,15 @@
     width: 100%;
     height: 100%;
     background-color: #F7F7F7;
-    .product-img{
+
+    .product-img {
         width: 100%;
-        >image{
+
+        >image {
             width: 100%;
         }
     }
+
     .product-title,
     .shop-name {
         width: 100%;
@@ -18,7 +21,7 @@
         line-height: 90rpx;
     }
 
-    .people-num{
+    .people-num {
         display: flex;
         justify-content: space-between;
         height: 90rpx;
@@ -27,22 +30,26 @@
         align-items: center;
         margin-bottom: 10rpx;
         padding-left: 20rpx;
-        .num-box{
-            width:250rpx ;
+
+        .num-box {
+            width: 250rpx;
             display: flex;
             justify-content: space-around;
-            >view{
+
+            >view {
                 width: 40rpx;
                 height: 40rpx;
                 margin: 5rpx 0;
                 background-color: #fff;
-                >image{
+
+                >image {
                     width: 30rpx;
                     height: 30rpx;
                     margin-left: 10rpx;
                 }
             }
-            .num-text{
+
+            .num-text {
                 width: 50rpx;
                 height: 90rpx;
                 line-height: 90rpx;
@@ -51,16 +58,17 @@
         }
     }
 
-    .order-time{
+    .order-time {
         background-color: #fff;
         margin-bottom: 20rpx;
         padding-bottom: 20rpx;
         display: flex;
         justify-content: flex-start;
         position: relative;
+
         .weui-tabs {
             width: 100%;
-            
+
             .weui-tabs-bar__wrp {
                 .weui-tabs-bar__content {
                     height: 95rpx;
@@ -69,10 +77,10 @@
                     display: flex;
                     justify-content: space-around;
                     border-bottom: 1rpx solid #ECECEC;
-    
+
                     .weui-tabs-bar__item {
                         width: 14.2857%;
-    
+
                         .weui-tabs-bar__title {
                             width: 100rpx;
                             text-align: center;
@@ -80,20 +88,23 @@
                             font-size: 13px;
                         }
                     }
-    
+
                 }
             }
-            .weui-tabs-swiper{
+
+            .weui-tabs-swiper {
                 height: 800rpx;
             }
         }
-        .tab-content{
-            .orders{
+
+        .tab-content {
+            .orders {
                 display: flex;
                 flex-wrap: wrap;
                 background-color: #fff;
                 margin: 10rpx 15rpx 0;
-                .time-info{
+
+                .time-info {
                     width: 20%;
                     height: 110rpx;
                     line-height: 50rpx;
@@ -101,18 +112,38 @@
                     margin: 10rpx 0;
                     text-align: center;
                 }
-                .select-time{
+
+                .select-time {
                     background-color: #DF3361;
-                    color:#fff
+                    color: #fff
                 }
-                .out-time{
-                    color:#acacac;
+
+                .out-time {
+                    color: #acacac;
                 }
             }
         }
     }
 
-   
+    .product-mobile {
+        background-color: #fff;
+        width: 100%;
+        height: 100rpx;
+        position: relative;
+        >button {
+            background-color: rgba(0, 0, 0, 0);
+            color: #202020;
+            font-weight: 400;
+            height: 100rpx;
+            line-height: 100rpx;
+            padding: 0;
+            /* margin: 0; */
+            position: absolute;
+            left: -40rpx;
+            top: 0;
+        }
+    }
+
     .appointment {
         width: 90%;
         height: 100rpx;
@@ -135,4 +166,5 @@
         color: rgb(54, 54, 54);
     }
 
+
 }

+ 6 - 3
pages/appointment/appointment.wxml

@@ -3,6 +3,7 @@
         <image src="{{productImg}}"></image>
     </view>
     <view class="product-title card f17">{{productName}}</view>
+
     <!-- <view class="shop-name card f17">门店·{{storeName}}</view> -->
     <view class="people-num card">
         <view class="title">选择人数</view>
@@ -31,7 +32,7 @@
                     style="height: {{(tabs[activeTab].list.length)/5*140}}rpx;">
                     <view class="orders" style="height: {{(tabs[activeTab].list.length)/5*140}}rpx;overflow-y: auto;">
                         <block wx:for="{{tabs[activeTab].list}}" wx:for-index="index" wx:key="id">
-                           
+
                             <view
                                 class="time-info {{item.checked&&item.inTime?'select-time':''}}  {{item.inTime?'':'out-time'}}"
                                 data-time="{{item.time}}" data-i="{{index}}" bindtap="getOrderTime">
@@ -46,11 +47,13 @@
         </mp-tabs>
 
     </view>
-    <navigator class="appointment card" url="" hover-class="appointment-hover" open-type="navigate">
+    <view class="product-mobile card f17"><button type="primary" wx:if="{{!hasMobile}}" bindtap = "getMobile">点击获取手机号</button></view>
+
+    <view class="appointment card" url="" hover-class="appointment-hover" open-type="navigate">
         <view class="btn" bindtap="checkAuth">
             确认预约
         </view>
-    </navigator>
+    </view>
 
 
 </view>

+ 20 - 0
pages/appointment/appointment.wxss

@@ -121,6 +121,26 @@
   color: #acacac;
 }
 
+.container .product-mobile {
+  background-color: #fff;
+  width: 100%;
+  height: 100rpx;
+  position: relative;
+}
+
+.container .product-mobile > button {
+  background-color: transparent;
+  color: #202020;
+  font-weight: 400;
+  height: 100rpx;
+  line-height: 100rpx;
+  padding: 0;
+  /* margin: 0; */
+  position: absolute;
+  left: -40rpx;
+  top: 0;
+}
+
 .container .appointment {
   width: 90%;
   height: 100rpx;

+ 4 - 6
pages/personorder/personorder.js

@@ -161,15 +161,13 @@ Page({
     var orderId = e.currentTarget.dataset.orderid;
     var status = e.currentTarget.dataset.status;
     var writeStatus = e.currentTarget.dataset.writestatus;
-    wx.navigateTo({
-      url: '/pages/order/order?id=' + orderId,
-    })
-    /*  if(status==2&&writeStatus==1){
+   
+     if(status==2&&writeStatus==1){
        wx.navigateTo({
-         url: 'pages/order/order?orderId='+orderId,
+         url: '../order/order?orderId='+orderId,
        })
        return
-     } */
+     }
 
   },
   /**

+ 33 - 15
pages/personorder/personorder.scss

@@ -7,13 +7,14 @@
 
     .weui-tabs {
         .weui-tabs-bar__wrp {
+            position: relative;
+
             .weui-tabs-bar__content {
                 height: 95rpx;
-                line-height: 94rpx;
+                line-height: 92rpx;
                 white-space: nowrap;
                 display: flex;
                 justify-content: space-around;
-                border-bottom: 1rpx solid #ECECEC;
 
                 .weui-tabs-bar__item {
                     width: 100rpx;
@@ -26,24 +27,36 @@
                 }
 
             }
+
+            &::before {
+                content: "";
+                position: absolute;
+                width: 100%;
+                height: 1rpx;
+                background-color: #ECECEC;
+                bottom: -2rpx;
+                left: 0;
+            }
         }
     }
 
     .orders {
         margin-top: 20rpx;
+
         .orderinfo {
             margin: 0 20rpx 20rpx;
-          
+
 
             .order-item {
                 display: flex;
                 justify-content: flex-start;
                 position: relative;
                 border-bottom: 1px solid #ebeef5;
+
                 .order-img {
                     width: 210rpx;
                     height: 200rpx;
-                    margin: 15rpx 15rpx;
+                    margin: 55rpx 20rpx 0 20rpx;
 
                     image {
                         width: 210rpx;
@@ -54,6 +67,7 @@
                 .order-desc {
                     flex: 1;
                     margin: 15rpx 15rpx;
+
                     .order-id {
                         height: 40rpx;
                         line-height: 40rpx;
@@ -66,17 +80,18 @@
                     }
 
                     .order-price {
-                        height: 80rpx;
-                        line-height: 80rpx;
+                        height: 100rpx;
+                        line-height: 100rpx;
                     }
 
-                    .order-date{
-                        height: 30rpx;
+                    .order-date {
+                        height: 34rpx;
                         line-height: 30rpx;
                         margin-bottom: 10rpx;
                         position: relative;
                         padding-left: 40rpx;
                     }
+
                     .order-shop-address {
                         height: 30rpx;
                         line-height: 30rpx;
@@ -90,11 +105,11 @@
 
             }
 
-            .operate-btn{
+            .operate-btn {
                 display: flex;
                 justify-content: flex-end;
-                
-                .btn{
+
+                .btn {
                     width: 150rpx;
                     height: 60rpx;
                     line-height: 60rpx;
@@ -102,10 +117,13 @@
                     margin: 20rpx 25rpx;
                     border-radius: 10rpx;
                 }
-                .buy-again{
+
+                .buy-again {
                     border: 1rpx solid #c7c7c7;
                 }
-                .comment,.pay{
+
+                .comment,
+                .pay {
                     background-color: #DF3361;
                     color: #fff;
                 }
@@ -114,8 +132,8 @@
     }
 }
 
-.icon{
+.icon {
     position: absolute;
-    top: -2rpx;
+    top: -3rpx;
     left: 0;
 }

+ 1 - 1
pages/personorder/personorder.wxml

@@ -51,7 +51,7 @@
                                     wx:if="{{item.status==2&&item.writeOffStatus==2&&item.discussId==''}}"
                                     data-orderid="{{item.id}}" data-shopid="{{item.storeId}}"
                                     data-productid="{{item.productId}}" bindtap="gotoComment">评价</view>
-                                <view class="pay btn f14" wx:if="{{item.orderStatus==1}}">付款</view>
+                                <view class="pay btn f14" wx:if="{{item.status==1}}">付款</view>
                             </view>
                         </view>
                     </block>

+ 22 - 8
pages/personorder/personorder.wxss

@@ -3,13 +3,16 @@
   line-height: 95rpx;
 }
 
+.container .weui-tabs .weui-tabs-bar__wrp {
+  position: relative;
+}
+
 .container .weui-tabs .weui-tabs-bar__wrp .weui-tabs-bar__content {
   height: 95rpx;
-  line-height: 94rpx;
+  line-height: 92rpx;
   white-space: nowrap;
   display: flex;
   justify-content: space-around;
-  border-bottom: 1rpx solid #ECECEC;
 }
 
 .container .weui-tabs .weui-tabs-bar__wrp .weui-tabs-bar__content .weui-tabs-bar__item {
@@ -22,6 +25,16 @@
   border-bottom-width: 6rpx;
 }
 
+.container .weui-tabs .weui-tabs-bar__wrp::before {
+  content: "";
+  position: absolute;
+  width: 100%;
+  height: 1rpx;
+  background-color: #ECECEC;
+  bottom: -2rpx;
+  left: 0;
+}
+
 .container .orders {
   margin-top: 20rpx;
 }
@@ -40,7 +53,7 @@
 .container .orders .orderinfo .order-item .order-img {
   width: 210rpx;
   height: 200rpx;
-  margin: 15rpx 15rpx;
+  margin: 55rpx 20rpx 0 20rpx;
 }
 
 .container .orders .orderinfo .order-item .order-img image {
@@ -65,12 +78,12 @@
 }
 
 .container .orders .orderinfo .order-item .order-desc .order-price {
-  height: 80rpx;
-  line-height: 80rpx;
+  height: 100rpx;
+  line-height: 100rpx;
 }
 
 .container .orders .orderinfo .order-item .order-desc .order-date {
-  height: 30rpx;
+  height: 34rpx;
   line-height: 30rpx;
   margin-bottom: 10rpx;
   position: relative;
@@ -104,13 +117,14 @@
   border: 1rpx solid #c7c7c7;
 }
 
-.container .orders .orderinfo .operate-btn .comment, .container .orders .orderinfo .operate-btn .pay {
+.container .orders .orderinfo .operate-btn .comment,
+.container .orders .orderinfo .operate-btn .pay {
   background-color: #DF3361;
   color: #fff;
 }
 
 .icon {
   position: absolute;
-  top: -2rpx;
+  top: -3rpx;
   left: 0;
 }

+ 1 - 1
utils/date.js

@@ -24,7 +24,7 @@
  function checkedTime(list) {
    // 设置一小时内订单不能购买
    var timeLimit = 1;
-   var nowTime = new Date('2020-12-27 14:02:00');
+   var nowTime = new Date();
    var hour = nowTime.getHours();
    var checkList = [];
    // console.log(tabs[5].list)