فهرست منبع

修改结束时间

xuqiaoying 3 سال پیش
والد
کامیت
5cbe4def63
2فایلهای تغییر یافته به همراه30 افزوده شده و 10 حذف شده
  1. 0 3
      pages5/mockExam/examApply.vue
  2. 30 7
      pages5/mockExam/registrationSuccess.vue

+ 0 - 3
pages5/mockExam/examApply.vue

@@ -144,9 +144,6 @@ export default {
         }
     },
     onShow() {
-        // if (this.$method.isGoLogin()) { // 扫二维码进来的没登录需要跳到登录页,登录后返回
-        //     return
-        // }
         // console.log('222222222222222')
         // if (!uni.getStorageSync('user_account')) {
 		// 	uni.navigateTo({

+ 30 - 7
pages5/mockExam/registrationSuccess.vue

@@ -10,7 +10,7 @@
         <view class="exam_times">
             <view class="start_time all_time">
                 <view class="time_left">
-                    <text class="numbers">{{ sDay > 1 ? parseInt(sDay) : 0 }}</text>
+                    <text class="numbers">{{ startTime | getLastDay }}</text>
                     <text class="days">天</text>
                 </view>
                 <view class="words">距模考开始时间</view>
@@ -18,7 +18,7 @@
             <view class="lines"></view>
             <view class="end_time all_time">
                 <view class="time_left">
-                    <text class="numbers">{{ sDay > 1 ? parseInt(eDay) : 0 }}</text>
+                    <text class="numbers">{{ endTime | getLastDay }}</text>
                     <text class="days">天</text>
                 </view>
                 <view class="words">距模考结束时间</view>
@@ -102,15 +102,38 @@ export default {
             eDay: '',
         }
     },
+    filters: {
+        getLastDay(time) {
+            console.log('time:', time)
+            var padDate = function (va) {
+                va = va < 10 ? '0' + va : va
+                return va
+            }
+            if (time) {
+                var value = new Date(time * 1000) //时间戳为10位需*1000,时间戳为13位的话不需乘1000
+                var year = value.getFullYear()
+                var month = padDate(value.getMonth() + 1)
+                var day = padDate(value.getDate())
+                let t_value = year + '/' + month + '/' + day
+                console.log('t:', t_value)
+                let curTimeLast = new Date(new Date(t_value).toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1
+                
+                let lastStartDay = parseInt(curTimeLast/1000) - parseInt(curTime/1000)                
+                let days = parseInt(lastStartDay/24/60/60) 
+                return days >= 1 ? days : 0
+                // this.lastEndDay = parseInt(curTimeLast/1000)  - parseInt(curTime/1000)
+                // this.sDay = this.lastStartDay/24/60/60
+                // this.eDay = this.lastEndDay/24/60/60
+                // console.log('lastStartDay', this.lastStartDay, this.lastEndDay, this.sDay, this.eDay)
+            }
+        }
+    },
     onLoad(option) {
         console.log('option: ', option)
         this.startTime = option.startTime
         this.endTime = option.endTime
-        this.lastStartDay = option.startTime - parseInt(curTime/1000)
-        this.lastEndDay = option.endTime - parseInt(curTime/1000)
-        this.sDay = this.lastStartDay/24/60/60
-        this.eDay = this.lastEndDay/24/60/60
-        console.log('lastStartDay', this.lastStartDay, this.lastEndDay, this.sDay, this.eDay)
+        // this.startTime = "1663041599"
+        // this.endTime = "1663127999"
     },
 }
 </script>