App.vue
5.62 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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!--
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-07 17:09:53
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-12-21 14:41:41
* @FilePath: \gl_tape\App.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script>
const PATH = ['/pages/common/caseDetail']
import { mapState } from 'vuex'
import { Ws } from '@/ws/Ws.js'
export default {
computed: {
...mapState('audio', ['isEnd', 'isStart'])
},
onLoad() {},
onLaunch: async function () {
// this.init()
this.setAPPVersion()
setTimeout(() => {
plus.screen.unlockOrientation() //解除锁定屏幕方向
plus.screen.lockOrientation('landscape-primary')
}, 300)
uni.setKeepScreenOn({
keepScreenOn: true
})
new Ws().connect()
this.getAllApply()
},
methods: {
getAllApply() {
// #ifdef APP-PLUS
const main = plus.android.runtimeMainActivity()
const pManager = plus.android.invoke(main, 'getPackageManager')
const ApplicationInfo = plus.android.importClass('android.content.pm.ApplicationInfo')
const packages = plus.android.invoke(pManager, 'getInstalledPackages', 0)
const total = plus.android.invoke(packages, 'size')
let appInfoList = []
for (let i = 0; i < total; i++) {
try {
const packageInfo = plus.android.invoke(packages, 'get', i)
// 获取包名
const packName = plus.android.getAttribute(packageInfo, 'packageName')
const versionName = plus.android.getAttribute(packageInfo, 'versionName')
const versionCode = plus.android.getAttribute(packageInfo, 'versionCode')
const appInfo = plus.android.invoke(pManager, 'getApplicationInfo', packName, 0)
const appName = plus.android.invoke(pManager, 'getApplicationLabel', appInfo)
// 是否是系统软件
const isSystem = packageInfo.plusGetAttribute('applicationInfo').plusGetAttribute('flags') & (ApplicationInfo.FLAG_SYSTEM != 0) ? true : false
// 判断是否是系统文件
if (!isSystem) {
appInfoList.push({
packName,
versionName,
versionCode,
appName
})
}
} catch (e) {}
}
plus.android.autoCollection(main)
const { deviceId: tabletSerialNumber } = uni.getDeviceInfo()
uni.$api.commonApi
.saveOrUpdateEmployeeAppUsage({ tabletSerialNumber, appVersion: plus.runtime.version, gameAppList: JSON.stringify(appInfoList) })
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
// #endif
},
init() {
uni.addInterceptor('navigateTo', {
//监听跳转
invoke(e) {
console.log('******** invoke-navigateTo ********', e.url.split('?').shift())
if (PATH.includes(e.url.split('?').shift())) {
console.log(888)
}
}
})
//2
uni.addInterceptor('redirectTo', {
//监听关闭本页面跳转
invoke(e) {
console.log('******** redirectTo ********', e.url)
}
})
uni.addInterceptor('switchTab', {
//监听tabBar跳转
invoke(e) {
console.log('******** switchTab ********', e.url)
}
})
//4
uni.addInterceptor('navigateBack', {
//监听返回
invoke(e) {
console.log('******** navigateBack ********', e)
}
})
},
setAPPVersion() {
let version = plus.runtime.version
let storageVersion = uni.$storage.get('storageVersion')
console.log(storageVersion, version)
if (storageVersion != version) {
uni.$storage.rm('userInfo')
uni.$storage.rm('noSignInUuid')
}
uni.$storage.set('storageVersion', version)
}
},
onShow: async function () {
uni.$logger.local.info('切回app')
// const systemInfo = await uni.$api.systemApi.getMockData();
// if (systemInfo.isCheckedUpdate) {
// checkUpdate();
// }
// let version = plus.runtime.version;
// uni.$api.commonApi.getAPPVersion().then((res) => {
// if (res != version && !systemInfo.isCheckedUpdate)
// this.$store.dispatch("openUpdateModal");
// });
},
onHide: function () {
uni.$logger.local.info('切出app')
},
onError: function (e) {
try {
uni.$logger?.error({ msg: e.message || '捕获全局异常', extra: { error: typeof e == 'string' ? e : JSON.stringify(e) } })
} catch (error) {
console.log(error)
}
}
}
</script>
<style lang="scss">
body {
// overflow: hidden;
}
page {
font-size: toRpx(28);
height: 100%;
min-height: 100%;
}
view,
navigator,
image,
text,
scroll-view,
swiper,
swiper-item,
input,
textarea,
button {
box-sizing: border-box;
}
/* 文字避头尾法则 */
.btw {
table-layout: fixed;
word-wrap: break-word;
word-break: normal;
text-align: justify;
text-justify: inter-ideograph;
}
.bg-white {
background: #fff;
}
.font-weight {
font-weight: bold;
}
.u-flex-center {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
button {
margin: 0;
padding: 0;
line-height: 1.5;
font-size: toRpx(28);
background-color: transparent;
border-radius: 0;
position: relative;
}
button::after {
border: none;
}
// 指定按钮按下去的样式类
.button-hover {
transform: translate(toRpx(1), toRpx(1));
}
.webview-container {
position: absolute;
width: toRpx(100);
height: toRpx(100);
top: 0;
left: 0;
}
</style>