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
|
Page({
data: {
// 设置拖动组件的初始位置
x:340,
y: 0,
goodsList: [
{id: 15, pic: "https://images.pexels.com/photos/2113994/pexels-photo-2113994.jpeg", name: "手表", price: 699},
{id: 17, pic: "https://images.pexels.com/photos/221185/pexels-photo-221185.jpeg", name: "平板", price: 1900},
{id: 20, pic: "https://images.pexels.com/photos/1203803/pexels-photo-1203803.jpeg", name: "相机", price: 8150},
{id: 21, pic: "https://images.pexels.com/photos/270640/pexels-photo-270640.jpeg", name: "键盘", price: 2168}
],
},
onLoad(){
this.getCartHeight()
},
getCartHeight(){
// 页面初始化时 设置购物车初始位置为 停留在页面高度的2/3的位置 也可以设置成其他值
const height = Math.floor((wx.getSystemInfoSync().windowHeight)*2/3);
this.setData({
y: height
})
// 获取 自定义导航栏 时 页面高度
let customWindowHeight = wx.getSystemInfoSync().windowHeight
// console.log('customWindowHeight', customWindowHeight)
let navH = wx.getStorageSync('navigationBarHeight') + wx.getStorageSync('statusBarHeight')
// console.log('navH', navH)
let contentHeight = customWindowHeight - navH*2
this.setData({
contentHeight
})
},
})
|