business-address.vue
10.5 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
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
<template>
<view class="map-box">
<text class="cuIcon-back" @tap="$Router.back()"></text>
<map
id="map"
:style="{ width: '750rpx', height: mapHeight + 'px' }"
:latitude="latitude"
:longitude="longitude"
:markers="markers"
:polyline="polyline"
:include-points="includePoints"
show-location
@tap="onMap"
></map>
<view ref="testdiv" class="dragLayer" :class="moveCard" @touchstart="handleTouchStart" @touchend="handleTouchEnd" @touchmove="handleTouchMove">
<view ref="oilStation" class="oilStation">
<!-- #ifndef APP-PLUS -->
<view class="oilStation-top">
<view class="touch-guide x-c" @tap="onShowCard">
<image class="touch-jintou" v-if="!showCard" src="/static/imgs/order/arrows1.png" mode=""></image>
<image class="touch-jintou" v-if="showCard" src="/static/imgs/order/arrows2.png" mode=""></image>
</view>
<!-- <div class="search-box x-f">
<text class="cuIcon-search"></text>
<input class="search-inp" placeholder-class="search-pl" placeholder="输入地址寻找周边自提点" type="text" value="" />
</div> -->
</view>
<!-- #endif -->
<scroll-view class="oilStation-bottom" enable-back-to-top :scroll-y="scrollable" @scrolltoupper="scrolltoupper" @scroll="scroll" @scrolltolower="scrolltolower">
<view class="page_box">
<view class="content_box" style="background-color: #fff;overflow-x: hidden;">
<label @tap="selStoreAddress(address.id, index)" v-for="(address, index) in addressList" :key="address.id">
<view class="address-item x-f">
<view class="address-left">
<view class="address-name">{{ address.name }}</view>
<view class="time-box ">
<view class="x-f">
<text class="cuIcon-time address-icon"></text>
{{ address.openhours }}
</view>
<view class="x-f" style="padding-left: 30rpx;margin-top: 20rpx;">
<text v-for="week in address.openweeks_arr" :key="week">{{ weekMap[week] }}、</text>
</view>
</view>
<view class="address-detail x-f">
<text class="cuIcon-location address-icon"></text>
{{ address.province_name }}{{ address.city_name }}{{ address.area_name }}{{ address.address }}
</view>
<view class="address-phone x-f">
<text class="cuIcon-phone address-icon"></text>
{{ address.phone }}
</view>
</view>
<view class="address-right y-f">
<radio class="round address-checked orange" :class="{ checked: storeId == address.id }" :checked="storeId == address.id"></radio>
<text class="address-distance">{{ address.distance_text || 0 }}</text>
</view>
</view>
</label>
<view class="more x-c"><text class="more-text">更多自提点,敬请期待</text></view>
</view>
<view class="foot_box x-c"><button class="cu-btn save-btn" @tap="onSave">确认</button></view>
</view>
</scroll-view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
longitude: 0,
latitude: 0,
mapHeight: 0,
cardHeight: 0,
showCard: false,
scrollable: false, // 初始化禁止滑动
moveCard: 'dragLayer-bottom',
// markers: [], //标记点
polyline: [],
distance: 0,
storeId: 0, //默认门店ID
includePoints: [], //可视区域点
addressList: [], //门店列表
storeInfo: [], //当前门店信息
weekMap: {
1: '周一',
2: '周二',
3: '周三',
4: '周四',
5: '周五',
6: '周六',
7: '周日'
}
};
},
computed: {
markers() {
if (this.addressList.length) {
let arr = [];
this.addressList.forEach(item => {
let obj = {
id: item.id,
latitude: item.latitude,
longitude: item.longitude,
// #ifdef APP-PLUS
iconPath: '/static/imgs/order/e1.png',
width: 100,
height: 100
// #endif
};
arr.push(obj);
});
return arr;
}
}
},
onLoad(options) {
this.latitude = this.$Route.query.lat;
this.longitude = this.$Route.query.lng;
this.storeId = this.$Route.query.storeId;
this.getStoreAddress();
},
onReady() {
let that = this;
this.editHeight();
},
onShow() {},
methods: {
// 选中门店
onSave() {
let pages = getCurrentPages();
// #ifdef MP-WEIXIN || APP-PLUS
let currPage = pages[pages.length - 1].$vm;
let prevPage = pages[pages.length - 2].$vm; //上一个页面
// #endif
// #ifdef H5
let currPage = pages[pages.length - 1];
let prevPage = pages[pages.length - 2]; //上一个页面
// #endif
prevPage.storeInfo = this.storeInfo.id ? this.storeInfo : this.addressList[0];
this.storeId == 0 ? this.$tools.toast('请选择门店') : this.$Router.back();
},
// 点击地图
onMap() {
this.showCard = false;
this.moveCard = 'dragLayer-bottom';
this.scrollable = false;
},
// 选择门店
selStoreAddress(id, index) {
this.storeId = id;
this.latitude = this.addressList[index].latitude;
this.longitude = this.addressList[index].longitude;
this.storeInfo = this.addressList[index];
},
// 获取商品支持的自提点。
getStoreAddress() {
let that = this;
that.$api('goods.storeAddress', {
id: that.$Route.query.goodsId,
latitude: that.$Route.query.lat,
longitude: that.$Route.query.lng
}).then(res => {
if (res.code == 1) {
that.addressList = res.data;
this.storeId = res.data[0].id;
}
});
},
// 设置地图,卡片高度。
editHeight() {
let that = this;
uni.getSystemInfo({
success: res => {
let view = uni
.createSelectorQuery()
.in(this)
.select('.dragLayer');
view.fields(
{
size: true,
scrollOffset: true
},
data => {
that.mapHeight = res.screenHeight - data.height;
console.log('card-height', data.height);
}
).exec();
}
});
},
// 获取角度
getAngle(angx, angy) {
return (Math.atan2(angy, angx) * 180) / Math.PI;
},
// 根据起点终点返回方向 1向上 2向下 3向左 4向右 0未滑动
getDirection(startx, starty, endx, endy) {
var angx = endx - startx;
var angy = endy - starty;
var result = 0;
//如果滑动距离太短
if (Math.abs(angx) < 2 && Math.abs(angy) < 2) {
return result;
}
var angle = this.getAngle(angx, angy);
if (angle >= -135 && angle <= -45) {
result = 1;
} else if (angle > 45 && angle < 135) {
result = 2;
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
result = 3;
} else if (angle >= -45 && angle <= 45) {
result = 4;
}
return result;
},
// 手势滑动开始
handleTouchStart(e) {
this.startx = e.changedTouches[0].pageX;
this.starty = e.changedTouches[0].pageY;
},
handleTouchMove(e) {},
// 手势滑动结束
handleTouchEnd(e) {
var endx, endy;
endx = e.changedTouches[0].pageX;
endy = e.changedTouches[0].pageY;
var direction = this.getDirection(this.startx, this.starty, endx, endy);
switch (direction) {
// 未滑动!
case 0:
break;
// 向上滑动
case 1:
this.showCard = true;
this.moveCard = 'dragLayer-top';
this.scrollable = true;
break;
// 向下滑动
case 2:
break;
// 向左
case 3:
break;
// 向右
case 4:
break;
default:
}
},
scroll(e) {},
scrolltoupper(e) {},
scrolltolower(e) {},
// 点击显隐
onShowCard() {
this.showCard = !this.showCard;
if (this.showCard) {
this.moveCard = 'dragLayer-top';
this.scrollable = true;
} else {
this.moveCard = 'dragLayer-bottom';
this.scrollable = false;
}
}
}
};
</script>
<style lang="scss">
.cuIcon-back {
position: fixed;
top: 50rpx;
left: 30rpx;
width: 70rpx;
line-height: 70rpx;
font-size: 40rpx;
text-align: center;
background: rgba(0, 0, 0, 0.2);
z-index: 10;
border-radius: 50%;
color: #fff;
}
/* 浮层 */
.dragLayer {
width: 750rpx;
/* height: auto; */
position: fixed;
background-color: #fff;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
bottom: 0;
box-shadow: 0px 1rpx 18rpx 0px rgba(83, 83, 83, 0.35);
display: flex;
height: 100%;
}
.dragLayer-bottom {
height: 450rpx !important;
/*#ifdef APP-PLUS */
height: 800rpx !important;
/*#endif*/
transition: all ease-in-out 0.2s;
}
.dragLayer-top {
height: 800rpx !important;
transition: all ease-in-out 0.2s;
}
.oilStation {
width: 690rpx;
margin: 0 30rpx;
display: flex;
flex-direction: column;
flex: 1;
height: 100%;
}
.oilStation-top {
justify-content: center;
align-items: center;
flex-direction: column;
}
.touch-guide {
justify-content: center;
align-items: center;
height: 80rpx;
}
.touch-jintou {
width: 60rpx;
height: 8rpx;
}
.search-box {
flex: 1;
height: 60rpx;
background: rgba(243, 243, 243, 1);
border-radius: 30rpx;
flex-direction: row;
align-items: center;
justify-content: center;
padding: 0 25rpx;
margin-top: 30rpx;
}
// 确认门店
.foot_box {
height: 100rpx;
background-color: #fff;
.save-btn {
color: #fff;
width: 690rpx;
height: 80rpx;
background: linear-gradient(90deg, rgba(233, 181, 97, 1), rgba(238, 204, 138, 1));
box-shadow: 1rpx 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
border-radius: 40rpx;
font-size: 28rpx;
}
}
.cuIcon-search {
color: #bdbdbd;
font-size: 40rpx;
margin-right: 20rpx;
}
.search-inp {
flex: 1;
font-size: 24rpx;
color: #333;
}
.search-pl {
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 400;
color: rgba(153, 153, 153, 1);
}
.oilStation-bottom {
justify-content: space-between;
align-items: center;
flex-direction: row;
flex: 1;
height: 100%;
overflow: hidden;
}
.address-item {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #eef1f4;
padding: 15rpx 0 15rpx;
justify-content: space-between;
align-items: center;
flex-direction: row;
}
.address-name {
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 600;
color: rgba(51, 51, 51, 1);
margin-bottom: 30rpx;
}
.time-box,
.address-detail,
.address-phone {
flex-direction: row;
align-items: center;
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 400;
color: #666;
margin-bottom: 20rpx;
}
.address-icon {
color: #bdbdbd;
margin-right: 10rpx;
font-size: 30rpx;
}
.address-left {
flex: 1;
}
.address-right {
align-items: center;
color: #a8700e;
font-size: 24rpx;
margin-bottom: 20rpx;
white-space: nowrap;
}
.address-checked {
transform: scale(0.7);
}
.more {
width: 750rpx;
height: 90rpx;
justify-content: center;
align-items: center;
}
.more-text {
font-size: 24rpx;
color: #ccc;
}
</style>