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

fix:1、授权成功后,取消授权倒计时进度条显示不正确;
2、预支付下单页面的”请输入金额0.00“,这里的0.00会占用字符位,需要删除才能输入;
3、订单详细页显示不全;

Zhenghanjv пре 8 месеци
родитељ
комит
ce0a634665

+ 1 - 1
components/orderItemInfo/orderItemInfo.js

@@ -46,7 +46,7 @@ Component({
    */
   methods: {
     showOrHide(){
-      const height = this.data.isHide?10:29;
+      const height = this.data.isHide?10:30;
       console.log("点击了",this.data.isHide,height)
       
       this.setData({

+ 2 - 2
components/prepayOrderItemInfo/prepayOrderItemInfo.js

@@ -36,7 +36,7 @@ Component({
    * 组件的初始数据
    */
   data: {
-    contentHeight: 20,
+    contentHeight: 22,
     isHide:false,
     rotateDeg:0
   },
@@ -48,7 +48,7 @@ Component({
     
     showOrHide(){
       
-      const height = this.data.isHide?20:35;
+      const height = this.data.isHide?22:37;
       console.log("点击了",this.data.isHide,height)
       
       this.setData({

+ 1 - 1
pages/AuthorizationTransactionPage/AuthorizationTransactionPage.js

@@ -12,7 +12,7 @@ Page({
   data: {
     nozzleId: 0,
     type: '预支付',
-    order: null,
+    order: null
   },
 
   /**

+ 28 - 6
pages/TransactionPage/TransactionPage.js

@@ -11,8 +11,8 @@ Page({
    */
   data: {
     nozzleId: 0,
-    type: '后支付',
     order: null,
+    stationName:'',//油站名
     // order: {
     //   oilName: '好名字',
     //   nozzle: "1",
@@ -39,7 +39,7 @@ Page({
     this.setData({
       nozzleId: id
     })
-
+    this.getStationInfo()
     this.getOrder()
   },
 
@@ -75,7 +75,7 @@ Page({
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh() {
-
+    this.getOrder()
   },
 
   /**
@@ -91,7 +91,27 @@ Page({
   onShareAppMessage() {
 
   },
-
+  /** 获取站点信息 */
+  getStationInfo() {
+    const that = this;
+    api.request_GetSiteInfo().then(res => {
+      if (res.data.statusCode == 203) {
+        //若为203,证明还未登录,跳转到登录页,这里可能刚从主页跳转过来,频繁的跳转可能会跳转页面超时,故而加上延时
+        setTimeout(() => {
+          wx.navigateTo({
+            url: '../login/login'
+          })
+        }, 500)
+        return
+      }
+      console.log("站点信息", res)
+      
+      const name = res.data.data.site.name;
+      that.setData({
+        stationName:name,
+      })
+    })
+  },
   /** 获取订单信息 */
   getOrder() {
     wx.showLoading({
@@ -100,6 +120,7 @@ Page({
     api.request_GetMiniProgramTransactionsUnpaidNozzle(Number(this.data.nozzleId))
       .then(res => {
         wx.hideLoading()
+        wx.stopPullDownRefresh()
         if (res.data.statusCode == 203) {
           //若为203,证明还未登录,跳转到登录页,这里可能刚从主页跳转过来,频繁的跳转可能会跳转页面超时,故而加上延时
           setTimeout(() => {
@@ -123,7 +144,8 @@ Page({
             discount: order.originalAmount - order.actualPaymentAmount,
             orderId: order.id,
             time: time,
-            price:order.price
+            price:order.price,
+            station:this.data.stationName
           }
         })
 
@@ -141,7 +163,7 @@ Page({
     })
     var that = this;
     wx.navigateTo({
-      url: '../moreOrder/moreOrder?nozzle=' + this.data.nozzleId,
+      url: '../moreOrder/moreOrder?nozzle=' + this.data.nozzleId+'&stationName=' + this.data.stationName,
       events: {
         acceptOrderFromMoreOrder: function (data) {
           console.log("获取到传送过来的订单", data)

+ 2 - 1
pages/TransactionPage/TransactionPage.json

@@ -3,5 +3,6 @@
     "orderInfo":"../../components/orderItemInfo/orderItemInfo",
     "pay":"../../components/pay/pay"
   },
-  "navigationBarTitleText": "确认支付"
+  "navigationBarTitleText": "确认支付",
+  "enablePullDownRefresh": true
 }

+ 0 - 1
pages/TransactionPage/TransactionPage.wxml

@@ -8,5 +8,4 @@
   <!-- 支付按钮 -->
   <pay class="payButton" amount="{{order.amount}}" bind:onPay="toPay" />
 
-  <text>{{nozzleId}}</text>
 </view>

+ 67 - 0
pages/historyOrder/historyOrder.js

@@ -310,6 +310,70 @@ Page({
     if (event.detail.event == "重新授权") {
       this.toAuthorization(event.detail.order.orderId)
     }
+    if(event.detail.event == "继续支付") {
+      this.toPay(event.detail.order.orderId)
+    }
+  },
+
+  /** 支付按钮点击事件 */
+  toPay(orderId) {
+    wx.showLoading({
+      title: '支付中',
+    })
+    this.subMessage(orderId)
+  },
+  /** 订阅消息模板 */
+  subMessage(orderId) {
+    const that = this;
+    wx.requestSubscribeMessage({
+      tmplIds: ['V0tl-4n-5hwNZc4SrEttvrmawAyM-SB0pQWZNwp54Ks'], // 最多支持3条
+      success(res) {
+        that.pay(orderId)
+        // 'accept'表示用户同意订阅该条id对应的模板消息
+        if (res['V0tl-4n-5hwNZc4SrEttvrmawAyM-SB0pQWZNwp54Ks'] === 'accept') {
+          
+        }
+      },
+      fail(err) {
+        that.pay(orderId)
+      }
+    })
+
+
+  },
+  /** 实际支付 */
+  pay(orderId) {
+    const that = this;
+    api.request_wechatPay(orderId)
+      .then(res => {
+        wx.requestPayment({
+          timeStamp: res.data.data.unifiedOrderResult.timeStamp,
+          nonceStr: res.data.data.unifiedOrderResult.nonceStr,
+          package: res.data.data.unifiedOrderResult.package,
+          signType: res.data.data.unifiedOrderResult.signType,
+          paySign: res.data.data.unifiedOrderResult.paySign,
+          success: res => {
+            wx.hideLoading()
+            that.sendMessage(orderId)
+            that.refreshOrder()
+          },
+          fail: res => {
+            wx.hideLoading()
+          }
+        })
+      });
+  },
+  /** 发送消息模板 */
+  sendMessage(orderId) {
+    const message = {
+      trxid: orderId,
+      orderType: '支付'
+    }
+    api.request_sendMessage(message).then(res => {
+      console.log("发送消息模板结果", res)
+    }).catch(err => {
+      console.log("发送消息模板失败", err)
+    })
   },
 
   /** 授权 */
@@ -352,6 +416,7 @@ Page({
     const findTime = this.data.date != '' ? this.data.date + "T23:59:59" : this.data.date;
     api.request_WXFindOrders(findTime, this.data.pageNum, this.data.pageSize).then(res => {
       wx.hideLoading()
+      wx.stopPullDownRefresh()
       // api.request_WXFindOrders(this.data.date, 3, 5).then(res => {
       console.log("获取历史订单", res)
       let datas = res.data.data;
@@ -468,6 +533,8 @@ Page({
   refreshOrder() {
     this.setData({
       date: '',
+      pageNum:1,
+      pageSize:5,
       orders: []
     });
     console.log(this.data.date)

+ 2 - 1
pages/historyOrder/historyOrder.json

@@ -3,5 +3,6 @@
     "orderItem":"../../components/orderItemInfo/orderItemInfo",
     "prepayOrderItem":"../../components/prepayOrderItemInfo/prepayOrderItemInfo"
   },
-  "navigationBarTitleText": "订单列表"
+  "navigationBarTitleText": "订单列表",
+  "enablePullDownRefresh": true
 }

+ 18 - 6
pages/moreOrder/moreOrder.js

@@ -8,7 +8,9 @@ Page({
    */
   data: {
     buttonMessage2:'去支付',
-    orders:[]
+    orders:[],
+    stationName:'',
+    nozzleId:0
   },
 
   /**
@@ -16,7 +18,11 @@ Page({
    */
   onLoad(options) {
     console.log("更多订单页",options)
-    this.getOrder(options.nozzle)
+    this.setData({
+      stationName:options.stationName,
+      nozzleId:options.nozzle
+    })
+    this.getOrder()
   },
 
   /**
@@ -51,7 +57,7 @@ Page({
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh() {
-
+    this.getOrder()
   },
 
   /**
@@ -78,10 +84,15 @@ Page({
   },
 
   /** 获取订单信息 */
-  getOrder(nozzle) {
-    api.request_GetMiniProgramTransactionsUnpaidNozzle(Number(nozzle))
+  getOrder() {
+    wx.showLoading({
+      title: '获取更多订单',
+    })
+    api.request_GetMiniProgramTransactionsUnpaidNozzle(Number(this.data.nozzleId))
     .then(res => {
       console.log("获取到未支付订单",res)
+      wx.hideLoading()
+      wx.stopPullDownRefresh()
       var datas = res.data.data;
       var getOrders = datas.map(order => {
         var time = util.formatDateNotSecond(order.fuelItemTransactionEndTime);
@@ -93,7 +104,8 @@ Page({
           payAmount:order.actualPaymentAmount,
           discount:order.originalAmount - order.actualPaymentAmount,
           orderId:order.id,
-          time:time
+          time:time,
+          station:this.data.stationName
         }
       })
       

+ 2 - 1
pages/moreOrder/moreOrder.json

@@ -2,5 +2,6 @@
   "usingComponents": {
     "orderItem":"../../components/orderItemInfo/orderItemInfo"
   },
-  "navigationBarTitleText": "确认支付"
+  "navigationBarTitleText": "确认支付",
+  "enablePullDownRefresh": true
 }

+ 16 - 6
pages/payStatus/payStatus.js

@@ -2,13 +2,13 @@ const { default: api } = require("../../js/api");
 
 Page({
   data: {
-    id: 4 , // 初始ID值
+    id: 1 , // 初始ID值
     nozzleId:0,
     order:null,
-    countdown: 120,
+    // countdown: 120,
     progressWidth: 100, // 初始进度条宽度为100%
-    totalSeconds: 60, // 总秒数
-    currentSeconds: 60, // 当前剩余秒数
+    totalSeconds: 120,// 总秒数
+    currentSeconds: 120, // 当前剩余秒数
     countDownTimer:null, //倒计时定时器
     checkNozzleStatuesTimer:null, //检查油枪状态定时器
   },
@@ -31,7 +31,7 @@ Page({
       that.toAuthorization();
     }
     });
-
+    
   },
 
   /** 返回重新支付 */
@@ -71,9 +71,16 @@ Page({
   /** 取消授权 */
   toUnAuthorization(){
     const that = this;
+    wx.showLoading({
+      title: '正在取消授权',
+    })
     api.request_CancelNozzleAuthorization(this.data.order.orderId).then(res => {
       console.log("取消授权",res)
+      wx.hideLoading()
       if(res.data.statusCode != 200) {
+        wx.showToast({
+          title: '取消授权失败,重新取消授权',
+        })
         that.countDown()
         that.startCheckNozzle()
         return
@@ -81,6 +88,9 @@ Page({
       that.setData({
         id:5
       })
+    }).catch(err => {
+      console.log("取消授权报错",err)
+      wx.hideLoading()
     })
   },
 
@@ -102,7 +112,7 @@ Page({
       if (currentSeconds < 0) {
         that.toUnAuthorization()
         that.setData({
-          currentSeconds: 60,
+          currentSeconds: 120,
           progressWidth: 100
         })
         that.clearTimer()

+ 1 - 1
pages/payStatus/payStatus.wxml

@@ -54,7 +54,7 @@
   </view>
   <!-- 倒计时区域 -->
   <view class="i" style="position: relative; left: -2rpx; top: -387rpx; width: 560rpx; height: 100rpx; display: block; box-sizing: border-box">
-    <view class="k" style="width: {{progressWidth}}%; position: relative; left: -58rpx; top: 0rpx"></view>
+    <view class="k" style="width: {{progressWidth}}%; position: relative;"></view>
     <text class="countdown-text" style="position: absolute; left: 85rpx; top: -105rpx; width: 368rpx; height: 291rpx; display: flex; box-sizing: border-box">{{currentSeconds}}s</text>
   </view>
   <!-- 底部链接区域 -->

+ 19 - 7
pages/quantify/quantify.js

@@ -13,6 +13,7 @@ Page({
     isLoading: false,
     nozzleInfo: null,
     quantify: '元',
+    stationName:'',//油站名
     fastInputs: [10, 20, 50, 100, 200, 500],
     selectIndex:-1,
     type: [{
@@ -24,7 +25,7 @@ Page({
       checked: false
     }
     ],
-    inputValue: '0.00',
+    inputValue: '',
     inputTip: '请输入金额',
     amount: '',
     latitude: 0, //用户当前经度
@@ -45,9 +46,6 @@ Page({
     this.setData({
       nozzleId: id
     })
-    wx.showToast({
-      title: id,
-    })
   },
 
   /** 获取站点信息 */
@@ -64,6 +62,10 @@ Page({
         return
       }
       console.log("站点信息", res)
+      const name = res.data.data.site.name;
+      this.setData({
+        stationName:name,
+      })
       const stationLocation = res.data.data.site.gpsCoordinates.split(",");
       if (stationLocation.length == 2) {
         this.setData({
@@ -80,6 +82,8 @@ Page({
     const that = this;
     wx.getLocation({
       type: 'wgs84',
+      isHighAccuracy:true,
+      highAccuracyExpireTime:5000,
       success(res) {
         console.log("获取经纬度结果", res)
         that.setData({
@@ -149,8 +153,15 @@ Page({
 
   /** 授权 */
   toAuthorization() {
+    if(this.data.inputValue == '') {
+      wx.showToast({
+        title: '请输入定量值',
+        icon:'none'
+      })
+      return
+    }
     wx.showLoading({
-      title: '授权中',
+      title: '下单中',
     })
   
     console.log('进入 toAuthorization 方法');
@@ -176,7 +187,6 @@ Page({
       });
       return;
     }
-
     const value = parseFloat(this.data.inputValue);
     console.log("要授权的油枪信息", nozzle, value);
     if (this.data.quantify == '元' && (value < 2.00 || value > 9900.00)) {
@@ -235,6 +245,7 @@ Page({
   },
 
   toPayPage(res) {
+    const that = this;
     const order = res.data.data;
     const time = utils.formatDateNotSecond(order.createTime);
     setTimeout(() => {
@@ -250,7 +261,8 @@ Page({
             discount: order.originalAmount - order.actualPaymentAmount,
             orderId: order.id,
             time: time,
-            price:order.price
+            price:order.price,
+            station:that.data.stationName
           })
         }
       })

+ 1 - 1
pages/scan/scan.wxml

@@ -49,7 +49,7 @@
 
     </view>
 
-    <text class="version">V2025.02.06</text>
+    <text class="version">V2025.02.07</text>
   </view>