提示窗定时
This commit is contained in:
45
main.js
45
main.js
@@ -25,47 +25,14 @@ Vue.directive('enterNumber', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 全局计时
|
|
||||||
// Vue.prototype.$globalData = {
|
|
||||||
// timer: null,
|
|
||||||
// timerDuration: 20, // 假设是60秒
|
|
||||||
// startTimer: function() {
|
|
||||||
// const self = this;
|
|
||||||
// self.timer = setInterval(function() {
|
|
||||||
// self.timerDuration--;
|
|
||||||
// console.log('剩余时间:' + self.timerDuration + '秒');
|
|
||||||
// if (self.timerDuration <= 0) {
|
|
||||||
// clearInterval(self.timer);
|
|
||||||
// self.timerDuration = 20;
|
|
||||||
// console.log('计时器结束1');
|
|
||||||
// uni.showModal({
|
|
||||||
// title: '提示',
|
|
||||||
// showCancel: false,
|
|
||||||
// content: '路线锁定未释放,请操作完成再退出!',
|
|
||||||
// success: (res) => {
|
|
||||||
// if (res.confirm) {
|
|
||||||
// Vue.prototype.$globalData.startTimer()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// }, 1000);
|
|
||||||
// },
|
|
||||||
// stopTimer: function() {
|
|
||||||
// if (this.timer) {
|
|
||||||
// clearInterval(this.timer);
|
|
||||||
// console.log('计时器结束2');
|
|
||||||
// this.timer = null;
|
|
||||||
// this.timerDuration = 20;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
Vue.prototype.$globalData = {
|
Vue.prototype.$globalData = {
|
||||||
timer: null,
|
timer: null,
|
||||||
|
timerDuration: 900000,
|
||||||
startTimer: function() {
|
startTimer: function() {
|
||||||
const self = this;
|
const self = this;
|
||||||
self.timer = setTimeout(function() {
|
self.timer = setTimeout(function() {
|
||||||
clearTimeout(self.timer);
|
clearTimeout(self.timer);
|
||||||
|
self.timer = null;
|
||||||
// console.log('延时器结束1');
|
// console.log('延时器结束1');
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
@@ -73,17 +40,19 @@ Vue.prototype.$globalData = {
|
|||||||
content: '路线锁定未释放,请操作完成再退出!',
|
content: '路线锁定未释放,请操作完成再退出!',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
Vue.prototype.$globalData.startTimer()
|
self.timerDuration = 30000;
|
||||||
|
Vue.prototype.$globalData.startTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 900000);
|
}, self.timerDuration);
|
||||||
},
|
},
|
||||||
stopTimer: function() {
|
stopTimer: function() {
|
||||||
if (this.timer) {
|
if (this.timer) {
|
||||||
clearTimeout(this.timer);
|
clearTimeout(this.timer);
|
||||||
|
this.timer = null;
|
||||||
// console.log('延时器结束2');
|
// console.log('延时器结束2');
|
||||||
this.timer = null;
|
this.timerDuration = 900000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user