Browse Source

解决时间问题

master
yangwenhua 1 year ago
parent
commit
314bcf2ab8
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      src/components/GoodsList/GoodsList.vue

+ 8
- 1
src/components/GoodsList/GoodsList.vue View File

@@ -31,7 +31,7 @@
{{food.name}}
</view>
<view class="reservation-timerange" v-if="isReserve">
{{new Date(food.startReserveTime).toLocaleTimeString('chinese',{hour12:false}) || '无'}} - {{new Date(food.endReserveTime).toLocaleTimeString('chinese',{hour12:false}) || '无'}}
{{onFormartLocalDate(food.startReserveTime)}} - {{onFormartLocalDate(food.endReserveTime)}}
</view>
<view class="food-card-no-vip">
非会员{{food.price}}起
@@ -276,6 +276,13 @@
} else {
return false;
}
},
onFormartLocalDate(times) {
const date = new Date(times);
const hour = date.getHours() < 10 ? `0${date.getHours()}` : date.getHours();
const minutes = date.getMinutes() < 10 ? `0${date.getMinutes()}` : date.getMinutes();
const seconds = date.getMilliseconds() < 10 ? `0${date.getMilliseconds()}` : date.getMilliseconds();
return `${hour}:${minutes}:${seconds}`;
}
}
}


Loading…
Cancel
Save