App.vue
2.25 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
<script>
import * as loginServer from '@/common/login.js';
import * as api from '@/common/api.js';
import config from '@/config.js';
let firstload = false
export default {
onLaunch: function() {
console.log('App Launch');
firstload = true
this.globalData.baseUrl = config.baseUrl;
this.globalData.baseUrl_api = config.baseUrl_api;
this.globalData.fileUrl = config.fileUrl;
uni.getSystemInfo({
success: function(res) {
console.log(111, res)
const model = res.model
let stt = ''
// 判断机型
if (model.includes('iPhone')) {
stt = 'iPhone'
} else if (model.includes('iPad')) {
stt = 'iPad'
} else if (model.includes('Android')) {
stt = 'Android'
} else {
stt = '其他'
}
uni.setStorageSync('systemType', stt);
}
})
new Promise((resolve, reject) => {
uni.checkSession({
success: res => {
loginServer
.getCurrUser(true)
.catch(() => {
return loginServer.pcLogin();
})
.then(user => {
resolve(user);
});
},
fail: res => {
loginServer
.wxLogin()
.then(loginRes => {
return loginServer.pcLogin(loginRes.code);
})
.then(user => {
resolve(user);
});
}
});
// loginServer
// .wxLogin()
// .then(loginRes => {
// return loginServer.pcLogin(loginRes.code)
// })
// .then(loginServer.getCurrUser)
// .then(user=>{
// resolve(user);
// });
})
.then(() => {
this.globalData.isLogin = true;
let firstLoadCallback = getApp().firstLoadCallback;
if (firstLoadCallback) {
firstLoadCallback();
}
});
},
onShow: function() {
console.log('App Show', uni.getStorageSync('isRegister'));
},
onHide: function() {
console.log('App Hide');
const isRegister = uni.getStorageSync('isRegister')
if (isRegister == '0') {
uni.setStorageSync('isRegister', '1');
}
}
};
</script>
<style lang="scss">
/*每个页面公共css */
@import '/common/uni.css';
@import '/common/mystyle.scss';
@import '@/static/font/iconfont.css';
</style>