Files
hht-ximenzi-uni/main.js

99 lines
2.4 KiB
JavaScript
Raw Normal View History

2024-08-19 15:45:30 +08:00
import App from './App'
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
Vue.directive('enterNumber', {
inserted: function (el) {
el.addEventListener("keypress",function(e){
e = e || window.event;
let charcode = typeof e.charCode == 'number' ? e.charCode : e.keyCode;
// if (parseInt(e.target.value) == 0) {
// e.preventDefault();
// }
parseInt(e.target.value) == 0 && e.preventDefault();
let re = /\d/;
if(!re.test(String.fromCharCode(charcode)) && charcode > 9 && !e.ctrlKey){
if(e.preventDefault){
e.preventDefault();
}else{
e.returnValue = false;
}
}
});
}
});
2024-09-20 11:24:16 +08:00
// 全局计时
2024-09-20 13:28:39 +08:00
// 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;
// }
// }
// };
2024-09-20 11:24:16 +08:00
Vue.prototype.$globalData = {
timer: null,
startTimer: function() {
const self = this;
2024-09-20 13:28:39 +08:00
self.timer = setTimeout(function() {
clearTimeout(self.timer);
// console.log('延时器结束1');
uni.showModal({
title: '提示',
showCancel: false,
content: '路线锁定未释放,请操作完成再退出!',
success: (res) => {
if (res.confirm) {
Vue.prototype.$globalData.startTimer()
}
}
})
2024-09-20 13:41:58 +08:00
}, 900000);
2024-09-20 11:24:16 +08:00
},
stopTimer: function() {
if (this.timer) {
2024-09-20 13:28:39 +08:00
clearTimeout(this.timer);
// console.log('延时器结束2');
2024-09-20 11:24:16 +08:00
this.timer = null;
}
}
};
2024-08-19 15:45:30 +08:00
import store from '@/vuex/store.js'
const app = new Vue({
...App,
store
})
app.$mount()