index.js
6.81 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
// packageEquity/pages/parking/index/index.js
const STATUS = [{
label: '空闲', value: 1, name: 'idleStatusCount'
},
{
label: '占用', value: 2, name: 'occupyStatusCount'
},
{
label: '未知', value: 0, name: 'unknowStatusCount'
}
]
Page({
/**
* 页面的初始数据
*/
data: {
animationData: {},
drawerHeight: 456, // 当前抽屉的高度
touchStartY: 0, // 触摸起始位置
touchMoveY: 0, // 触摸移动位置
drawerExpanded: false, // 抽屉是否展开的标志
isRotate: false,
boxHeight: 456,
scale: 16,
markers: [],
STATUS,
tabIndex: '',
customCalloutMarkerIds: [],
num: 1,
},
touchStart(event) {
this.setData({
touchStartY: event.touches[0].clientY
});
},
touchMove(event) {
const { touchStartY, drawerHeight } = this.data;
const touchMoveY = event.touches[0].clientY;
const diffY = touchMoveY - touchStartY;
const newDrawerHeight = Math.max(drawerHeight - diffY, 0); // 根据实际需求设置抽屉的最小高度
const animation = wx.createAnimation({
duration: 0
});
animation.height(newDrawerHeight + 'rpx').step();
this.setData({
animationData: animation.export(),
drawerHeight: newDrawerHeight
});
},
touchEnd() {
const { drawerHeight } = this.data;
const { windowHeight } = wx.getSystemInfoSync();
if (drawerHeight > windowHeight * 0.5) {
// 抽屉高度大于屏幕高度的一半时,展开抽屉
this.expandDrawer();
} else {
// 否则收起抽屉
this.collapseDrawer();
}
},
expandDrawer() {
// const animation = wx.createAnimation({
// duration: 300,
// timingFunction: 'ease-out'
// });
// animation.height('100%').step();
this.setData({
drawerHeight: 850,
drawerExpanded: true
});
},
collapseDrawer() {
this.setData({
drawerHeight: 456,
});
},
pullH() {
const { boxHeight } = this.data
this.setData({ boxHeight: boxHeight == 850 ? 456 : 850 })
},
getCarPosition(latitude, longitude) {
const normalCallout = {
id: 0,
latitude,
longitude,
width: 32,
height: 32,
iconPath: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/wuye/home/parking/location.png',
}
const { markers } = this.data
this.setData({
latitude, longitude,
markers: [normalCallout, ...markers],
})
},
handleRefresh() {
this.parkingSpaceList()
this.setData({ isRotate: true })
setTimeout(() => {
this.setData({ isRotate: false })
}, 1000)
},
getAllParking() {
let {
merchantId
} = wx.p.storage.get('merchant_info')
wx.p.api.equityApi.parkingSpaceList({ locateFlag: 1,merchantId }).then(res => {
const normalCallout = [], list = res.responseList || [];
list.forEach((item, index) => {
normalCallout.push({
id: item.id,
latitude: item.parkingAddressLat,
longitude: item.parkingAddressLng,
width: 32,
height: 32,
iconPath: `https://img02.glsx.com.cn/weapp/resource/miniprogram/wuye/home/parking/${item.parkingStatus == 1 ? 'idle' : item.parkingStatus == 2 ? 'occupy' : 'unknown'}.png`,
callout: {
content: `${item.parkingArea}-${item.parkingBuilding}-${item.parkingFloor} >`,
color: '#666',
fontSize: 10,
borderWidth: 1,
borderRadius: 22,
borderColor: '#FFFFFF',
padding: 6,
display: 'BYCLICK',
textAlign: 'center'
},
})
})
const { markers } = this.data
this.setData({ markers: [...normalCallout, ...markers], isEmpty: normalCallout.length })
})
},
parkingSpaceList() {
let { tabIndex } = this.data ,{
merchantId
} = wx.p.storage.get('merchant_info')
wx.p.api.equityApi.parkingSpaceList({ locateFlag: 1, parkingStatusList: tabIndex === ''?null:[tabIndex],merchantId }).then(res => {
const list = res.responseList || [];
this.setData({ carList: list, parking: res })
})
},
/**
* 点击冒泡
*/
callouttap(e) {
wx.p.router.go('/packageEquity/pages/parking/detail/detail', { id: e.markerId })
},
tolower() {
console.log(88)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.parkingSpaceList()
this.getAllParking()
wx.getLocation({
type: 'gcj02',
success: res => {
this.getCarPosition(res.latitude, res.longitude)
}
})
},
controltap(e) {
// 创建 map 上下文 MapContext 对象。建议使用 wx.createSelectorQuery 获取 context 对象
// 获取地图,map要与wxml页面的id名一致。注意:不需要#符号
let mpCtx = wx.createMapContext('myMap')
// 将地图中心移置当前定位点,此时需设置地图组件 show-location 为true。'2.8.0' 起支持将地图中心移动到指定位置。
mpCtx.moveToLocation()
console.log(mpCtx)
// 将地图缩放值改为初始值
this.setData({
scale: 16
})
},
markertap(e) {
},
selectTab(e) {
let { index } = e.currentTarget.dataset,{tabIndex} = this.data;
if(tabIndex === index) index = ''
this.setData({ tabIndex:index }, () => {
this.parkingSpaceList()
})
},
jump(e) {
const { id } = e.currentTarget.dataset
wx.p.router.go('/packageEquity/pages/parking/detail/detail', { id })
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})