nieyuge il y a 2 ans
Parent
commit
1b533cad07
2 fichiers modifiés avec 18 ajouts et 2 suppressions
  1. 2 2
      pages/luckdraw.vue
  2. 16 0
      utils/help.js

+ 2 - 2
pages/luckdraw.vue

@@ -205,7 +205,7 @@
 import axios from 'axios'
 import Cookies from 'js-cookie'
 import { Toast } from 'vant';
-import { isBrowser, appType, appVersionCode, formatSecondsAsTime } from '../utils/help.js'
+import { isBrowser, appType, appVersionCode, formatSecondsAsDaysOrTime } from '../utils/help.js'
 import FontAmount from '../components/FontAmount.vue'
 
 var moment = require('moment');
@@ -417,7 +417,7 @@ export default {
                 let endTime = moment(end_time + 5000)
                 let downTime = (endTime - time) || 0
                 if (downTime > 0) {
-                    this.validity = formatSecondsAsTime(downTime / 1000);
+                    this.validity = formatSecondsAsDaysOrTime(downTime / 1000);
                 } else {
                     this.validity = `00:00:00`
                     this.getDetail(() => {

+ 16 - 0
utils/help.js

@@ -88,6 +88,22 @@ export function formatSecondsAsTime(secs) {
     return text
 }
 
+// 抽奖红包 left
+export function formatSecondsAsDaysOrTime(secs) {
+    if (secs <= 0) {
+      return '00:00:00'
+    }
+    let text = ''
+    var hr = Math.floor(secs / 3600)
+    if (hr >= 24) {
+      let day = parseInt(hr / 24)
+      text = `${day} days left`
+    } else {
+      text = formatSecondsAsTime(secs)
+    }
+    return text
+}
+
 export const appVersionCode = 12;
 
 export const appType = 1;