You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.2 KiB
JavaScript

import App from './App'
import tui from './common/httpRequest'
import store from './store'
// #ifndef VUE3
//网络监听
setTimeout(() => {
uni.onNetworkStatusChange(function(res) {
//console.log(res.networkType);
store.commit("networkChange", {
isConnected: res.isConnected
})
});
}, 100)
// #endif
Vue.prototype.checkLogin = function(backpage, backtype) {
var Token = uni.getStorageSync('Token');
if (Token == '' || Token == null || Token == undefined) {
uni.redirectTo({
url: "../login/login?backpage=" + backpage + "&backtype=" + backtype
});
return false;
}
return [Token];
}
Vue.prototype.formatdate = function(date) {
if (date == null || date == '') {
return '';
}
date = new Date(date);
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return [year, month, day].map(formatNumber).join('-');
}
Vue.prototype.formattime = function(date) {
date = new Date(date)
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
var h = date.getHours();
h = h < 10 ? ('0' + h) : h;
var minute = date.getMinutes();
var second = date.getSeconds();
minute = minute < 10 ? ('0' + minute) : minute;
second = second < 10 ? ('0' + second) : second;
return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
}
Vue.prototype.formatTtime = function(value) {
// var dateee = new Date(value).toJSON();
var date = new Date(value).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
return date
}
const padLeftZero = str => {
return ('00' + str).substr(str.length);
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
Vue.prototype.tui = tui
Vue.prototype.$eventHub = Vue.prototype.$eventHub || new Vue()
Vue.prototype.$store = store
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
// #endif