main.js
2.03 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
import Vue from 'vue';
import App from './App';
import '@/config/umtrack.js';
import cache from '@/utils/cache';
import { formatImagePath } from '@/utils/imagePath';
Vue.config.productionTip = false;
Vue.prototype.formatImagePath = formatImagePath;
import uView from '@/uni_modules/uview-ui';
Vue.use(uView);
let colorPrimary = '#1E7B6B';
uni.$u.setConfig({
config: {
color: {
'u-primary': colorPrimary,
},
},
props: {
line: {
color: 'rgba(151, 151, 151, 0.2)'
},
swiper: {
bgColor: 'inherit'
},
tabs: {
lineColor: colorPrimary,
},
steps: {
activeColor: colorPrimary,
},
radio: {
activeColor: colorPrimary,
},
checkbox: {
activeColor: colorPrimary,
},
picker: {
confirmColor: colorPrimary,
},
switch: {
activeColor: colorPrimary,
},
input: {
fontSize: 'inherit'
},
text: {
size: 'inherit',
color: 'inherit'
},
icon: {
color: 'inherit'
},
}
});
// 混入与组件List相关的页面生命周期
Vue.mixin({
onPullDownRefresh() {
if (this.mpType === 'page' && this.$refs.list) this.$refs.list.pullDownRefresh();
},
onReachBottom() {
if (this.mpType === 'page' && this.$refs.list) this.$refs.list.reachBottom();
},
methods: {
onSearch(config) {
if (this.mpType === 'page' && this.$refs.list) this.$refs.list.search(config);
},
}
});
// 页面内获取当前页面参数
Object.defineProperty(Vue.prototype, '$params', {
get: function get() {
const routes = getCurrentPages();
return routes[routes.length - 1].options;
},
});
import store from './store'
Vue.config.productionTip = false;
Vue.prototype.$store = store;
Vue.prototype.$cache = cache;
App.mpType = 'app';
const app = new Vue({
store,
...App
});
require('@/utils/uniapp.js')(uni);
// 引入请求封装,将app参数传递到配置中
require('@/config/request.js')(app);
// http接口API抽离,免于写url或者一些固定的参数
require('@/common/api.js')(app);
app.$mount();