-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.vue
283 lines (258 loc) · 7.21 KB
/
App.vue
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<script>
import store from '@/store/store.js'
import {$api} from '@/config/api.js';
export default {
globalData: {
$i18n: {},
$t: {},
store
},
onLaunch() {
// let date = new Date(),
// hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours()
// if(!this.heiye&&hour!==15){
// console.log(2222)
// uni.setStorageSync('heiye',{type:false})
// }
// if(this.heiye===null&&hour==15){
// console.log(1111)
// uni.setStorageSync('heiye',{type:true})
// }
this.globalData.$i18n = this.$i18n
this.globalData.$t = str => this.$t(str)
// 读取client_id
// this.channelIDSyncFunc()
// 数据初始化
this.dataInit();
//自动登录
this.autoLogin();
// 读取设备信息
// this.getEquipmentCode();
//下载
this.getDownLoad()
// 获取用户定制信息
this.userFormat();
setTimeout(() => {
// plus.navigator.closeSplashscreen();
}, 100)
//设置初始化
this.getSetting()
// plus.navigator.setStatusBarStyle('dark');
},
// computed: {
// heiye(){
// return uni.getStorageSync('heiye').type
// },
// },
methods: {
// 修改原生虚拟按键
getNativeBut(type){
if(uni.getSystemInfoSync().platform!=='android'){
return
}
var Color = plus.android.importClass("android.graphics.Color");
plus.android.importClass("android.view.Window");
var mainActivity = plus.android.runtimeMainActivity();
var window_android = mainActivity.getWindow();
if(type){
window_android.setNavigationBarColor(Color.argb(255,255,255,255));
}else{
window_android.setNavigationBarColor(Color.argb(255,0,0,0));
}
},
// 页面初始化
dataInit() {
this.$api.get("system/appinit").then(res => {
this.$store.commit("setInit", res.data.data);
})
},
// 获取客户信息
userFormat() {
this.$api.get(`system/box_front_setup`).then(res => {
let userFormat = res.data.data.front_setup
userFormat.down_app_url = userFormat.down_app_url + this.$store.state.client_id;
this.$store.commit('setUserFormat', userFormat);
})
},
// 自动登录
autoLogin() {
this.$store.commit("setUserInfo", {});
if (uni.getStorageSync('mem-username') && uni.getStorageSync('mem-password')) {
let username = uni.getStorageSync('mem-username')
let password = uni.getStorageSync('mem-password')
this.$api.get("user/login", {
'mem-username': username,
'mem-password': password,
equipmentCode: this.equipmentCode
}).then(res => {
if (res.data.code == 200) {
// 将登录获取的数据记录下来
this.$store.commit("setLoginInfo", res.data.data)
// 获取用户信息
this.$common.getuserInfo();
}
})
} else if (uni.getStorageSync('mem-openid')) {
this.$api.get("user/login", {
"mem-openid": uni.getStorageSync('mem-openid'),
"mem-username": uni.getStorageSync('mem-username'),
"mem-oauth_type": uni.getStorageSync('mem-oauth_type'),
}).then(res => {
if (res.data.code == 200) {
// 将登录获取的数据记录下来
this.$store.commit("setLoginInfo", res.data.data)
// 获取用户信息
this.$common.getuserInfo();
}
})
} else if (uni.getStorageSync('sms-mobile')) {
this.$api.get("v8/user/loginm", {
"sms-mobile": uni.getStorageSync('sms-mobile'),
"sms-phone": '1',
"sms-type": '2',
}).then(res => {
console.log(res, 'sms-mobilesms-mobilesms-mobile')
// 将登录获取的数据记录下来
if (res.data.code == 200) {
if (res.data.data.is_pwd) {
uni.setStorageSync('mem-username', res.data.data.username)
uni.setStorageSync('sms-mobile',uni.getStorageSync('sms-mobile'))
this.$store.commit("setLoginInfo", res.data.data)
// 获取用户信息
this.$common.getuserInfo();
}
}
})
} else {
// 清空本地存储的登录数据
this.$store.commit('setInit', {});
this.$store.commit('setLoginInfo', {});
this.$store.commit('setUserInfo', {});
uni.setStorageSync('mem-openid', '')
uni.setStorageSync('mem-username', '')
uni.setStorageSync('mem-password', '')
uni.setStorageSync('sms-mobile','')
}
},
//设置初始化
getSetting() {
let heiye = uni.getStorageSync('heiye')
let isMessage = uni.getStorageSync('isMessage')
let isWifi = uni.getStorageSync('isWifi')
let isWifiDown = uni.getStorageSync('isWifiDown')
let isinstallGame = uni.getStorageSync('isinstallGame')
let isClearPackage = uni.getStorageSync('isClearPackage')
if (!isMessage) {
uni.setStorageSync('isMessage', {
type: 1,
status: true
})
}
if (!isWifi) {
uni.setStorageSync('isWifi',{
type: 1,
status: true
})
}
if (!isWifiDown) {
uni.setStorageSync('isWifiDown',{
type: 1,
status: true
})
}
if (!isinstallGame) {
uni.setStorageSync('isinstallGame',{
type: 1,
status: true
})
}
if (!isClearPackage) {
uni.setStorageSync('isClearPackage',{
type: 1,
status: true
})
}
if (!heiye) {
uni.setStorageSync('heiye',{
type: false,
})
this.getNativeBut(1)
}else if(heiye.type==false){
this.getNativeBut(1)
}else{
this.getNativeBut(0)
}
},
// 读取设备信息
getEquipmentCode() {
// #ifdef APP-PLUS
let that = this;
plus.device.getInfo({
success: function(e) {
that.$store.commit("setEquipmentCode", e.uuid);
},
fail: function(e) {
console.log(e);
}
});
// #endif
},
//下载管理
/* 无法持久化存储下载 */
getDownLoad() {
let arrList = uni.getStorageSync('downList')
if (arrList.length) {
let downList = []
arrList.map((item, index) => {
downList.push({
game_id: item.game_id,
downTasks: null,
status:1
})
})
this.$store.commit('setDownTasksList', downList)
}
},
// 获取channelId
channelIDSyncFunc() {
let ret;
let udid;
switch (uni.getSystemInfoSync().platform) {
case "android":
let getXWID = uni.requireNativePlugin("GetXWID")
ret = getXWID.channelIDSyncFunc();
// console.log(ret,'retretretretrets')
if (ret.channelid != 0) {
this.$store.commit('setClientId', ret.channelid);
} else {
this.$store.commit('setClientId', 4231);
}
break;
case "ios":
let channelModule = uni.requireNativePlugin("DCChannelUniPlugin-ChannelModule");
ret = channelModule.channelIdSyncFunc({
'name': 'uni-app',
'age': 1
}) || 4231
this.$store.commit('setClientId', ret);
udid = channelModule.udidSyncFunc({
'name': 'uni-app',
'age': 1
}) || ''
this.$store.commit('setUdid', udid);
console.log(udid,'udidudidudid')
break;
default:
break;
}
},
}
}
</script>
<style>
/* #ifndef APP-PLUS-NVUE */
/* @import "uview-ui/index.scss"; */
/* @import './static/fonts/iconfont.css'; */
/* #endif */
/* @import "./components/u-parse/u-parse.css" */
</style>