geek преди 4 години
родител
ревизия
c0fe8b9ce5
променени са 6 файла, в които са добавени 67 реда и са изтрити 11 реда
  1. 4 0
      api/order.js
  2. 9 7
      pages/appointment/appointment.js
  3. 28 2
      pages/order/order.js
  4. 1 1
      pages/order/order.wxml
  5. 24 0
      pages/personorder/personorder.js
  6. 1 1
      pages/personorder/personorder.wxml

+ 4 - 0
api/order.js

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

+ 9 - 7
pages/appointment/appointment.js

@@ -66,17 +66,19 @@ Page({
       return
     }
     if (!self.data.orderTime){
-      wx.showModal({
-        title: '提示',
-        content: '请选择预约时间',
-        showCancel:false,
-      })
-      return
+      // wx.showModal({
+      //   title: '提示',
+      //   content: '请选择预约时间',
+      //   showCancel:false,
+      // })
+      // return
     }
+    self.data.orderTime = '19:00'
     let data = {
       productId: self.data.productId,
       storeId: self.data.shopId,
-      appointmentTime: self.data.orderTime,
+      // appointmentTime: self.data.orderTime,
+      appointmentTime: '2021-02-27 19:00',
       num: self.data.peopleNum,
       mobile: self.data.mobile
     }

+ 28 - 2
pages/order/order.js

@@ -23,7 +23,7 @@ Page({
     this.setData({
       orderId: orderId
     })
-    let order = await orderApi.getOrderById(orderId);
+    // let order = await orderApi.getOrderById(orderId);
 
 
 
@@ -122,6 +122,10 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: async function () {
+    await this.orderInfo()
+
+  },
+  orderInfo: async function(){
     var orderId = this.data.orderId;
     let order = await orderApi.getOrderById(orderId);
     this.setData({
@@ -135,7 +139,6 @@ Page({
     if (order.info.status == 2) {
       this.drawCode(order.info.writeOffCode)
     }
-
   },
   rpxToPx(data) {
     return data / 750 * wx.getSystemInfoSync().windowWidth
@@ -174,6 +177,29 @@ Page({
    */
   onShareAppMessage: function () {
 
+  },
+  payOrder: async function(){
+    const self = this
+    let orderId = this.data.orderId
+    const data = {
+      orderId
+    }
+    const rs = await orderApi.payOrderAgain(data)
+
+    wx.requestPayment({
+      timeStamp: rs.timeStamp,
+      nonceStr: rs.nonceStr,
+      package: rs.package,
+      signType: rs.signType,
+      paySign: rs.paySign,
+      success: async function (res) { 
+        console.log(res)
+        await self.orderInfo()
+      },
+      fail: async function (res) { 
+        await self.orderInfo()
+      }
+    })
   }
 
 })

+ 1 - 1
pages/order/order.wxml

@@ -44,7 +44,7 @@
     </view>
     <view class="order-btn">
         <view class="delete-btn" bindtap="cancelOrder" wx:if="{{order.status==1}}">取消订单</view>
-        <view class="pay-btn" wx:if="{{order.status==1}}">确认支付</view>
+        <view class="pay-btn" wx:if="{{order.status==1}}" bindtap="payOrder">确认支付</view>
         <view class="delete-btn" bindtap="deleteOrder" wx:if="{{order.status==3}}">删除订单</view>
     </view>
 </view>

+ 24 - 0
pages/personorder/personorder.js

@@ -330,5 +330,29 @@ Page({
     wx.navigateTo({
       url: '../appointment/appointment?' + 'shopId=' + shopId + '&productId=' + productId + '&productImg=' + productImg + '&productName=' + productName + '&price=' + price,
     })
+  },
+  payOrder: async function(e){
+    console.log(e)
+    let orderId = e.currentTarget.dataset.orderid;
+    const data = {
+      orderId
+    }
+    const rs = await orderApi.payOrderAgain(data)
+
+    wx.requestPayment({
+      timeStamp: rs.timeStamp,
+      nonceStr: rs.nonceStr,
+      package: rs.package,
+      signType: rs.signType,
+      paySign: rs.paySign,
+      success: async function (res) { 
+        console.log(res)
+        self.onLoad()
+      },
+      fail: async function (res) { 
+        self.onLoad()
+      }
+    })
+
   }
 })

+ 1 - 1
pages/personorder/personorder.wxml

@@ -49,7 +49,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.status==1}}">付款</view>
+                                <view class="pay btn f14" data-orderId="{{item.id}}" bindtap="payOrder" wx:if="{{item.status==1}}">付款</view>
                             </view>
                         </view>
                     </block>