-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
81 lines (71 loc) · 2.13 KB
/
Copy pathapp.js
File metadata and controls
81 lines (71 loc) · 2.13 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
import {
initPlayer
} from "utils/player.js";
import {
initDB
} from "utils/database.js";
//app.js
App({
onLaunch: function () {
let global = this.globalData;
//云开发初始化
wx.cloud.init({
env: 'relaxion-v1vxd',
traceUser: true
})
// 数据库
global.DB = initDB();
// 获取 openId
wx.cloud.callFunction({
name: 'get_openid',
complete: res => {
global.openid = res.result.openid
if (this.openidReady) {
this.openidReady(res)
}
global.DB.initid(res.result.openid)
}
})
// 创建音乐播放器
global.musicPlayer = initPlayer();
// 获取导航栏相关信息
let menuButton = wx.getMenuButtonBoundingClientRect();
wx.getSystemInfo({
complete: (res) => {
let statusBarHeight = res.statusBarHeight;
let menuButtonTop = menuButton.top;
// 自定义导航栏的高度
global.nav.height = menuButton.height + 2 * (menuButtonTop - statusBarHeight);
// 导航栏上下边界与胶囊按钮的缝隙
global.nav.strip = menuButtonTop - statusBarHeight;
// 状态栏的高度,即导航栏与屏幕上方的距离
global.nav.top = statusBarHeight;
// 导航栏内容距离左侧屏幕的距离,此处与胶囊按钮距离右侧的距离相同
global.nav.left = res.windowWidth - menuButton.right;
// 导航栏内容距离右侧屏幕的距离,保证不会与胶囊按钮重叠
global.nav.right = menuButton.width + global.nav.left;
// 导航栏本身的最大宽度
global.nav.width = res.safeArea.width;
// 包括导航栏在内的整个窗口的高度
global.window.height = res.windowHeight;
// 导航栏下方用于显示内容的窗口高度
global.window.contentHeight = res.windowHeight - statusBarHeight - global.nav.height;
},
})
},
globalData: {
musicPlayer: null,
nav: {
height: 40,
top: 20,
strip: 4,
left: 10,
right: 10,
width: 320
},
window: {
contentHeight: 460,
height: 520
}
}
})