main.js
2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import App from './App'
import store from './store'
// 引入封装的接口api
import common from "./common/common.js";
import { myRequest } from './common/requestServer.js'
//引入封装的过滤器 filters
import filters from './common/filters.js'
// 挂在Vue属性 全局通过this.$myRequest()可以访问到
Vue.prototype.$common = common
Vue.prototype.$myRequest = myRequest
// 添加全局filter
Object.keys(filters).map(v => {
Vue.filter(v, filters[v])
})
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
Vue.prototype.$store = store
Vue.prototype.$adpid = "1111111111"
Vue.prototype.$backgroundAudioData = {
playing: false,
playTime: 0,
formatedPlayTime: '00:00:00'
}
Vue.filter('priceFormat', function(value, arg) {
return (value / 100).toFixed(2)
})
Vue.filter('timeFormat', function(value, arg) {
var time = '';
if (null != value && "" != value) {
var timer = parseInt(value);
if (timer == 0) {
return '0秒';
}
var days = parseInt(timer / (60 * 60 * 24));
var hours = parseInt((timer % (60 * 60 * 24)) / (60 * 60));
var minutes = parseInt((timer % (60 * 60)) / (60))
var seconds = parseInt(timer % (60));
if (days > 0) {
time = time + days +'天';
}
if (hours > 0) {
time = time + hours +'小时';
}
if (minutes > 0) {
time = time + minutes +'分钟';
}
if (seconds > 0) {
time = time + seconds +'秒';
}
return time;
}
return time;
})
Vue.prototype.getGlobalUser = function(key) {
var userInfo = uni.getStorageSync("globalUser");
if (userInfo != null && userInfo != "" && userInfo != undefined) {
return userInfo;
} else {
return null;
}
}
Vue.prototype.getWxOpenid= function(key) {
var WxOpenid = uni.getStorageSync("WxOpenid");
if (WxOpenid != null && WxOpenid != "" && WxOpenid != undefined) {
return WxOpenid;
} else {
return "";
}
}
App.mpType = 'app'
const app = new Vue({
store,
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import {
createSSRApp
} from 'vue'
export function createApp() {
const app = createSSRApp(App)
app.use(store)
app.config.globalProperties.$adpid = "1111111111"
app.config.globalProperties.$backgroundAudioData = {
playing: false,
playTime: 0,
formatedPlayTime: '00:00:00'
}
return {
app
}
}
// #endif