jufubao-mall 2.0.35-beta1 → 2.0.35-beta3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,47 +2,67 @@
2
2
  <baidu-map
3
3
  class="xd-baidu__content"
4
4
  v-if="ak"
5
- :center="center"
5
+ :center="centerMap"
6
6
  :zoom="level"
7
- :key="renderMapKey"
8
- auto-resize
9
7
  scroll-wheel-zoom
8
+ :continuous-zoom="true"
10
9
  :ak="ak"
10
+ :draggable="dragging"
11
+ :pinch-to-zoom="pinchToZoom"
12
+ @dragstart="handleDragStart"
13
+ @dragging="handleDragMove"
14
+ @tilesloaded="handleTouchEnd"
15
+ @touchstart="handleTouchStart"
16
+ @touchmove="handleTouchMove"
11
17
  >
12
18
  <bm-marker
13
- v-if="myPosition"
14
- :position="myPosition" title="我的坐标"
15
- :icon="{
16
- url: 'https://sandbox-img.jufubao.cn/uploads/20250722/5694efe27b94cba718ce5c5175a00bfb.png?x-oss-process=style/size3&ver=1753173358',
17
- size: {width: 30, height: 30},
18
- opts: {imageSize: {width: 30, height: 30}}
19
- }"
19
+ v-if="!moved"
20
+ title="我的坐标"
21
+ :position="position"
22
+ :key="baiduMapKey"
23
+ :icon="icon"
20
24
  animation="BMAP_ANIMATION_BOUNCE"
21
- >
22
- <!-- <bm-label content="我的坐标" :labelStyle="{color: 'red', fontSize : '12px'}" :offset="{width: -15, height: 30}"/> -->
25
+ >
23
26
  </bm-marker>
24
-
25
- <!-- <bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT" type="NavigationControlType"></bm-navigation> -->
26
- <bm-marker v-for="(item,index) in markets" :key="item.id"
27
+ <bm-marker
28
+ v-for="(item,index) in uiMarkets"
29
+ :key="item.id"
27
30
  :position="item"
28
31
  :icon="item.icon"
29
- :dragging="true"
30
32
  :title="item.title"
31
33
  animation="BMAP_ANIMATION_BOUNCE"
32
34
  @click="showItemInfo(item)"
33
35
  >
34
- <bm-info-window :show="item.show" @close="closeItemInfo(item)">{{ item.title }}</bm-info-window>
36
+ <bm-info-window :show="item.show" @close="closeItemInfo(item)">
37
+ <view class="showMarker" @click="handleDetail(item)">
38
+ <view>{{item.title}}</view>
39
+ <view>{{item.address}}</view>
40
+ </view>
41
+
42
+ </bm-info-window>
35
43
  </bm-marker>
44
+ <bm-control anchor="BMAP_ANCHOR_BOTTOM_RIGHT" v-if="baiduMap !== null">
45
+ <view @click.stop="(e)=>{handleLocationSuccess(e,null)}" class="location" :style="{backgroundImage: `url(${location})`}"></view>
46
+ </bm-control>
47
+ <bm-control anchor="BMAP_ANCHOR_TOP_LEFT" v-if="baiduMap !== null && 0">
48
+ <view style="font-size: 20rpx; background-color: #fff;">pinchToZoom:{{pinchToZoom}}--dragging:{{dragging}}:{{centerMap}}--{{moved}}</view>
49
+ </bm-control>
36
50
  </baidu-map>
37
51
  </template>
38
52
 
39
53
  <script>
40
-
41
- import BaiduMap from 'vue-baidu-map/components/map/Map.vue';
42
- import BmMarker from 'vue-baidu-map/components/overlays/Marker';
43
- import BmNavigation from 'vue-baidu-map/components/controls/Navigation.vue'
44
- import BmInfoWindow from 'vue-baidu-map/components/overlays/InfoWindow.vue'
45
- import BmLabel from 'vue-baidu-map/components/overlays/Label';
54
+ //https://dafrok.github.io/vue-baidu-map/#/zh/control/map-type
55
+ //https://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a2b5
56
+ import BaiduMap from 'modules/vue-baidu-map/components/map/Map.vue';
57
+ import bmScale from 'modules/vue-baidu-map/components/controls/Scale';
58
+ import BmMarker from 'modules/vue-baidu-map/components/overlays/Marker';
59
+ import BmNavigation from 'modules/vue-baidu-map/components/controls/Navigation.vue'
60
+ import BmGeolocation from 'modules/vue-baidu-map/components/controls/Geolocation.vue'
61
+ import BmControl from 'modules/vue-baidu-map/components/controls/Control.vue'
62
+ import BmInfoWindow from 'modules/vue-baidu-map/components/overlays/InfoWindow.vue'
63
+ import BmLabel from 'modules/vue-baidu-map/components/overlays/Label';
64
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon.vue";
65
+ import getServiceUrl from "@/common/getServiceUrl";
46
66
 
47
67
  export default {
48
68
  name: "XdBaiduMap",
@@ -51,7 +71,11 @@
51
71
  BmMarker,
52
72
  BmNavigation,
53
73
  BmInfoWindow,
54
- BmLabel
74
+ BmGeolocation,
75
+ BmLabel,
76
+ bmScale,
77
+ BmControl,
78
+ XdFontIcon
55
79
  },
56
80
  props:{
57
81
  center: {
@@ -74,40 +98,268 @@
74
98
  return []
75
99
  }
76
100
  },
77
- myPosition: {
78
- type: Object,
79
- default(){
80
- return null;
81
- }
101
+ showPosition: {
102
+ type: Boolean,
103
+ default: false
82
104
  }
83
105
  },
84
106
  watch: {
85
107
  markets(val){
86
108
  if(val.length > 0){
87
- this.uiMarkets = val.map(item => {
88
- item.show = false;
89
- if(item.id === this.showMarketId){
90
- item.show = true;
91
- }
92
- return item;
93
- });
109
+ this.uiMarkets = null;
110
+ this.$nextTick(()=>{
111
+ this.uiMarkets = val.map(item => {
112
+ item.show = item.id === this.showMarketId;
113
+ return item;
114
+ });
115
+ })
94
116
  }
117
+ },
118
+ showPosition(val){
119
+ this.showCenter = val
95
120
  }
96
121
  },
97
122
  data(){
98
123
  return {
124
+ showCenter:true,
125
+ icon:{
126
+ url: 'https://img.jufubao.cn/common/local.png?x-oss-process=style/size3',
127
+ size: {width: 30, height: 30},
128
+ opts: {imageSize: {width: 30, height: 30}}
129
+ },
130
+ baiduIcon: {
131
+ url: 'https://img.jufubao.cn/common/empty.png?x-oss-process=style/size3',
132
+ size: {width: 30, height: 30},
133
+ opts: {imageSize: {width: 30, height: 30}}
134
+ },
135
+ location: getServiceUrl('/common/location.png?v1=1'),
136
+ mapType:'',
99
137
  show: false,
100
- uiMarkets: [],
101
- showMarketId: '',
138
+ uiMarkets: [], //所有markers
139
+ showMarketId: '', //当前显示ID
102
140
  clickOnce: false,
103
- renderMapKey: "renderMapKey"
141
+ timer: false,
142
+ moved:null, //是否移动过
143
+ isFirst: true,
144
+ cusLocal: false, //当前为点击定位逻辑
145
+
146
+ dragging: true, //拖拽状态
147
+ pinchToZoom: true, //双指缩放
148
+ isDragge: '', //是否为拖拽操作 //dragge, pinch
149
+ touchEndTimer:null, //结束定时器
150
+ centerMap:{},
151
+ position:{},
152
+ baiduMap:null, //百度初始化对象
153
+ cusLocationTimer: null,
154
+ baiduMapKey: 'baiduMapKey',
155
+ locationStatus: false,
104
156
  }
105
157
  },
106
158
  created() {
107
159
  if(!this.ak) throw new Error('请传入百度AK值');
108
- this.uiMarkets = this.markets;
160
+ this.uiMarkets = this.$xdUniHelper.cloneDeep(this.markets);
161
+ this.showCenter = this.showPosition;
162
+ if(this.$configProject['isPreview']
163
+ || this.center === null
164
+ || (this.center && this.$xdUniHelper.isEmpty(this.center))
165
+ ) {
166
+ this.centerMap = {lng: 116.404, lat: 39.915};
167
+ }
168
+ else{
169
+ this.centerMap = this.$xdUniHelper.cloneDeep(this.center);
170
+ }
171
+ this.position = this.$xdUniHelper.cloneDeep(this.centerMap);
109
172
  },
110
173
  methods:{
174
+ toTranformLocation(point){
175
+ let {lng, lat} = point
176
+ console.log('handleRegionChange.toTranformLocation',point);
177
+ return {
178
+ longitude:lng,
179
+ latitude: lat,
180
+ lng,lat
181
+ }
182
+ },
183
+ handleDragStart(e){
184
+ if(this.$configProject['isPreview']) {
185
+ e.touches = [];
186
+ this.handleTouchStart(e)
187
+ }
188
+ },
189
+ handleDragMove(e){
190
+ if(this.$configProject['isPreview']) {
191
+ e.touches = [];
192
+ this.handleTouchMove(e)
193
+ }
194
+ },
195
+ handleTouchStart(){
196
+ this.uiMarkets = this.uiMarkets.map(market => {
197
+ delete market.show;
198
+ return market;
199
+ });
200
+ if(this.touchEndTimer) clearTimeout(this.touchEndTimer);
201
+ },
202
+ handleTouchMove(e){
203
+ //定位中
204
+ if(this.locationStatus) return
205
+ if(!this.isDragge){
206
+ let touches = e.targetTouches || e.touches
207
+ this.moved = true;
208
+ //一个手指为拖拽操作
209
+ if(touches.length <= 1) {
210
+ this.isDragge = 'dragge'
211
+ }
212
+ //两个手指为放大操作
213
+ else {
214
+ this.isDragge = 'pinch'
215
+ }
216
+ this.touchUseTime = Date.now();
217
+ this.$emit('regionchange', {
218
+ type:"begin",
219
+ causedBy: this.isDragge === 'dragge'? 'drag':'scale',
220
+ detail:{
221
+ type:"begin",
222
+ causedBy: this.isDragge === 'dragge'? 'drag':'scale',
223
+ point: this.toTranformLocation(e.point),
224
+ },
225
+ });
226
+ }
227
+ },
228
+ handleTouchEnd(e){
229
+ if(this.baiduMap === null){
230
+ this.baiduMap = e.target;
231
+ this.$emit('init');
232
+ }
233
+
234
+ //移动与缩放处理
235
+ if(['dragge','pinch'].includes(this.isDragge)) {
236
+ this.touchEndTimer = setTimeout(()=>{
237
+ this.level = e.target.getZoom();
238
+ this.$emit('regionchange', {
239
+ type:"end",
240
+ causedBy:this.isDragge,
241
+ detail:{
242
+ type:"end",
243
+ causedBy: this.isDragge,
244
+ point: this.toTranformLocation(e.target.getCenter()),
245
+ time: Date.now() - this.touchUseTime + ' ms'
246
+ },
247
+ });
248
+ this.isDragge = '';
249
+ }, 300)
250
+ }
251
+
252
+ //定位成功处理
253
+ if(['location'].includes(this.isDragge)) {
254
+ this.$emit('regionchange', {
255
+ type:"end",
256
+ causedBy: 'location',
257
+ detail:{
258
+ type:"end",
259
+ causedBy: 'location',
260
+ point: this.toTranformLocation(this.$xdUniHelper.cloneDeep(e.target.getCenter())),
261
+ time: Date.now() - this.touchUseTime + ' ms'
262
+ },
263
+ });
264
+ this.position = this.$xdUniHelper.cloneDeep(e.target.getCenter())
265
+ this.baiduMapKey = Date.now();
266
+ this.dragging = true;
267
+ this.pinchToZoom = true;
268
+ this.isDragge = '';
269
+ }
270
+ },
271
+ handleLocationSuccess(e){
272
+ let geolocation = new BMap['Geolocation']();
273
+
274
+ //定位中处理
275
+ if(this.locationStatus) return;
276
+ this.locationStatus = true;
277
+ this.dragging = false;
278
+ this.pinchToZoom = false;
279
+ this.isDragge = 'location';
280
+ geolocation['enableSDKLocation']();
281
+ this.$emit('regionchange', {
282
+ type:"begin",
283
+ causedBy: 'location',
284
+ detail:{
285
+ type:"begin",
286
+ causedBy: 'location',
287
+ point: null,
288
+ time: Date.now() - this.touchUseTime + ' ms'
289
+ },
290
+ });
291
+
292
+ //当前次是否超时设置
293
+ let isTimeout = false;
294
+
295
+ //3秒超时
296
+ this.cusLocationTimer = setTimeout(()=>{
297
+ this.$emit('regionchange', {
298
+ type:"end",
299
+ causedBy: 'location',
300
+ detail:{
301
+ type:"end",
302
+ causedBy: 'location',
303
+ point: null,
304
+ time: Date.now() - this.touchUseTime + ' ms'
305
+ },
306
+ });
307
+ isTimeout = true;
308
+ this.moved = false;
309
+ this.locationStatus = false;
310
+ this.dragging = true;
311
+ this.pinchToZoom = true;
312
+ this.isDragge = '';
313
+ }, 3000);
314
+
315
+ geolocation.getCurrentPosition(
316
+ (location) => {
317
+ if(isTimeout) return;
318
+ this.locationStatus = false;
319
+ if(location && location.point) {
320
+ console.log('baiduMap.setCenter')
321
+ this.baiduMap.setCenter(location.point);
322
+ this.moved = false;
323
+ }
324
+ else {
325
+ this.$emit('regionchange', {
326
+ type:"end",
327
+ causedBy: 'location',
328
+ detail:{
329
+ type:"end",
330
+ causedBy: 'location',
331
+ point: null,
332
+ time: Date.now() - this.touchUseTime + ' ms'
333
+ },
334
+ });
335
+ this.dragging = true;
336
+ this.pinchToZoom = true;
337
+ this.isDragge = '';
338
+ }
339
+ isTimeout = false;
340
+ console.log('handleLocationSuccess.location.end',location,this.locationStatus)
341
+ clearTimeout(this.cusLocationTimer);
342
+ },
343
+ (error) => {
344
+ this.isDragge = '';
345
+ this.moved = false;
346
+ this.dragging = true;
347
+ this.pinchToZoom = true;
348
+ this.locationStatus = false;
349
+ this.$emit('regionchange', {
350
+ type:"end",
351
+ causedBy: 'location',
352
+ detail:{
353
+ type:"end",
354
+ causedBy: 'location',
355
+ point: null,
356
+ time: Date.now() - this.touchUseTime + ' ms'
357
+ },
358
+ });
359
+ clearTimeout(this.cusLocationTimer);
360
+ }
361
+ )
362
+ },
111
363
  showItemInfo(item){
112
364
  this.clickOnce = true;
113
365
  setTimeout(() => {
@@ -115,13 +367,10 @@
115
367
  }, 200)
116
368
  this.showMarketId = item.id;
117
369
  this.uiMarkets = this.uiMarkets.map(market => {
118
- market.show = false;
119
- if(item.id === market.id){
120
- market.show = true;
121
- }
370
+ market.show = item.id === market.id;
122
371
  return market;
123
372
  })
124
- this.$emit('onChose', item)
373
+ this.$emit('on-show-marker', item)
125
374
  },
126
375
  closeItemInfo(item){
127
376
  if(this.clickOnce) return;
@@ -129,9 +378,18 @@
129
378
  this.uiMarkets = this.uiMarkets.map(market => {
130
379
  delete market.show;
131
380
  return market;
132
- })
133
- this.renderMapKey = Date.now();
134
- }
381
+ });
382
+ this.$emit('on-close-marker')
383
+ },
384
+ handleDetail(item){
385
+ this.showMarketId = '';
386
+ this.uiMarkets = this.uiMarkets.map(market => {
387
+ delete market.show;
388
+ return market;
389
+ });
390
+ this.$emit('on-detail',{item:item, type: 'shop', isMap: true});
391
+ this.$emit('on-close-marker')
392
+ },
135
393
  }
136
394
  }
137
395
  </script>
@@ -144,4 +402,34 @@
144
402
  height: 50%;
145
403
  z-index: 3000;
146
404
  }
405
+
406
+ .showMarker {
407
+ margin-right: 32rpx;
408
+ & > view:first-child {
409
+ font-size: 32rpx;
410
+ line-height: 44rpx;
411
+ margin-bottom: 18rpx;
412
+ color: #333;
413
+ max-width: 400rpx;
414
+ }
415
+
416
+ & > view:nth-child(2) {
417
+ font-size: 24rpx;
418
+ line-height: 36rpx;
419
+ color: #999;
420
+ max-width: 400rpx;
421
+ }
422
+ }
423
+
424
+ .location {
425
+ width: 60rpx;
426
+ height: 60rpx;
427
+ background-color: #fff;
428
+ border: 1px solid #eee;
429
+ border-radius: 10rpx;
430
+ background-size: 90% 90%;
431
+ background-position: center;
432
+ background-repeat: repeat;
433
+ margin: 0 20rpx 20rpx 0;
434
+ }
147
435
  </style>
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  export default (data, gValue, gColor, oldData={})=>{
4
- let codePath =null;
5
- if(data['codePath'] !== undefined) {
6
- codePath = data['codePath']
7
- }
4
+ let codePath =null,detailPath = null;
5
+ if(data['codePath'] !== undefined) codePath = data['codePath'];
6
+ if(data['detailPath'] !== undefined) detailPath = data['detailPath'];
7
+
8
8
  return [
9
9
  {
10
10
  label: '门店地址',
11
11
  ele: 'xd-select-pages-path',
12
12
  valueKey: 'codePath',
13
- placeholder: '请选择门店地址跳转地址',
13
+ placeholder: '请选择门店跳转页面',
14
14
  groupKey:'advanced',
15
15
  value: codePath,
16
16
  labelInline:true,
@@ -20,81 +20,23 @@ export default (data, gValue, gColor, oldData={})=>{
20
20
  router: XdBus.getParentApi('getPagesTree'),
21
21
  },
22
22
  inline: false,
23
+ notice: "点击门店跳转到地址"
23
24
  },
24
25
  {
25
- label: '核销地址',
26
+ label: '门店详情',
26
27
  ele: 'xd-select-pages-path',
27
- valueKey: 'cashierPath',
28
- placeholder: '请选择核销地址跳转地址',
28
+ valueKey: 'detailPath',
29
+ placeholder: '请选择门店详情跳转页面',
29
30
  groupKey:'advanced',
30
- className: 'input100',
31
- value: data['cashierPath'] || null,
32
- setting: {
33
- mode:'new',
34
- router: XdBus.getParentApi('getPagesTree'),
35
- },
36
- inline: false,
31
+ value: detailPath,
37
32
  labelInline:true,
38
- },
39
- {
40
- label: '在线选座',
41
- ele: 'xd-select-pages-path',
42
- valueKey: 'buyTicketPath',
43
- placeholder: '请选择在线选座跳转地址',
44
- groupKey:'advanced',
45
33
  className: 'input100',
46
- value: data['buyTicketPath'] || null,
47
34
  setting: {
48
35
  mode:'new',
49
36
  router: XdBus.getParentApi('getPagesTree'),
50
37
  },
51
38
  inline: false,
52
- labelInline:true,
53
- },
54
- {
55
- label: '电子码地址',
56
- ele: 'xd-select-pages-path',
57
- valueKey: 'codeAfterPath',
58
- placeholder: '请选择电子码跳转地址',
59
- groupKey:'advanced',
60
- className: 'input100',
61
- value: data['codeAfterPath'] || null,
62
- setting: {
63
- mode:'new',
64
- router: XdBus.getParentApi('getPagesTree'),
65
- },
66
- inline: false,
67
- labelInline:true,
68
- },
69
- {
70
- label: '小时达地址',
71
- ele: 'xd-select-pages-path',
72
- valueKey: 'hdSelfPath',
73
- placeholder: '请选择小时达到店自取跳转地址',
74
- groupKey:'advanced',
75
- className: 'input100',
76
- value: data['hdSelfPath'] || null,
77
- setting: {
78
- mode:'new',
79
- router: XdBus.getParentApi('getPagesTree'),
80
- },
81
- inline: false,
82
- labelInline:true,
83
- },
84
- {
85
- label: '旅游门票',
86
- ele: 'xd-select-pages-path',
87
- valueKey: 'travelfPath',
88
- placeholder: '请选择旅游在线订票跳转地址',
89
- groupKey:'advanced',
90
- className: 'input100',
91
- value: data['travelfPath'] || null,
92
- setting: {
93
- mode:'new',
94
- router: XdBus.getParentApi('getPagesTree'),
95
- },
96
- inline: false,
97
- labelInline:true,
39
+ notice: '点击门店名称后面的详情跳转到地址'
98
40
  },
99
41
  {
100
42
  label: '版本号:',