Showing
2 changed files
with
16 additions
and
33 deletions
| ... | @@ -323,23 +323,15 @@ const showBtn = computed(() => { | ... | @@ -323,23 +323,15 @@ const showBtn = computed(() => { |
| 323 | * @param {*} seconds | 323 | * @param {*} seconds |
| 324 | */ | 324 | */ |
| 325 | function formatTime(seconds) { | 325 | function formatTime(seconds) { |
| 326 | - const hours = Math.floor(seconds / 3600); | 326 | + const hours = Math.floor(seconds / 3600); // 计算小时数 |
| 327 | - const minutes = Math.floor((seconds % 3600) / 60); | 327 | + const minutes = Math.floor((seconds % 3600) / 60); // 计算分钟数 |
| 328 | - const remainingSeconds = seconds % 60; | 328 | + const remainingSeconds = seconds % 60; // 计算剩余的秒数 |
| 329 | 329 | ||
| 330 | - let formattedTime = ""; | 330 | + const formattedHours = String(hours).padStart(2, "0"); // 格式化小时数,保证两位数 |
| 331 | + const formattedMinutes = String(minutes).padStart(2, "0"); // 格式化分钟数,保证两位数 | ||
| 332 | + const formattedSeconds = String(remainingSeconds).padStart(2, "0"); // 格式化剩余的秒数,保证两位数 | ||
| 331 | 333 | ||
| 332 | - if (hours > 0) { | 334 | + return `${formattedHours}:${formattedMinutes}:${formattedSeconds}`; |
| 333 | - formattedTime += hours.toString().padStart(2, "0") + ":"; | ||
| 334 | - } | ||
| 335 | - | ||
| 336 | - if (minutes > 0 || hours > 0) { | ||
| 337 | - formattedTime += minutes.toString().padStart(2, "0") + ":"; | ||
| 338 | - } | ||
| 339 | - | ||
| 340 | - formattedTime += "00:" + remainingSeconds.toString().padStart(2, "0"); | ||
| 341 | - | ||
| 342 | - return formattedTime; | ||
| 343 | } | 335 | } |
| 344 | 336 | ||
| 345 | const props = defineProps({ | 337 | const props = defineProps({ |
| ... | @@ -430,8 +422,7 @@ onMounted(async () => { | ... | @@ -430,8 +422,7 @@ onMounted(async () => { |
| 430 | order_num.value = props.data.order_num; | 422 | order_num.value = props.data.order_num; |
| 431 | plan_in.value = props.data.plan_in; | 423 | plan_in.value = props.data.plan_in; |
| 432 | plan_out.value = props.data.plan_out; | 424 | plan_out.value = props.data.plan_out; |
| 433 | - // remain_time.value = props.data.pay_time; | 425 | + remain_time.value = props.data.pay_time; |
| 434 | - remain_time.value = 50; | ||
| 435 | contact_name.value = props.data.contact_name; | 426 | contact_name.value = props.data.contact_name; |
| 436 | contact_phone.value = props.data.contact_phone; | 427 | contact_phone.value = props.data.contact_phone; |
| 437 | order_remark.value = props.data.order_remark; | 428 | order_remark.value = props.data.order_remark; | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2023-12-20 14:11:11 | 2 | * @Date: 2023-12-20 14:11:11 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-12-29 17:47:15 | 4 | + * @LastEditTime: 2023-12-29 17:59:42 |
| 5 | * @FilePath: /meihuaApp/src/components/payCard.vue | 5 | * @FilePath: /meihuaApp/src/components/payCard.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -29,23 +29,15 @@ import { payAPI, payCheckAPI } from '@/api/index' | ... | @@ -29,23 +29,15 @@ import { payAPI, payCheckAPI } from '@/api/index' |
| 29 | * @param {*} seconds | 29 | * @param {*} seconds |
| 30 | */ | 30 | */ |
| 31 | function formatTime(seconds) { | 31 | function formatTime(seconds) { |
| 32 | - const hours = Math.floor(seconds / 3600); | 32 | + const hours = Math.floor(seconds / 3600); // 计算小时数 |
| 33 | - const minutes = Math.floor((seconds % 3600) / 60); | 33 | + const minutes = Math.floor((seconds % 3600) / 60); // 计算分钟数 |
| 34 | - const remainingSeconds = seconds % 60; | 34 | + const remainingSeconds = seconds % 60; // 计算剩余的秒数 |
| 35 | 35 | ||
| 36 | - let formattedTime = ""; | 36 | + const formattedHours = String(hours).padStart(2, "0"); // 格式化小时数,保证两位数 |
| 37 | + const formattedMinutes = String(minutes).padStart(2, "0"); // 格式化分钟数,保证两位数 | ||
| 38 | + const formattedSeconds = String(remainingSeconds).padStart(2, "0"); // 格式化剩余的秒数,保证两位数 | ||
| 37 | 39 | ||
| 38 | - if (hours > 0) { | 40 | + return `${formattedHours}:${formattedMinutes}:${formattedSeconds}`; |
| 39 | - formattedTime += hours.toString().padStart(2, "0") + ":"; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - if (minutes > 0 || hours > 0) { | ||
| 43 | - formattedTime += minutes.toString().padStart(2, "0") + ":"; | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - formattedTime += "00:" + remainingSeconds.toString().padStart(2, "0"); | ||
| 47 | - | ||
| 48 | - return formattedTime; | ||
| 49 | } | 41 | } |
| 50 | 42 | ||
| 51 | const props = defineProps({ | 43 | const props = defineProps({ | ... | ... |
-
Please register or login to post a comment