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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
* @Description: In User Settings Edit
* @Author: your name
* @Date: 2019-09-24 12:34:06
* @LastEditTime: 2019-09-24 12:34:06
* @LastEditors: your name
*/
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import router from './router'
import App from './App'
import Vuex from 'vuex'
import vuexI18n from 'vuex-i18n'
import flexible from './common/ydui.flexible'
import components from './components/component'
import {componentInstall, appStyle} from 'hls-easy-ui'
/**
* 指令
*/
import directives from './scripts/directives'
import filter from './scripts/filter'
import './scripts/prototype'
/**
* 组件
*/
// import component from './components/component.js'
import {
Tabbar,
TabbarItem,
} from 'vux'
/**
* 弹框组件
*/
import hlsPopup from './scripts/hlsPopup'
/**
* http
*/
import {post, get} from './scripts/hlsHttp'
/** 全局函数hlsUtil**/
import hlsUtil from './scripts/hlsUtil'
/** end**/
/**
* jpush jmessage
*/
import Jpush from './scripts/jpushService'
import Jmessage from './scripts/jmessageService'
// if (process.env.CONFIG_ENV === 'uat') {
//const VConsole = require('vconsole')
// new VConsole() // eslint-disable-line
// }
Vue.use(componentInstall)
Vue.use(components)
Vue.use(appStyle)
Vue.use(flexible)
Vue.use(directives)
Vue.use(filter)
// Vue.use(component)
Vue.use(Vuex)
Vue.component('tabbar', Tabbar)
Vue.component('tabbar-item', TabbarItem)
/** i18n **/
let store = new Vuex.Store({
modules: {
i18n: vuexI18n.store,
},
})
Vue.use(vuexI18n.plugin, store)
Vue.prototype.hlsPopup = window.hlsPopup = hlsPopup
Vue.prototype.$devicePixelRatio = 2
Vue.prototype.$post = post
Vue.prototype.$get = get
let hlsHttp = {
get: get,
post: post,
}
Vue.prototype.hlsHttp = window.hlsHttp = hlsHttp
Vue.prototype.hlsUtil = window.hlsUtil = hlsUtil
Vue.prototype.Jpush = window.Jpush = Jpush
Vue.prototype.Jmessage = window.Jmessage = Jmessage
/**
* 全局返回上一页面
* @param index
*/
let routeGo = function (index) {
if (!index) {
index = -1
}
this.$router.go(index)
}
Vue.prototype.$routeGo = routeGo
FastClick.attach(document.body)
Vue.config.productionTip = false
let backButtonPressedOnceToExit
vum.$vumPlatform.ready(function () {
if ((vum.Platform.isAndroid()) || (vum.Platform.isIOS())) {
/* window.getRegistrationID = function (callback){
callback('')
}*/
try {
setTimeout(function () {
navigator.splashscreen.hide()
if (window.plugins.jPushPlugin) {
Jpush._init()
}
if (window.JMessagePlugin) {
Jmessage._init({'isOpenMessageRoaming': true})
}
}, 40)
} catch (e) {
}
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true)
cordova.plugins.Keyboard.disableScroll(true)
}
if (window.StatusBar) {
window.StatusBar.styleDefault()
window.StatusBar.backgroundColorByName('white')
}
const winSize = vum.$vumPlatform.getWinSize()
if (winSize.width) {
window.localStorage.setItem('width', winSize.width)
}
if (winSize.height) {
window.localStorage.setItem('height', winSize.height)
}
}
})
vum.$vumPlatform.registerBackButtonAction(function (e) {
// let vm = this
let time
let path = router.currentRoute.path
if (path === '/tab/home' || path === '/tab/message' || path === '/tab/my-info') {
// 进入主界面清除缓存
if (backButtonPressedOnceToExit === true) {
vum.Platform.exitApp()
} else {
backButtonPressedOnceToExit = true
hlsPopup.showLongBottom('再次点击返回键退出应用')
clearTimeout(time)
time = setTimeout(function () {
backButtonPressedOnceToExit = false
}, 1500)
}
} else if (path === '/login' || path === '/finger-login' || path === '/gesture') {
vum.Platform.exitApp()
} else {
router.go(-1)
}
e.preventDefault()
return false
}, 101)
/* eslint-disable no-new */
new Vue({
data () {
return {
pathList: [],
transitionName: null,
}
},
router,
watch: { // 监听路由变化
$route (to, from) {
document.body.scrollTop = 0
document.documentElement.scrollTop = 0
},
},
render: h => h(App),
}).$mount('#app-box')