Commit ed36f8b5 authored by youjie's avatar youjie

定时器

parent 129d7b27
......@@ -122,31 +122,31 @@
orders: {
handler(newVal, oldVal) {
this.g = JSON.parse(JSON.stringify(newVal))
this.g.forEach(x => {
let goodsTypeHotel = 0
// #ifdef MP-DI
goodsTypeHotel = x.goodsType==9?1:0
// #endif
// #ifdef MP-AG
goodsTypeHotel = x.goodsType==7?1:0
// #endif
if(x.orderStatus!=1) x.isExpired = true
if (x.orderStatus==1&&goodsTypeHotel>0) {
const now = Date.now();
// const customStr = '2025-05-12 14:43:00'
const customStr = x.createTimeStr
const [date, time] = customStr.split(' ')
const [year, month, day] = date.split('-')
const [hours, minutes, seconds] = time.split(':')
const parsedDate = new Date(year, month-1, day, hours, minutes, seconds)
x.orderTime = parsedDate.getTime()
const diff = x.orderTime + 5 * 60 * 1000 - now; // 5分钟倒计时
let remainingSeconds = Math.max(diff, 0); // 确保不出现负数
x.remainingSeconds = Math.floor(remainingSeconds/1000)
// console.log("支付倒计时",x.remainingSeconds)
if(x.remainingSeconds) this.initCountdown(x)
}
});
// this.g.forEach(x => {
// let goodsTypeHotel = 0
// // #ifdef MP-DI
// goodsTypeHotel = x.goodsType==9?1:0
// // #endif
// // #ifdef MP-AG
// goodsTypeHotel = x.goodsType==7?1:0
// // #endif
// if(x.orderStatus!=1) x.isExpired = true
// if (x.orderStatus==1&&goodsTypeHotel>0) {
// const now = Date.now();
// // const customStr = '2025-05-12 14:43:00'
// const customStr = x.createTimeStr
// const [date, time] = customStr.split(' ')
// const [year, month, day] = date.split('-')
// const [hours, minutes, seconds] = time.split(':')
// const parsedDate = new Date(year, month-1, day, hours, minutes, seconds)
// x.orderTime = parsedDate.getTime()
// const diff = x.orderTime + 5 * 60 * 1000 - now; // 5分钟倒计时
// let remainingSeconds = Math.max(diff, 0); // 确保不出现负数
// x.remainingSeconds = Math.floor(remainingSeconds/1000)
// // console.log("支付倒计时",x.remainingSeconds)
// if(x.remainingSeconds) this.initCountdown(x)
// }
// });
},
deep: true,
}
......@@ -162,9 +162,9 @@
mounted() {
this.b2b_user = uni.getStorageSync("b2b_user")
// 全局定时检查(防止极端情况下定时器失效)
this.checkInterval = setInterval(() => {
this.checkExpiredOrders()
}, 60000) // 每分钟检查一次
// this.checkInterval = setInterval(() => {
// this.checkExpiredOrders()
// }, 60000) // 每分钟检查一次
},
methods: {
// 时间格式化
......
......@@ -29,7 +29,7 @@
<text class="q-ml-sm col bold">
{{(order.status==0?'待支付':(order.status==1?'正常':'已取消'))}}
</text>
<u-count-down :timestamp="endts" v-if="order.status==0" color="#ffffffdd" separator-color="#ffffffdd" :show-days="false" bg-color="transparent"></u-count-down>
<u-count-down :timestamp="endts" v-if="order.status==0" color="#ffffff" separator-color="#ffffff" :show-days="false" bg-color="transparent"></u-count-down>
<!-- #endif -->
</view>
<view class="content q-mt-sm">
......
......@@ -263,7 +263,6 @@
goVisible:false,
orderInfo: {},
Mailbox: '',
price: 0,
}
},
components: {
......
......@@ -338,6 +338,13 @@
<coupon v-if="couponList.length > 0 && showCoupon" :price="orderMsg.Money" :list="couponList"
:current="useCouponIds" @close="closeCouponHandler" :order="orderMsg" :numberPeople="orderMsg.peoples">
</coupon>
<u-modal :border-radius="16"
@confirm="nativageToOrderHandle"
title="订单提醒"
content="订单创建成功,请您在5分钟内完成付款,否则将会被取消."
@cancel="navigatorToHomeHandle"
v-model="successVisible" confirm-text='查看订单' cancel-text='返回首页'
confirm-color='#DEBF7B' cancel-color='#080A09' :show-cancel-button="true"></u-modal>
</view>
</template>
......@@ -450,6 +457,7 @@
{name: '女',value: 2},
],
ErpOrderId: '',
successVisible: false,
}
},
onLoad(options) {
......@@ -493,6 +501,23 @@
});
},
methods: {
navigatorToHomeHandle() {
uni.redirectTo({
url: '/pages/index/index'
})
},
nativageToOrderHandle(){
let OrderTypeStr = ''
// #ifdef MP-DI
OrderTypeStr = '12,13,14'
// #endif
// #ifdef MP-AG
OrderTypeStr = '5'
// #endif
uni.redirectTo({
url: `/pages/AggregateOrders/AggregateOrdersList?OrderTypeStr=${OrderTypeStr}`,
});
},
radioChange(e){
this.orderMsg.Sex = e
},
......@@ -592,8 +617,18 @@
icon: "none",
});
setTimeout(() => {
// uni.redirectTo({
// url: "/pages/bus/orderdetails?orderId=" + that.ErpOrderId,
// });
let OrderTypeStr = ''
// #ifdef MP-DI
OrderTypeStr = '12,13,14'
// #endif
// #ifdef MP-AG
OrderTypeStr = '5'
// #endif
uni.redirectTo({
url: "/pages/bus/orderdetails?orderId=" + that.ErpOrderId,
url: `/pages/AggregateOrders/AggregateOrdersList?OrderTypeStr=${OrderTypeStr}`,
});
}, 100);
},
......
......@@ -228,6 +228,13 @@
<coupon v-if="couponList.length > 0 && showCoupon" :price="orderMsg.TotalPrice" :list="couponList"
:current="useCouponIds" @close="closeCouponHandler" :order="orderMsg" :numberPeople="searchObj.peoples">
</coupon>
<u-modal :border-radius="16"
@confirm="nativageToOrderHandle"
title="订单提醒"
content="订单创建成功,请您在5分钟内完成付款,否则将会被取消."
@cancel="navigatorToHomeHandle"
v-model="successVisible" confirm-text='查看订单' cancel-text='返回首页'
confirm-color='#DEBF7B' cancel-color='#080A09' :show-cancel-button="true"></u-modal>
</view>
</template>
......@@ -347,6 +354,7 @@
submit: false,
orderInfo: null,
price: 0,
successVisible: false,
}
},
onLoad(options) {
......@@ -414,6 +422,23 @@
});
},
methods: {
navigatorToHomeHandle() {
uni.redirectTo({
url: '/pages/index/index'
})
},
nativageToOrderHandle(){
let OrderTypeStr = ''
// #ifdef MP-DI
OrderTypeStr = '8,9,10,11'
// #endif
// #ifdef MP-AG
OrderTypeStr = '7'
// #endif
uni.redirectTo({
url: `/pages/AggregateOrders/AggregateOrdersList?OrderTypeStr=${OrderTypeStr}`,
});
},
//获取房间价格
getRoomPrice(priceList)
{
......@@ -592,14 +617,26 @@
},
fail: function(err) {
that.submit = true;
uni.showToast({
title: "支付失败",
icon: "none",
});
that.successVisible = true
// uni.showToast({
// title: "支付失败",
// icon: "none",
// });
setTimeout(() => {
uni.redirectTo({
url: "/pages/hotel/orderdetails?orderId=" + item.ErpOrderId,
});
// uni.redirectTo({
// url: "/pages/hotel/orderdetails?orderId=" + item.ErpOrderId,
// });
// let OrderTypeStr = ''
// // #ifdef MP-DI
// OrderTypeStr = '8,9,10,11'
// // #endif
// // #ifdef MP-AG
// OrderTypeStr = '7'
// // #endif
// uni.redirectTo({
// url: `/pages/AggregateOrders/AggregateOrdersList?OrderTypeStr=${OrderTypeStr}`,
// });
}, 100);
},
});
......
<template>
<view class="hotel-detail" v-if="orderData">
<view class="hotel-detail f-order" v-if="orderData">
<scroll-view ref="scrollView" scroll-y="true" style="height: 1px;flex: 1;box-sizing: border-box;"
@scroll="scroll">
<view class="media" :style="{ opacity: 100 - boxOption + '%' }">
......@@ -10,30 +10,48 @@
<u-icon name="arrow-left" size="44" style="margin-top: 22rpx"></u-icon>
</view> -->
<!-- #endif -->
<view class="orderStatusBox flex" style="margin-bottom: 30rpx;justify-content: space-between">
<view class="row">
<u-icon customPrefix="iconfont" name="icondaizhifu-" size="52" color="#DFBE6E"
v-if="orderStatus.code == 0"></u-icon>
<u-icon customPrefix="iconfont" name="iconquxiao" size="52" color="#f26c6c"
v-if="orderStatus.code == -1"></u-icon>
<u-icon customPrefix="iconfont" name="iconshenhezhong" size="52" color="#86d9a5"
v-if="orderStatus.code == -2"></u-icon>
<u-icon customPrefix="iconfont" name="iconzhengchang" size="52" color="#111"
v-if="orderStatus.code == 1"></u-icon>
<text style="
margin-left: 26rpx;
font-size: 40rpx;
font-weight: 600;
color: #111;
">
{{ orderStatus.text }}
</text>
<view class="orderStatusBox column" style="margin-bottom: 30rpx;justify-content: space-between">
<view class="row-sbas-n">
<view class="row items-center">
<u-icon customPrefix="iconfont" name="icondaizhifu-" size="52" color="#DFBE6E"
v-if="orderStatus.code == 0"></u-icon>
<u-icon customPrefix="iconfont" name="iconquxiao" size="52" color="#f26c6c"
v-if="orderStatus.code == -1"></u-icon>
<u-icon customPrefix="iconfont" name="iconshenhezhong" size="52" color="#86d9a5"
v-if="orderStatus.code == -2"></u-icon>
<u-icon customPrefix="iconfont" name="iconzhengchang" size="52" color="#111"
v-if="orderStatus.code == 1"></u-icon>
<text style="
margin-left: 26rpx;
font-size: 40rpx;
font-weight: 600;
color: #111;
">
{{ orderStatus.text }}
</text>
</view>
<u-count-down :showDays="false" :showHours="false" :timestamp="remainingSeconds"
@change="changeSeconds"
v-if="orderData.directOrder.OrderStatus==1" color="#000" separator-color="#000" :show-days="false" bg-color="transparent"></u-count-down>
</view>
<view class="RemainderBox" v-if="remainingSeconds">
<text>剩余支付时间:</text>
<text>{{formattedTime}}</text>
<view class="timecontent q-mt-sm">
<view v-if="orderData.directOrder.OrderStatus&&orderData.directOrder.OrderStatus==1">
<view class="row">
<text>请您于{{dielineTime}}前支付:¥</text>
<text class="bold">{{ DanWei }}{{(orderData.model.TotalPrice-orderData.model.DiscountMoney).toFixed(2)}}</text>
</view>
<view class="small">
完成支付才能锁定酒店</view>
</view>
<view class="small" v-else-if="orderData.directOrder.OrderStatus==2||(orderData.directOrder.OrderStatus&&orderData.directOrder.OrderStatus==4)">
取消原因:用户超时未付款,自动取消
</view>
<view class="small" v-else>
感谢您的预定,服务专员将会持续为您提供服务
</view>
</view>
</view>
<view class="orderIforRzBox row">
<view class="orderIforRzImg">
<img style="width: 14rpx;height: 68rpx;"
......@@ -258,6 +276,7 @@
</button>
</view>
</view>
</view>
</template>
......@@ -311,6 +330,8 @@
isExpired: false,
countdownInterval: null,
currentTime: Date.now(),
endts:0,
dielineTime: '',
};
},
computed: {
......@@ -321,11 +342,10 @@
}
},
beforeDestroy() {
this.clearInterval()
},
onHide() {
// 清除所有定时器
this.clearInterval()
},
created() {
this.Up = uni.getStorageSync("mall_UserInfo") ?
......@@ -350,6 +370,18 @@
this.getdidaMealType()
},
methods: {
changeSeconds(seconds) {
if(seconds<=0) {
let cancelMsg = {
OrderNo: this.orderData.directOrder.OrderNo,
ErpOrderId: this.orderData.model.OrderID,
OrderTypeStr: "Hotel", //订单类型为酒店
ConfirmID: "",
Amount: 0,
};
this.cancelOrder(cancelMsg,1)
}
},
payHotelOrder() {
let userInfo = uni.getStorageSync("mall_UserInfo");
var payMsg = {
......@@ -466,7 +498,7 @@
}
})
},
cancelOrder(postMsg) {
cancelOrder(postMsg,type) {
this.apipost(
"post_CancelThirdHotelOrder", postMsg,
(res) => {
......@@ -475,6 +507,7 @@
title: "操作成功",
icon: "success",
});
if(type) this.orderData.directOrder.OrderStatus = 4;
this.getOrderDetail(this.id)
}
},
......@@ -540,7 +573,6 @@
this.orderData.directOrder.CreateTime = this.$utils.formatDates(new Date(tempData.directOrder.CreateTime), 'yyyy-MM-dd hh:mm:ss')
// 支付倒计时
console.log(tempData.directOrder.OrderStatus,'--------')
if (this.orderData.directOrder.CreateTime&&tempData.directOrder.OrderStatus==1) {
const now = Date.now();
// const customStr = '2025-05-12 14:33:47'
......@@ -554,9 +586,20 @@
const diff = this.orderTime + 5 * 60 * 1000 - now; // 5分钟倒计时
let remainingSeconds = Math.max(diff, 0); // 确保不出现负数
this.remainingSeconds = Math.floor(remainingSeconds/1000)
// 启动倒计时
if(this.remainingSeconds) this.startCountdown()
else this.handleTimeout()
let endTime = new Date(this.orderData.directOrder.CreateTime)
endTime.setHours(endTime.getHours()+6)
this.endts = this.remainingSeconds
console.log(this.endts,'----------')
if(this.endts<=0){
this.cancleOrderHandle()
}
const m = Math.floor(this.remainingSeconds / 60)
const s = this.remainingSeconds % 60
this.dielineTime = `${m}${s}秒`
// // 启动倒计时
// if(this.remainingSeconds) this.startCountdown()
// else this.handleTimeout()
}
......@@ -580,37 +623,6 @@
}
);
},
clearInterval() {
if (this.countdownInterval) {
clearInterval(this.countdownInterval)
this.countdownInterval = null
}
},
handleTimeout() {
if(this.isExpired) return this.clearInterval()
this.isExpired = true
if (this.submitCancel) return
let cancelMsg = {
OrderNo: this.orderData.directOrder.OrderNo,
ErpOrderId: this.orderData.model.OrderID,
OrderTypeStr: "Hotel", //订单类型为酒店
ConfirmID: "",
Amount: 0,
};
this.getOrderDetail(this.id)
// this.cancelOrder(cancelMsg)
},
startCountdown() {
this.countdownInterval = setInterval(() => {
if (this.remainingSeconds > 0) {
this.remainingSeconds--
} else {
this.handleTimeout()
}
}, 1000)
},
//未付款是初始化预定房型,餐型等,
initBookHotel() {
var cMsg = {
......@@ -1397,4 +1409,50 @@
font-size: 20px;
font-weight: 600;
}
.timecontent{
font-size: 26rpx;
padding: 0 30rpx;
margin-bottom: 20rpx;
}
.f-order .bold{
font-weight: bold;
}
.f-order .small{
font-size: 22rpx;
}
.f-order .flight-status {
background: #E1C278;
border-radius: 8rpx;
font-size: 24rpx;
color: #111111;
font-weight: 400;
padding: 7rpx 14rpx;
}
.day-diff{
position: absolute;
top: -35rpx;
line-height: 1;
font-size: 22rpx;
color: #FF5858;
left: 4rpx;
}
.thin{
line-height: 1;
margin-top: 16rpx;
font-weight: 400;
font-size: 22rpx;
color: #9999A5;
max-width: 45px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.f-order .used-time{
margin-top: -16rpx;
}
.f-order .how-time{
height: 24rpx;
font-size: 20rpx;
color: #9999A5;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment