Browse Source

'修改主页和订单详情页'

machinecat520 2 years ago
parent
commit
78d3916f09
4 changed files with 88 additions and 14 deletions
  1. 3 3
      app.json
  2. 3 3
      pages/myInfo/myInfo.js
  3. 78 4
      pages/orderDetail/orderDetail.js
  4. 4 4
      pages/orderDetail/orderDetail.wxml

+ 3 - 3
app.json

@@ -1,14 +1,14 @@
 
 {
     "pages": [
+        "pages/myInfo/myInfo",
         "pages/orderDetail/orderDetail",
+        "pages/authenticationDetail/authenticationDetail",
         "pages/myOrder/myOrder",
-        "pages/receivedInvitation/receivedInvitation",
         "pages/receivedInvitationList/receivedInvitationList",
+        "pages/receivedInvitation/receivedInvitation",
         "pages/sendInvitationList/sendInvitationList",
         "pages/sendInvitation/sendInvitation",
-        "pages/authenticationDetail/authenticationDetail",
-        "pages/myInfo/myInfo",
         "pages/mask/mask",
         "pages/handleSuggest/handleSuggest",
         "pages/manageSuggestDetail/manageSuggestDetail",

+ 3 - 3
pages/myInfo/myInfo.js

@@ -5,7 +5,7 @@ Page({
      * 页面的初始数据
      */
     data: {
-        id: '20221222'
+        id: '20221222'  //管理员的id号
     },
 
     /**
@@ -32,14 +32,14 @@ Page({
     //跳转到我发出的邀请详情
     sendInvitation() {
         wx.navigateTo({
-            url: '/pages/sendInvitation/sendInvitation',
+            url: '/pages/sendInvitationList/sendInvitationList',
         })
     },
 
     //跳转到我收到的邀请详情
     receivedInvitation() {
         wx.navigateTo({
-            url: '/pages/receivedInvitation/receivedInvitation',
+            url: '/pages/receivedInvitationList/receivedInvitationList',
         })
     },
 

+ 78 - 4
pages/orderDetail/orderDetail.js

@@ -5,10 +5,17 @@ Page({
      * 页面的初始数据
      */
     data: {
-        pay: false,
-        payStatus:'待支付',
-        payDays:4,
-        id:'teacher'
+        pay: false, //是否支付
+        show: false,    //是否显示倒计时、提示信息和教员支付按钮
+        payStatus: '待支付',  //支付状态
+        payDays: 4, //订单支付完成后的天数
+        id: 'teacher',  //身份
+        dateTime: '1672988578705', //订单生成时间的时间戳
+        currentTime: '1672988995705',   //后台获取的服务器当前时间戳
+        intervalTime: '900000', //间隔时间的时间戳
+        minute: '', //剩余分钟数
+        second: '', //剩余秒数
+        remanentTime: '' //剩余倒计时时长时间戳
     },
 
     // 跳转到需求详情
@@ -30,6 +37,73 @@ Page({
      */
     onLoad(options) {
 
+        let dateTime = this.data.dateTime
+        let intervalTime = this.data.intervalTime
+        let currentTime = this.data.currentTime
+
+        // 当前时间减去订单生成时间
+        let margin = currentTime - dateTime
+        // 剩余倒计时时长时间戳
+        let remanentTime = intervalTime - margin
+        this.setData({
+            remanentTime: remanentTime
+        })
+
+        // 调用倒计时函数
+        this.startTime()
+    },
+
+    // 倒计时函数
+    startTime() {
+        let remanentTime = this.data.remanentTime
+        // 剩余倒计时的分钟数
+        let min = remanentTime / 1000 / 60
+        let minute = Math.floor(min)
+        // 剩余倒计时的秒数
+        let sec = remanentTime / 1000 % 60
+        let second = Math.round(sec)
+        // 判断剩余倒计时时长的时间戳
+        if (remanentTime > 0) {
+            this.setData({
+                show: true
+            })
+            // 判断分钟数
+            if (minute < 10) {
+                this.setData({
+                    minute: '0' + minute
+                })
+            } else {
+                this.setData({
+                    minute: minute
+                })
+            }
+            // 判断秒数
+            if (second < 10) {
+                this.setData({
+                    second: '0' + second
+                })
+            } else {
+                this.setData({
+                    second: second
+                })
+            }
+            // 重置剩余时长,并在原基础上减1秒
+            this.setData({
+                remanentTime : remanentTime - 1000
+            })
+        } else {
+            // 当剩余倒计时时长小于等于0时,设置显示状态为false,支付状态为“已取消”
+            this.setData({
+                show: false,
+                payStatus: '已取消'
+            })
+        }
+        // 当剩余倒计时时长大于0时,间隔1秒重新执行本函数
+        if (remanentTime > 0) {
+            setTimeout(() => {
+                this.startTime()
+            }, 1000);
+        }
     },
 
     /**

+ 4 - 4
pages/orderDetail/orderDetail.wxml

@@ -48,11 +48,11 @@
             <text class="orderPayStatus">{{payStatus}}</text>
         </view>
     </view>
-    <view class="orderPay" wx:if="{{payStatus == '待支付' && id == 'teacher'}}">
+    <view class="orderPay" wx:if="{{payStatus == '待支付' && id == 'teacher' && show}}">
         <text>支付倒计时</text>
-        <text class="orderPayTime">00:32:02</text>
+        <text class="orderPayTime">00:{{minute}}:{{second}}</text>
     </view>
-    <view class="warning" wx:if="{{!pay}}">
+    <view class="warning" wx:if="{{!pay && show}}">
         <view class="warningDetail">
             <text>重要提醒:</text>
             <text>如需退款,请在支付后5日内操作,过期不受理。</text>
@@ -72,7 +72,7 @@
                 <view class="payStatus">查看手机号</view>
             </view>
         </view>
-        <view wx:elif="{{!pay && id == 'teacher'}}" class="paidSucceed">
+        <view wx:elif="{{!pay && id == 'teacher' && show}}" class="paidSucceed">
             <view class="payStatus">教员支付</view>
         </view>
     </view>