diff --git a/src/views/table/table_list.vue b/src/views/table/table_list.vue index b074ba0..0622cc1 100644 --- a/src/views/table/table_list.vue +++ b/src/views/table/table_list.vue @@ -233,6 +233,8 @@ import { tbShopTable, } from "@/api/table"; import dayjs from "dayjs"; + + export default { components: { addEara, @@ -253,18 +255,48 @@ export default { selTable: "", //当前选中的桌台 areaMap: {}, shopInfo: {}, + timer:null }; }, + beforeDestroy() { + this.clearTimer(); + console.log('beforeDestroy') + }, mounted() { + this.clearTimer(); + this.setTimter(60); this.tbShopAreaGet(); this.getShopInfo(); }, filters: { - formatTime(time) { - return dayjs(time).format("HH小时mm分"); + formatTime(milliseconds) { + console.log(milliseconds) + if (!milliseconds) { + return ""; + } + const days = Math.floor(milliseconds / (1000 * 60 * 60 * 24)); + const hours = Math.floor( + (milliseconds % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) + ); + const minutes = Math.floor( + (milliseconds % (1000 * 60 * 60)) / (1000 * 60) + ); + return `${days ? days + "天" : ""} ${hours ? hours + "时" : ""} ${minutes + "分" + }`; }, }, methods: { + clearTimer(){ + console.log('clearTimer') + clearInterval(this.timer); + this.timer=null; + }, + setTimter(time=60){ + this.timer=setInterval(() => { + const showloading=false + this.tbShopTableGet(showloading) + }, time*1000); + }, //获取店铺信息 async getShopInfo() { try { @@ -322,7 +354,7 @@ export default { this.selTable = item; if (this.shopInfo.isTableFee) { //免餐位费 - this.toInstead({num: 0,key}); + this.toInstead({ num: 0, key }); // this.$refs.diancan.open(item, key, ''); return; } @@ -330,20 +362,23 @@ export default { if (item.useNum <= 0) { return this.$refs.refChooseDinersNumber.open(); } - this.toInstead({num: num,key}); + this.toInstead({ num: num, key }); // this.$refs.diancan.open(item, key, num); }, toInstead(query) { - this.$router.push({ path: "/tool/Instead/index", query: { - table_name: this.selTable.name, - tableId: this.selTable.tableId, - maxCapacity:this.selTable.maxCapacity, - useType: this.selTable.useType, - ...query - }}); + this.$router.push({ + path: "/tool/Instead/index", + query: { + table_name: this.selTable.name, + tableId: this.selTable.tableId, + useType: this.selTable.useType, + maxCapacity:this.selTable.maxCapacity, + ...query, + }, + }); }, chooseDinersNumberConfirm(num) { - this.toInstead({num: num}); + this.toInstead({ num: num }); // this.$refs.diancan.open(this.selTable, undefined, num); }, tabClick() { @@ -369,8 +404,8 @@ export default { } }, // 台桌列表 - async tbShopTableGet() { - this.loading = true; + async tbShopTableGet(showloading=true) { + this.loading = showloading; try { const { content, total } = await tbShopTableGet({ shopId: localStorage.getItem("shopId"), diff --git a/src/views/tool/Instead/components/cart-item.vue b/src/views/tool/Instead/components/cart-item.vue index 5c79941..1fcab58 100644 --- a/src/views/tool/Instead/components/cart-item.vue +++ b/src/views/tool/Instead/components/cart-item.vue @@ -1,22 +1,22 @@ - 清空 @@ -306,18 +303,21 @@
订单备注: {{ note.content }} @@ -349,41 +349,77 @@
-