@tplc/business 0.5.53 → 0.5.54
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.
- package/CHANGELOG.md +2 -0
- package/components/lcb-map/lcb-map.vue +127 -51
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.5.54](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v1.0.7...v0.5.54) (2025-11-21)
|
|
6
|
+
|
|
5
7
|
### [0.5.53](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.5.46...v0.5.53) (2025-11-20)
|
|
6
8
|
|
|
7
9
|
|
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
<view class="flex-col flex w-full" :style="{ height }" v-if="height">
|
|
4
4
|
<view class="flex-1 h-0 relative">
|
|
5
5
|
<map
|
|
6
|
+
id="map"
|
|
6
7
|
:markers="info.covers"
|
|
7
8
|
show-location
|
|
8
9
|
show-compass
|
|
9
10
|
show-scale
|
|
10
11
|
:scale="mapScale"
|
|
11
12
|
class="w-full h-full"
|
|
12
|
-
id="map"
|
|
13
13
|
@regionchange="onRegionChange"
|
|
14
14
|
@callouttap="onCalloutTap"
|
|
15
|
+
:latitude="mapLatLon.latitude"
|
|
16
|
+
:longitude="mapLatLon.longitude"
|
|
15
17
|
/>
|
|
16
18
|
<image
|
|
17
19
|
src="./images/2.png"
|
|
@@ -85,7 +87,17 @@
|
|
|
85
87
|
|
|
86
88
|
<script lang="ts" setup>
|
|
87
89
|
import { FORM_KEY } from '@tplc/business/constants'
|
|
88
|
-
import {
|
|
90
|
+
import {
|
|
91
|
+
reactive,
|
|
92
|
+
inject,
|
|
93
|
+
ref,
|
|
94
|
+
useAttrs,
|
|
95
|
+
watch,
|
|
96
|
+
getCurrentInstance,
|
|
97
|
+
onUnmounted,
|
|
98
|
+
onMounted,
|
|
99
|
+
nextTick,
|
|
100
|
+
} from 'vue'
|
|
89
101
|
import { getJsonFromStr, transformValueUnit } from '../../utils/transform'
|
|
90
102
|
import { MapItem, MapMarker } from './types'
|
|
91
103
|
import useAutoHeight from '../../hooks/useAutoHeight'
|
|
@@ -94,6 +106,7 @@ import { LcbListInfo } from '@tplc/business/components/lcb-list/api'
|
|
|
94
106
|
import { debounce } from '@tplc/wot/components/common/util'
|
|
95
107
|
import useLocation from '../../hooks/useLocation'
|
|
96
108
|
const { height } = useAutoHeight('pagingTop', 500)
|
|
109
|
+
const mapReady = ref(false)
|
|
97
110
|
defineOptions({
|
|
98
111
|
name: 'LcbMap',
|
|
99
112
|
options: {
|
|
@@ -134,6 +147,10 @@ const list = ref<MapItem[]>([])
|
|
|
134
147
|
const mapScale = ref(14)
|
|
135
148
|
const isConfig = ref(false)
|
|
136
149
|
const currentScale = ref(14)
|
|
150
|
+
const mapLatLon = ref({
|
|
151
|
+
latitude: 0,
|
|
152
|
+
longitude: 0,
|
|
153
|
+
})
|
|
137
154
|
|
|
138
155
|
const onTagClick = (value: string) => {
|
|
139
156
|
if (props.mapTagMode === 'single') {
|
|
@@ -151,40 +168,58 @@ const onTagClick = (value: string) => {
|
|
|
151
168
|
}
|
|
152
169
|
}
|
|
153
170
|
|
|
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
|
-
|
|
171
|
+
// 存储最新的地图区域信息
|
|
172
|
+
const lastRegionInfo = ref<{
|
|
173
|
+
centerLocation: { latitude: number; longitude: number }
|
|
174
|
+
southwest?: { latitude: number; longitude: number }
|
|
175
|
+
} | null>(null)
|
|
176
|
+
|
|
177
|
+
const getDataCore = async () => {
|
|
178
|
+
// 安全检查:确保地图已就绪
|
|
179
|
+
if (!mapContext.value || !mapReady.value) {
|
|
180
|
+
return
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// const region = await getMapRegion()
|
|
184
|
+
// lastRegionInfo.value = region
|
|
185
|
+
if (lastRegionInfo.value) {
|
|
186
|
+
await fetchMapData(lastRegionInfo.value)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 请求地图数据
|
|
191
|
+
const fetchMapData = async (regionInfo: {
|
|
192
|
+
centerLocation: { latitude: number; longitude: number }
|
|
193
|
+
southwest?: { latitude: number; longitude: number }
|
|
194
|
+
}) => {
|
|
195
|
+
isLoading.value = true
|
|
196
|
+
try {
|
|
197
|
+
const { data = [] } = (await uni.$lcb.http.post(
|
|
198
|
+
'/productInfoMap/list',
|
|
199
|
+
{
|
|
200
|
+
...props.baseParam,
|
|
201
|
+
...form?.value,
|
|
202
|
+
mapLatitude: regionInfo.centerLocation.latitude,
|
|
203
|
+
mapLongitude: regionInfo.centerLocation.longitude,
|
|
204
|
+
mapScale: currentScale.value,
|
|
205
|
+
mapCornerLongitude: regionInfo.southwest?.longitude,
|
|
206
|
+
mapCornerLatitude: regionInfo.southwest?.latitude,
|
|
207
|
+
productTypeList: selectedTag.value.length ? selectedTag.value : undefined,
|
|
208
|
+
},
|
|
209
|
+
true,
|
|
210
|
+
)) as {
|
|
211
|
+
data: MapItem[]
|
|
212
|
+
}
|
|
213
|
+
list.value = data as any
|
|
214
|
+
getCurrentData(data)
|
|
215
|
+
} catch (error) {
|
|
216
|
+
console.error('地图数据请求失败:', error)
|
|
217
|
+
} finally {
|
|
218
|
+
isLoading.value = false
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const getData = debounce(getDataCore, 50)
|
|
188
223
|
watch(
|
|
189
224
|
() => selectedTag.value,
|
|
190
225
|
() => {
|
|
@@ -196,6 +231,21 @@ watch(
|
|
|
196
231
|
)
|
|
197
232
|
|
|
198
233
|
const getConfig = async () => {
|
|
234
|
+
// 等待地图就绪
|
|
235
|
+
if (!mapReady.value) {
|
|
236
|
+
await new Promise<void>((resolve) => {
|
|
237
|
+
const unwatch = watch(
|
|
238
|
+
() => mapReady.value,
|
|
239
|
+
(ready) => {
|
|
240
|
+
if (ready) {
|
|
241
|
+
unwatch()
|
|
242
|
+
resolve()
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
)
|
|
246
|
+
})
|
|
247
|
+
}
|
|
248
|
+
|
|
199
249
|
isConfig.value = true
|
|
200
250
|
const {
|
|
201
251
|
data: { mapLatitude, mapLongitude, mapScale: scale },
|
|
@@ -208,28 +258,31 @@ const getConfig = async () => {
|
|
|
208
258
|
...form?.value,
|
|
209
259
|
...getJsonFromStr(props.mapConfigParams),
|
|
210
260
|
})
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
261
|
+
|
|
262
|
+
if (mapLatitude && `${mapLatitude}` !== '0') {
|
|
263
|
+
mapLatLon.value = {
|
|
264
|
+
latitude: mapLatitude,
|
|
265
|
+
longitude: mapLongitude,
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
216
269
|
mapScale.value = scale
|
|
217
270
|
currentScale.value = scale
|
|
218
|
-
getData()
|
|
219
271
|
}
|
|
220
272
|
|
|
221
273
|
watch(
|
|
222
274
|
() => userLatLon.value,
|
|
223
275
|
async (val, old) => {
|
|
224
276
|
if (!val || JSON.stringify(val) === JSON.stringify(old)) return
|
|
225
|
-
mapContext.value?.moveToLocation({
|
|
226
|
-
latitude: val.latitude,
|
|
227
|
-
longitude: val.longitude,
|
|
228
|
-
})
|
|
229
277
|
form.value.userLongitude = val.longitude
|
|
230
278
|
form.value.userLatitude = val.latitude
|
|
231
279
|
if (!isConfig.value) {
|
|
232
280
|
getConfig()
|
|
281
|
+
} else {
|
|
282
|
+
mapLatLon.value = {
|
|
283
|
+
latitude: val.latitude,
|
|
284
|
+
longitude: val.longitude,
|
|
285
|
+
}
|
|
233
286
|
}
|
|
234
287
|
},
|
|
235
288
|
{
|
|
@@ -246,16 +299,25 @@ const onRegionChange = (e: {
|
|
|
246
299
|
detail: {
|
|
247
300
|
causedBy: string
|
|
248
301
|
scale: number
|
|
249
|
-
gesture: boolean
|
|
250
302
|
centerLocation: {
|
|
251
303
|
latitude: number
|
|
252
304
|
longitude: number
|
|
253
305
|
}
|
|
306
|
+
region: {
|
|
307
|
+
northeast: { latitude: number; longitude: number }
|
|
308
|
+
southwest: { latitude: number; longitude: number }
|
|
309
|
+
}
|
|
254
310
|
}
|
|
255
311
|
}) => {
|
|
312
|
+
// 更新当前缩放级别
|
|
313
|
+
currentScale.value = e.detail.scale
|
|
314
|
+
|
|
256
315
|
if (e.type === 'end') {
|
|
316
|
+
lastRegionInfo.value = {
|
|
317
|
+
centerLocation: e.detail.centerLocation,
|
|
318
|
+
southwest: e.detail.region.southwest,
|
|
319
|
+
}
|
|
257
320
|
getData()
|
|
258
|
-
currentScale.value = e.detail.scale
|
|
259
321
|
}
|
|
260
322
|
}
|
|
261
323
|
const onCurrentChange = (p: number) => {
|
|
@@ -317,12 +379,26 @@ watch(
|
|
|
317
379
|
deep: true,
|
|
318
380
|
},
|
|
319
381
|
)
|
|
320
|
-
|
|
321
|
-
//
|
|
322
|
-
|
|
382
|
+
onMounted(() => {
|
|
383
|
+
// 延迟创建 mapContext,确保 DOM 完全渲染
|
|
384
|
+
nextTick(() => {
|
|
385
|
+
setTimeout(() => {
|
|
386
|
+
try {
|
|
387
|
+
mapContext.value = uni.createMapContext('map', proxy)
|
|
388
|
+
if (mapContext.value) {
|
|
389
|
+
mapReady.value = true
|
|
390
|
+
}
|
|
391
|
+
} catch (error) {
|
|
392
|
+
console.error('地图初始化异常:', error)
|
|
393
|
+
}
|
|
394
|
+
}, 500)
|
|
395
|
+
})
|
|
396
|
+
})
|
|
323
397
|
|
|
324
398
|
onUnmounted(() => {
|
|
325
399
|
mapContext.value = undefined
|
|
400
|
+
mapReady.value = false
|
|
401
|
+
lastRegionInfo.value = null
|
|
326
402
|
})
|
|
327
403
|
</script>
|
|
328
404
|
<style lang="scss">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tplc/business",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.54",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"业务组件"
|
|
6
6
|
],
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"vue": ">=3.2.47",
|
|
14
|
-
"@tplc/wot": "1.0.
|
|
14
|
+
"@tplc/wot": "1.0.7"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">=18",
|