gxd-uni-library-editx 1.0.0
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/.editorconfig +14 -0
- package/README.md +447 -0
- package/index.js +3 -0
- package/package.json +104 -0
- package/postcss.config.js +22 -0
- package/settings.js.tpl +68 -0
- package/src/XdAppClass.1.0.js +257 -0
- package/src/XdAppClass.js +150 -0
- package/src/components/XdAddress/XdAddress.vue +579 -0
- package/src/components/XdAddressSelect/XdAddressSelect.vue +243 -0
- package/src/components/XdBaiduMap/XdBaiduMap.vue +204 -0
- package/src/components/XdBaiduOverlay/XdBaiduOverlay.vue +345 -0
- package/src/components/XdBaiduSearch/XdBaiduSearch.vue +354 -0
- package/src/components/XdBar/XdBar.vue +339 -0
- package/src/components/XdButton/XdButton.vue +288 -0
- package/src/components/XdCartList/XdCartList.vue +791 -0
- package/src/components/XdCartNoStoreList/XdCartNoStoreList.vue +747 -0
- package/src/components/XdCity/XdCity.vue +620 -0
- package/src/components/XdCity/city.js +93 -0
- package/src/components/XdCity/testData.js +124 -0
- package/src/components/XdCityLocation/XdCityLocation.vue +314 -0
- package/src/components/XdCityLocation/jweixin.js +72 -0
- package/src/components/XdCityShow/XdCityShow.vue +354 -0
- package/src/components/XdClipImage/XdClipImage.vue +879 -0
- package/src/components/XdCoins/XdCoins.vue +66 -0
- package/src/components/XdConfirm/XdConfirm.vue +240 -0
- package/src/components/XdContentXss/XdContentXss.vue +71 -0
- package/src/components/XdDailog/XdDailog.vue +258 -0
- package/src/components/XdDate/XdDataItemOne.vue +236 -0
- package/src/components/XdDate/XdDate.vue +1081 -0
- package/src/components/XdDate/XdDateItem.vue +316 -0
- package/src/components/XdDate/XdDateTime.vue +929 -0
- package/src/components/XdDate/i18n/en.json +19 -0
- package/src/components/XdDate/i18n/index.js +8 -0
- package/src/components/XdDate/i18n/zh-Hans.json +19 -0
- package/src/components/XdDate/i18n/zh-Hant.json +19 -0
- package/src/components/XdDate/keypress.js +45 -0
- package/src/components/XdDate/util.js +418 -0
- package/src/components/XdDownDrawer/XdDownDrawer.vue +176 -0
- package/src/components/XdEditPwd/XdEditPwd.vue +305 -0
- package/src/components/XdEnterOrderList/XdEnterOrderList.vue +413 -0
- package/src/components/XdExpressTimeLine/XdExpressTimeLine.vue +280 -0
- package/src/components/XdFilter/XdFilter.vue +541 -0
- package/src/components/XdFontIcon/XdFontIcon.vue +165 -0
- package/src/components/XdFontIcon/css/icon.less +498 -0
- package/src/components/XdFooterBar/XdFooterBar.vue +291 -0
- package/src/components/XdFooterTabbar/XdFooterTabbar.vue +284 -0
- package/src/components/XdForm/XdForm.vue +481 -0
- package/src/components/XdForm/validate.js +486 -0
- package/src/components/XdFormCheckbox/XdFormCheckbox.vue +858 -0
- package/src/components/XdFormDate.vue +187 -0
- package/src/components/XdFormInput/XdFormInput.vue +535 -0
- package/src/components/XdFormInput/common.js +56 -0
- package/src/components/XdFormItem/XdFormItem.vue +583 -0
- package/src/components/XdFormSelect/XdFormSelect.vue +119 -0
- package/src/components/XdImage/XdImage.vue +113 -0
- package/src/components/XdItemCardUser/XdItemCardUser.vue +232 -0
- package/src/components/XdItemFilmImage/XdItemFilmImage.vue +146 -0
- package/src/components/XdItemFilmText/XdItemFilmText.vue +83 -0
- package/src/components/XdItemPhysical/XdItemPhysical.vue +410 -0
- package/src/components/XdItemPhysicalPack/XdItemPhysicalPack.vue +240 -0
- package/src/components/XdItemStore/XdItemStore.vue +236 -0
- package/src/components/XdItemUserInfo/XdItemUserInfo.vue +175 -0
- package/src/components/XdJson/XdJson.vue +398 -0
- package/src/components/XdKeyValue/XdKeyValue.vue +150 -0
- package/src/components/XdLabelNew/XdLabelNew.vue +193 -0
- package/src/components/XdLayout/XdLayout.vue +634 -0
- package/src/components/XdLoading/XdLoading.vue +165 -0
- package/src/components/XdMore/XdMore.vue +66 -0
- package/src/components/XdMpHtml/XdMpHtml.vue +458 -0
- package/src/components/XdMpHtml/node/node.vue +536 -0
- package/src/components/XdMpHtml/parser.js +1260 -0
- package/src/components/XdMpHtml/static/js/handler.js +1 -0
- package/src/components/XdMpHtml/static/js/uni.webview.min.js +1 -0
- package/src/components/XdMpHtml/static/local.html +1 -0
- package/src/components/XdMy/XdMy.vue +294 -0
- package/src/components/XdMySuccess/XdMySuccess.vue +603 -0
- package/src/components/XdNavTab/XdNavTab.vue +147 -0
- package/src/components/XdNoData/XdNoData.vue +87 -0
- package/src/components/XdNoticeBar/XdNoticeBar.vue +501 -0
- package/src/components/XdNumber/XdNumber.vue +210 -0
- package/src/components/XdNumberUni/XdNumberUni.vue +270 -0
- package/src/components/XdNumberUni/readme.md +42 -0
- package/src/components/XdOnlineConfirm/XdOnlineConfirm.vue +385 -0
- package/src/components/XdOnlineDetail/XdOnlineDetail.vue +332 -0
- package/src/components/XdOnlinePay/XdOnlinePay.vue +349 -0
- package/src/components/XdOnlineSchedule/XdOnlineSchedule.vue +453 -0
- package/src/components/XdOnlineSeat/XdOnlineSeat.vue +796 -0
- package/src/components/XdOnlineSeatMove/XdOnlineSeatMove.vue +1012 -0
- package/src/components/XdPayCombo/XdPayCombo.vue +118 -0
- package/src/components/XdPreviewImage/XdPreviewImage.vue +372 -0
- package/src/components/XdPwPay/XdPwPay.vue +214 -0
- package/src/components/XdRadio/XdRadio.vue +151 -0
- package/src/components/XdRangeSlider/XdRangeSlider.vue +355 -0
- package/src/components/XdRedName/XdRedName.vue +35 -0
- package/src/components/XdSearchBar/XdSearchBar.vue +286 -0
- package/src/components/XdSelect/XdSelect.vue +382 -0
- package/src/components/XdSelectCity/XdSelectCity.vue +270 -0
- package/src/components/XdSelectTime/XdSelectTime.vue +342 -0
- package/src/components/XdStar/XdStar.vue +261 -0
- package/src/components/XdStoreCashier/XdStoreCashier.vue +526 -0
- package/src/components/XdStoreItem/XdStoreItem.vue +400 -0
- package/src/components/XdStoreOrderDetail/XdStoreOrderDetail.vue +1571 -0
- package/src/components/XdStoreOrderList/XdStoreOrderList.vue +450 -0
- package/src/components/XdStoreProductInfo/XdStoreProductInfo.vue +940 -0
- package/src/components/XdStoreProductType/XdStoreProductType.vue +307 -0
- package/src/components/XdSuccess/XdSuccess.vue +527 -0
- package/src/components/XdSwipeSelect/XdSwipeSelect.vue +99 -0
- package/src/components/XdSwiper/XdSwiper.vue +124 -0
- package/src/components/XdSwitch/XdSwitch.vue +204 -0
- package/src/components/XdTab/XdTab.vue +220 -0
- package/src/components/XdTabScroll/XdTabScroll.vue +212 -0
- package/src/components/XdTag/XdTag.vue +423 -0
- package/src/components/XdTimeLine/XdTimeLine.vue +121 -0
- package/src/components/XdTips/XdTips.vue +212 -0
- package/src/components/XdTipsBlock/XdTipsBlock.vue +141 -0
- package/src/components/XdTitleSection/XdTitleSection.vue +152 -0
- package/src/components/XdTitleTab/XdTitleTab.vue +227 -0
- package/src/components/XdUnit/XdUnit.vue +206 -0
- package/src/components/XdUpload/XdUpload.vue +197 -0
- package/src/components/XdUploadImage/XdUploadImage.vue +145 -0
- package/src/components/Xdlogs/XdLogs.vue +144 -0
- package/src/components/autoload.js +211 -0
- package/src/components/swipeAction/UniSwipeAction.vue +43 -0
- package/src/components/swipeActionItem/UniSwipeActionItem.vue +386 -0
- package/src/components/swipeActionItem/bindingx.js +298 -0
- package/src/components/swipeActionItem/index.wxs +321 -0
- package/src/components/swipeActionItem/isPC.js +18 -0
- package/src/components/swipeActionItem/mpalipay.js +210 -0
- package/src/components/swipeActionItem/mpother.js +252 -0
- package/src/components/swipeActionItem/mpwxs.js +140 -0
- package/src/dome/dome/address.vue +415 -0
- package/src/dome/dome/auth/login.vue +166 -0
- package/src/dome/dome/baidu_show.vue +20 -0
- package/src/dome/dome/cake.vue +186 -0
- package/src/dome/dome/cart.vue +205 -0
- package/src/dome/dome/cart_store.vue +149 -0
- package/src/dome/dome/cashier/cashier.vue +73 -0
- package/src/dome/dome/cashier/check_cashier.vue +469 -0
- package/src/dome/dome/cashier/success.vue +127 -0
- package/src/dome/dome/city.vue +148 -0
- package/src/dome/dome/cityData.js +9 -0
- package/src/dome/dome/clip.vue +82 -0
- package/src/dome/dome/date/date.vue +273 -0
- package/src/dome/dome/date/selected.js +315 -0
- package/src/dome/dome/dcom/app1.vue +13 -0
- package/src/dome/dome/dcom/app2.vue +13 -0
- package/src/dome/dome/dcom/app3.vue +13 -0
- package/src/dome/dome/dcom/app4.vue +13 -0
- package/src/dome/dome/dcom/app5.vue +13 -0
- package/src/dome/dome/dcom/index.vue +1 -0
- package/src/dome/dome/debug/debug.vue +95 -0
- package/src/dome/dome/docache/docache.vue +88 -0
- package/src/dome/dome/express.vue +269 -0
- package/src/dome/dome/form.vue +312 -0
- package/src/dome/dome/icon.js +125 -0
- package/src/dome/dome/icon.vue +93 -0
- package/src/dome/dome/index.vue +725 -0
- package/src/dome/dome/item.vue +236 -0
- package/src/dome/dome/json/json.vue +88 -0
- package/src/dome/dome/layout.vue +105 -0
- package/src/dome/dome/line.vue +113 -0
- package/src/dome/dome/map/search.vue +70 -0
- package/src/dome/dome/my.vue +171 -0
- package/src/dome/dome/notice.vue +93 -0
- package/src/dome/dome/online/confirm.vue +92 -0
- package/src/dome/dome/online/detail.vue +80 -0
- package/src/dome/dome/online/pay.vue +78 -0
- package/src/dome/dome/online/schedule.vue +73 -0
- package/src/dome/dome/online/seat.vue +98 -0
- package/src/dome/dome/order/detail.vue +166 -0
- package/src/dome/dome/order/enter_order.vue +294 -0
- package/src/dome/dome/order/list.vue +219 -0
- package/src/dome/dome/order/order.js +18 -0
- package/src/dome/dome/order/success.vue +68 -0
- package/src/dome/dome/product.vue +179 -0
- package/src/dome/dome/store_cashier.vue +67 -0
- package/src/dome/dome/swiper.vue +32 -0
- package/src/dome/dome/webview.vue +61 -0
- package/src/install.js +183 -0
- package/src/main/address/address.vue +251 -0
- package/src/main/cart/cart.vue +149 -0
- package/src/main/cashier/cashier.vue +72 -0
- package/src/main/cashier/check_cashier.vue +483 -0
- package/src/main/city/city.vue +149 -0
- package/src/main/date/date.vue +260 -0
- package/src/main/order/order.js +19 -0
- package/src/main/order/order.vue +222 -0
- package/src/main/product/detail.vue +121 -0
- package/src/main/product/type.vue +108 -0
- package/src/main/search/search.vue +501 -0
- package/src/pages.json +337 -0
- package/src/plugins/CreatedComponentsPlugin.js +19 -0
- package/src/plugins/JsonRename.js +72 -0
- package/src/plugins/SetAppParams.js +171 -0
- package/src/project.js +18 -0
- package/src/utils/Cookie.js +68 -0
- package/src/utils/Runtime.js +105 -0
- package/src/utils/Storage.js +104 -0
- package/src/utils/XdNetwork.js +133 -0
- package/src/utils/helper.js +1321 -0
- package/src/utils/nourl.js +95 -0
- package/src/utils/project.js +17 -0
- package/src/utils/xd.auth.js +61 -0
- package/src/utils/xd.base.js +474 -0
- package/src/utils/xd.common.js +240 -0
- package/src/utils/xd.event.js +99 -0
- package/src/utils/xd.frame.js +96 -0
- package/src/utils/xd.path.js +96 -0
- package/src/utils/xdAppLog.js +170 -0
- package/src/utils/xdWxLog.js +302 -0
- package/src/utils/xdh5log.js +307 -0
- package/src/websetting.js +64 -0
- package/tsconfig.json +9 -0
- package/xd.less +180 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="xd-baidu">
|
|
3
|
+
<baidu-map
|
|
4
|
+
v-if="uiAk"
|
|
5
|
+
class="xd-baidu__content"
|
|
6
|
+
:center="uiCenter"
|
|
7
|
+
:zoom="uiLevel"
|
|
8
|
+
:ak="uiAk"
|
|
9
|
+
@ready="handleReady"
|
|
10
|
+
@tilesloaded="handleTilesloaded"
|
|
11
|
+
>
|
|
12
|
+
<bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT" type="NavigationControlType"></bm-navigation>
|
|
13
|
+
<bm-geolocation
|
|
14
|
+
v-if="isGeolocation"
|
|
15
|
+
@locationSuccess="handleLocationSuccess"
|
|
16
|
+
class="xd-baidu__content-geolocation"
|
|
17
|
+
anchor="BMAP_ANCHOR_BOTTOM_RIGHT"
|
|
18
|
+
:showAddressBar="true"
|
|
19
|
+
:autoLocation="true"
|
|
20
|
+
|
|
21
|
+
></bm-geolocation>
|
|
22
|
+
<bm-marker
|
|
23
|
+
v-if="isGeolocation && uiGeolocation !== null"
|
|
24
|
+
:position="uiGeolocation"
|
|
25
|
+
:dragging="false"
|
|
26
|
+
animation="BMAP_ANIMATION_BOUNCE"
|
|
27
|
+
></bm-marker>
|
|
28
|
+
<bm-marker
|
|
29
|
+
v-if="isMaker"
|
|
30
|
+
:position="uiCenter"
|
|
31
|
+
:dragging="false"
|
|
32
|
+
animation="BMAP_ANIMATION_BOUNCE"
|
|
33
|
+
></bm-marker>
|
|
34
|
+
<template v-if="defaultOverlays !== null" v-for="(item,index) in defaultOverlays">
|
|
35
|
+
<bm-circle
|
|
36
|
+
v-if="item.type === 'Circle'"
|
|
37
|
+
:center="getArrayToObject(item.value[0])"
|
|
38
|
+
:radius="strToNumber(item.r)"
|
|
39
|
+
:stroke-color="stroke.strokeColor"
|
|
40
|
+
:stroke-opacity="stroke.fillOpacity"
|
|
41
|
+
:stroke-weight="stroke.strokeWeight"
|
|
42
|
+
:fill-color="stroke.fillColor"
|
|
43
|
+
:fill-opacity="stroke.fillOpacity"
|
|
44
|
+
:editing="false"
|
|
45
|
+
></bm-circle>
|
|
46
|
+
<bm-polygon
|
|
47
|
+
v-if="item.type === 'Polygon'"
|
|
48
|
+
:path="getArraysToObjects(item.value)"
|
|
49
|
+
:stroke-color="stroke.strokeColor"
|
|
50
|
+
:stroke-opacity="stroke.fillOpacity"
|
|
51
|
+
:stroke-weight="stroke.strokeWeight"
|
|
52
|
+
:fill-color="stroke.fillColor"
|
|
53
|
+
:fill-opacity="stroke.fillOpacity"
|
|
54
|
+
:editing="false"
|
|
55
|
+
></bm-polygon>
|
|
56
|
+
<bm-marker
|
|
57
|
+
v-if="item.type === 'Marker'"
|
|
58
|
+
:position="getArrayToObject(item.value[0])"
|
|
59
|
+
:dragging="false"
|
|
60
|
+
animation="BMAP_ANIMATION_BOUNCE"
|
|
61
|
+
></bm-marker>
|
|
62
|
+
<bm-boundary
|
|
63
|
+
v-if="item.type === 'city'"
|
|
64
|
+
:name="item.value"
|
|
65
|
+
:stroke-color="stroke.strokeColor"
|
|
66
|
+
:stroke-opacity="stroke.fillOpacity"
|
|
67
|
+
:stroke-weight="stroke.strokeWeight"
|
|
68
|
+
:fill-color="stroke.fillColor"
|
|
69
|
+
:fill-opacity="stroke.fillOpacity"
|
|
70
|
+
></bm-boundary>
|
|
71
|
+
</template>
|
|
72
|
+
</baidu-map>
|
|
73
|
+
</view>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<script>
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @description 仅仅支持H5端
|
|
80
|
+
* https://dafrok.github.io/vue-baidu-map/#/zh/start/usage
|
|
81
|
+
* https://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a0b0
|
|
82
|
+
* 文档:https://www.npmjs.com/package/gxd-helper
|
|
83
|
+
*
|
|
84
|
+
* @property {Array} center 设置中心点坐标,当有覆盖物时候,使用第一个覆盖物为中心点,无覆盖物并且为设置中心点使用用户自动定位点作为中心点 (选填) 默认:null
|
|
85
|
+
* @property {Boolean} isMaker 完成中心点设置之后是否标记中心点位置 (选填) 默认:false
|
|
86
|
+
* @property {Boolean} isGeolocation 是否启用定位控件 (选填) 默认:true
|
|
87
|
+
* @property {String} ak 百度Ak (选填) 默认:''
|
|
88
|
+
* @property {Number} level 缩放级别 (选填) 默认:15
|
|
89
|
+
* @property {Array} defaultOverlays 覆盖物对象 (选填) 默认:[]
|
|
90
|
+
*
|
|
91
|
+
* @event {Function} onDone 编辑或者创建覆盖物完成事件 参数:overlays(覆盖物对象), overlaysSource(覆盖物数据)
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
import BaiduMap from 'vue-baidu-map/components/map/Map.vue';
|
|
95
|
+
import BmMarker from 'vue-baidu-map/components/overlays/Marker';
|
|
96
|
+
import BmCircle from 'vue-baidu-map/components/overlays/Circle';
|
|
97
|
+
import BmPolygon from 'vue-baidu-map/components/overlays/Polygon';
|
|
98
|
+
import BmGeolocation from 'vue-baidu-map/components/controls/Geolocation';
|
|
99
|
+
import BmBoundary from 'vue-baidu-map/components/others/Boundary';
|
|
100
|
+
import BmNavigation from 'vue-baidu-map/components/controls/Navigation';
|
|
101
|
+
|
|
102
|
+
export default {
|
|
103
|
+
name: "XdBaiduOverlay",
|
|
104
|
+
components:{
|
|
105
|
+
BaiduMap,
|
|
106
|
+
BmMarker,
|
|
107
|
+
BmGeolocation,
|
|
108
|
+
BmCircle,
|
|
109
|
+
BmPolygon,
|
|
110
|
+
BmBoundary,
|
|
111
|
+
BmNavigation
|
|
112
|
+
},
|
|
113
|
+
props:{
|
|
114
|
+
center: {
|
|
115
|
+
type: Array | null,
|
|
116
|
+
default(){
|
|
117
|
+
return null
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
isGeolocation:{
|
|
122
|
+
type:Boolean,
|
|
123
|
+
default: true
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
isMaker: {
|
|
127
|
+
type:Boolean,
|
|
128
|
+
default: false
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
level: {
|
|
132
|
+
type:Number,
|
|
133
|
+
default: 15
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
defaultOverlays: {
|
|
137
|
+
type: Array | null,
|
|
138
|
+
default(){
|
|
139
|
+
return [
|
|
140
|
+
// {
|
|
141
|
+
// type: 'Polyline',
|
|
142
|
+
// value: [[116.399, 39.910],[116.405, 39.920],[116.423493, 39.907445]]
|
|
143
|
+
// },
|
|
144
|
+
// {
|
|
145
|
+
// type: 'Polygon',
|
|
146
|
+
// value: [[116.399, 39.910],[116.405, 39.920],[116.423493, 39.907445]]
|
|
147
|
+
// },
|
|
148
|
+
{
|
|
149
|
+
type: 'Polygon',
|
|
150
|
+
value: [
|
|
151
|
+
[116.387112, 39.920977],
|
|
152
|
+
[116.385243, 39.913063],
|
|
153
|
+
[116.394226, 39.917988],
|
|
154
|
+
[116.401772, 39.921364],
|
|
155
|
+
[116.41248, 39.927893]
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
type: 'Circle',
|
|
160
|
+
r: 1000, //1米
|
|
161
|
+
value: [
|
|
162
|
+
[116.423493, 39.907445],
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
type: 'Marker',
|
|
167
|
+
value: [[116.4782359673445, 39.909576462078476]]
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
type: 'city',
|
|
171
|
+
value: '贵阳'
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
type: 'city',
|
|
175
|
+
value: '山东'
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
{
|
|
179
|
+
type: 'Boundary',
|
|
180
|
+
value:[
|
|
181
|
+
[[116.399, 39.910], [116.405, 39.920], [116.423493, 39.907445]],
|
|
182
|
+
[
|
|
183
|
+
[116.38711199999995, 39.92097707656194],
|
|
184
|
+
[116.38524299999993, 39.91306307719058],
|
|
185
|
+
[116.4289369609569, 39.900997411802976],
|
|
186
|
+
[116.42548746779859, 39.91876314730457],
|
|
187
|
+
[116.41247999999993, 39.9278930760079],
|
|
188
|
+
[116.38711199999995, 39.92097707656194]
|
|
189
|
+
]
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
ak: {
|
|
197
|
+
type: String,
|
|
198
|
+
default: ''
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
watch:{
|
|
203
|
+
BMap(){
|
|
204
|
+
if(this.BMap !== null && this.loaded) {
|
|
205
|
+
this.handleInitDone({BMap: this.BMap});
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
loaded(){
|
|
209
|
+
if(this.BMap !== null && this.loaded) {
|
|
210
|
+
this.handleInitDone({BMap: this.BMap});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
data(){
|
|
216
|
+
return {
|
|
217
|
+
uiLevel: 15,
|
|
218
|
+
uiCenter: null,
|
|
219
|
+
uiGeolocation: null,
|
|
220
|
+
uiAk: null,
|
|
221
|
+
|
|
222
|
+
stroke: {
|
|
223
|
+
strokeColor: '#f00',
|
|
224
|
+
strokeWeight: 2,
|
|
225
|
+
fillColor: 'blue',
|
|
226
|
+
fillOpacity: 0.4,
|
|
227
|
+
strokeOpacity: .8
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
//判断地图是否加载完成
|
|
231
|
+
BMap: null,
|
|
232
|
+
loaded: false,
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
created() {
|
|
238
|
+
this.uiAk = this.$settings.baiduAk || this.ak;
|
|
239
|
+
if(!this.uiAk) throw new Error('请传入百度AK值');
|
|
240
|
+
else{
|
|
241
|
+
let uiCenter = '北京';
|
|
242
|
+
if(this.center !== null) {
|
|
243
|
+
if(this.$xdUniHelper.checkVarType(this.center) === 'array'
|
|
244
|
+
&& this.center.length === 2
|
|
245
|
+
) {
|
|
246
|
+
uiCenter = this.getArrayToObject(this.center);
|
|
247
|
+
}
|
|
248
|
+
if(this.$xdUniHelper.checkVarType(this.center) === 'string'){
|
|
249
|
+
uiCenter = this.center;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
//自动定位到第一个覆盖物
|
|
254
|
+
if(this.defaultOverlays && this.defaultOverlays.length > 0) {
|
|
255
|
+
if(this.$xdUniHelper.checkVarType(this.defaultOverlays[0].value) === 'array') {
|
|
256
|
+
uiCenter = this.getArrayToObject(this.defaultOverlays[0].value[0]);
|
|
257
|
+
}
|
|
258
|
+
if(this.$xdUniHelper.checkVarType(this.defaultOverlays[0].value) === 'string'){
|
|
259
|
+
uiCenter = this.defaultOverlays[0].value;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
this.uiCenter = uiCenter;
|
|
263
|
+
|
|
264
|
+
if(this.level) this.uiLevel = this.level;
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
methods: {
|
|
269
|
+
getArraysToObjects(arr){
|
|
270
|
+
return arr.map(item=>{
|
|
271
|
+
return {
|
|
272
|
+
lng: Number(item[0]),
|
|
273
|
+
lat: Number(item[1])
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
},
|
|
277
|
+
getArrayToObject(arr){
|
|
278
|
+
return {
|
|
279
|
+
lng: Number(arr[0]),
|
|
280
|
+
lat: Number(arr[1])
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
handleLocationSuccess(location){
|
|
285
|
+
let point = this.$xdUniHelper.cloneDeep(location.point);
|
|
286
|
+
delete point['of']
|
|
287
|
+
this.uiGeolocation = point;
|
|
288
|
+
this.uiLevel = 15;
|
|
289
|
+
this.uiCenter = point;
|
|
290
|
+
this.$emit('onLocationSuccess',location);
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
handleInitDone({BMap}){
|
|
294
|
+
if(this.isGeolocation) {
|
|
295
|
+
let geolocation = new BMap['Geolocation']();
|
|
296
|
+
geolocation['enableSDKLocation']();
|
|
297
|
+
geolocation.getCurrentPosition(
|
|
298
|
+
(location) => {
|
|
299
|
+
console.log('handleInitDone',location)
|
|
300
|
+
if(!this.defaultOverlays || this.defaultOverlays.length === 0) {
|
|
301
|
+
let point = this.$xdUniHelper.cloneDeep(location.point);
|
|
302
|
+
delete point['of']
|
|
303
|
+
this.uiGeolocation = point;
|
|
304
|
+
this.uiLevel = 15;
|
|
305
|
+
this.uiCenter = point;
|
|
306
|
+
}
|
|
307
|
+
this.$emit('onLocationSuccess',location);
|
|
308
|
+
},
|
|
309
|
+
(error) => {
|
|
310
|
+
console.log('handleInitDone',error)
|
|
311
|
+
}
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
handleReady({BMap}){
|
|
317
|
+
this.BMap = BMap;
|
|
318
|
+
},
|
|
319
|
+
|
|
320
|
+
handleTilesloaded(){
|
|
321
|
+
this.loaded = true;
|
|
322
|
+
},
|
|
323
|
+
|
|
324
|
+
strToNumber(str){
|
|
325
|
+
if(str === '' || str === null || str === undefined) return '';
|
|
326
|
+
if (this.$xdUniHelper.checkVarType(str) === 'string') str = Number(str);
|
|
327
|
+
return str;
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
}
|
|
331
|
+
</script>
|
|
332
|
+
|
|
333
|
+
<style scoped lang="less">
|
|
334
|
+
.xd-baidu {
|
|
335
|
+
width: 100%;
|
|
336
|
+
height: 100%;
|
|
337
|
+
box-sizing: border-box;
|
|
338
|
+
|
|
339
|
+
&__content {
|
|
340
|
+
height: 100%;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
</style>
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="xd-baidu">
|
|
3
|
+
<baidu-map
|
|
4
|
+
v-if="uiAk"
|
|
5
|
+
class="xd-baidu__content"
|
|
6
|
+
:center="uiCenter"
|
|
7
|
+
:zoom="uiLevel"
|
|
8
|
+
:ak="ak"
|
|
9
|
+
@ready="handleReady"
|
|
10
|
+
@tilesloaded="handleTilesloaded"
|
|
11
|
+
>
|
|
12
|
+
<bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT" type="NavigationControlType"></bm-navigation>
|
|
13
|
+
<bm-geolocation
|
|
14
|
+
v-if="isGeolocation"
|
|
15
|
+
@locationSuccess="handleLocationSuccess"
|
|
16
|
+
class="xd-baidu__content-geolocation"
|
|
17
|
+
anchor="BMAP_ANCHOR_BOTTOM_RIGHT"
|
|
18
|
+
:showAddressBar="true"
|
|
19
|
+
:autoLocation="true"
|
|
20
|
+
|
|
21
|
+
></bm-geolocation>
|
|
22
|
+
<bm-marker
|
|
23
|
+
v-if="isGeolocation && uiGeolocation !== null"
|
|
24
|
+
:position="uiGeolocation"
|
|
25
|
+
:dragging="false"
|
|
26
|
+
animation="BMAP_ANIMATION_BOUNCE"
|
|
27
|
+
></bm-marker>
|
|
28
|
+
</baidu-map>
|
|
29
|
+
<view class="xd-baidu__box">
|
|
30
|
+
<view class="xd-baidu__box-search">
|
|
31
|
+
<input placeholder="请输入关键字" v-model="keyword" @input="handleInput"/>
|
|
32
|
+
</view>
|
|
33
|
+
</view>
|
|
34
|
+
<view class="xd-baidu__result" v-if="keyword">
|
|
35
|
+
<view class="xd-baidu__result-box" id="xd-baidu__result"></view>
|
|
36
|
+
</view>
|
|
37
|
+
</view>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script>
|
|
41
|
+
/**
|
|
42
|
+
* @description 仅仅支持H5端
|
|
43
|
+
* https://dafrok.github.io/vue-baidu-map/#/zh/start/usage
|
|
44
|
+
* https://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a0b0
|
|
45
|
+
* 文档:https://www.npmjs.com/package/gxd-helper
|
|
46
|
+
*
|
|
47
|
+
* @property {Array} center 设置中心点坐标 (选填) 默认:[116.404, 39.915]天安门
|
|
48
|
+
* @property {Number} level 缩放级别 (选填) 默认:15
|
|
49
|
+
* @property {Boolean} isGeolocation 是否启用定位控件 (选填) 默认:true
|
|
50
|
+
* @property {String} ak 百度Ak (选填) 默认:''
|
|
51
|
+
*
|
|
52
|
+
* @event {Function} onLocationSuccess 定位对象(location)
|
|
53
|
+
* @event {Function} onSelect 选择地址详情对象(address))
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
import BaiduMap from 'vue-baidu-map/components/map/Map.vue';
|
|
57
|
+
import BmMarker from 'vue-baidu-map/components/overlays/Marker';
|
|
58
|
+
import XdButton from "@/components/XdButton/XdButton";
|
|
59
|
+
import BmNavigation from 'vue-baidu-map/components/controls/Navigation';
|
|
60
|
+
import BmGeolocation from 'vue-baidu-map/components/controls/Geolocation';
|
|
61
|
+
import BmLocalSearch from 'vue-baidu-map/components/search/LocalSearch';
|
|
62
|
+
|
|
63
|
+
export default {
|
|
64
|
+
name: "XdBaiduSearch",
|
|
65
|
+
components: {
|
|
66
|
+
XdButton,
|
|
67
|
+
BmMarker,
|
|
68
|
+
BaiduMap,
|
|
69
|
+
BmNavigation,
|
|
70
|
+
BmGeolocation,
|
|
71
|
+
BmLocalSearch
|
|
72
|
+
},
|
|
73
|
+
props: {
|
|
74
|
+
ak: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: 'hAKGzqKPqNtR6mnXbWgCM6wc2nW8OdUK'
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
center: {
|
|
80
|
+
type: Array,
|
|
81
|
+
default() {
|
|
82
|
+
return []
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
level: {
|
|
87
|
+
type: Number,
|
|
88
|
+
default: 15
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
isGeolocation:{
|
|
92
|
+
type:Boolean,
|
|
93
|
+
default: true
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
watch:{
|
|
97
|
+
BMap(){
|
|
98
|
+
if(this.BMap !== null && this.loaded) {
|
|
99
|
+
this.handleInitDone({BMap: this.BMap});
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
loaded(){
|
|
103
|
+
if(this.BMap !== null && this.loaded) {
|
|
104
|
+
this.handleInitDone({BMap: this.BMap});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
data() {
|
|
110
|
+
return {
|
|
111
|
+
uiLevel: 15,
|
|
112
|
+
uiCenter: null,
|
|
113
|
+
uiGeolocation: null,
|
|
114
|
+
keyword:'',
|
|
115
|
+
show: false,
|
|
116
|
+
resultPoint: [],
|
|
117
|
+
uiAk: null,
|
|
118
|
+
|
|
119
|
+
//判断地图是否加载完成
|
|
120
|
+
BMap: null,
|
|
121
|
+
loaded: false,
|
|
122
|
+
map: null
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
created() {
|
|
127
|
+
this.uiAk = this.$settings.baiduAk || this.ak;
|
|
128
|
+
if(!this.uiAk) throw new Error('请传入百度AK值');
|
|
129
|
+
else{
|
|
130
|
+
let uiCenter = '北京';
|
|
131
|
+
if(this.center !== null) {
|
|
132
|
+
if(this.$xdUniHelper.checkVarType(this.center) === 'array'
|
|
133
|
+
&& this.center.length === 2
|
|
134
|
+
) {
|
|
135
|
+
uiCenter = this.getArrayToObject(this.center);
|
|
136
|
+
}
|
|
137
|
+
if(this.$xdUniHelper.checkVarType(this.center) === 'string'){
|
|
138
|
+
uiCenter = this.center;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
this.uiCenter = uiCenter;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
methods: {
|
|
148
|
+
|
|
149
|
+
getArrayToObject(arr){
|
|
150
|
+
return {
|
|
151
|
+
lng: Number(arr[0]),
|
|
152
|
+
lat: Number(arr[1])
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
handleLocationSuccess(location){
|
|
157
|
+
let point = this.$xdUniHelper.cloneDeep(location.point);
|
|
158
|
+
delete point['of']
|
|
159
|
+
this.uiGeolocation = point;
|
|
160
|
+
this.uiLevel = 15;
|
|
161
|
+
this.uiCenter = point;
|
|
162
|
+
this.getAddress(location.point)
|
|
163
|
+
this.$emit('onLocationSuccess',location);
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
handleInitDone({BMap}){
|
|
167
|
+
if(this.isGeolocation) {
|
|
168
|
+
let geolocation = new BMap['Geolocation']();
|
|
169
|
+
geolocation['enableSDKLocation']();
|
|
170
|
+
geolocation.getCurrentPosition(
|
|
171
|
+
(location) => {
|
|
172
|
+
console.log('handleInitDone',location)
|
|
173
|
+
//alert(JSON.stringify(location.address))
|
|
174
|
+
let point = this.$xdUniHelper.cloneDeep(location.point);
|
|
175
|
+
delete point['of']
|
|
176
|
+
this.uiGeolocation = point;
|
|
177
|
+
this.uiLevel = 15;
|
|
178
|
+
this.uiCenter = point;
|
|
179
|
+
this.getAddress(location.point)
|
|
180
|
+
this.$emit('onLocationSuccess',location);
|
|
181
|
+
},
|
|
182
|
+
(error) => {
|
|
183
|
+
console.log('handleInitDone',error)
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
handleReady({BMap, map}){
|
|
190
|
+
this.BMap = BMap;
|
|
191
|
+
this.map = map;
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
handleTilesloaded(){
|
|
195
|
+
this.loaded = true;
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
strToNumber(str){
|
|
199
|
+
if(str === '' || str === null || str === undefined) return '';
|
|
200
|
+
if (this.$xdUniHelper.checkVarType(str) === 'string') str = Number(str);
|
|
201
|
+
return str;
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
getAddress(point){
|
|
205
|
+
let geocode = new this.BMap['Geocoder']();
|
|
206
|
+
geocode.getLocation(point,(addres)=>{
|
|
207
|
+
if(addres['surroundingPois'].length > 0){
|
|
208
|
+
this.keyword = addres['surroundingPois'][0]['title'];
|
|
209
|
+
setTimeout(()=>{
|
|
210
|
+
console.log(addres['surroundingPois'])
|
|
211
|
+
this.handleSearch(this.keyword)
|
|
212
|
+
}, 10)
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
handleSearch(value) {
|
|
218
|
+
if (value === '') {
|
|
219
|
+
this.map.clearOverlays();
|
|
220
|
+
}
|
|
221
|
+
let local = new BMap.LocalSearch(this.map, {
|
|
222
|
+
renderOptions: {
|
|
223
|
+
map: this.map,
|
|
224
|
+
panel: "xd-baidu__result",
|
|
225
|
+
selectFirstResult: false,
|
|
226
|
+
pageCapacity: 100,
|
|
227
|
+
},
|
|
228
|
+
onInfoHtmlSet: (result) => {
|
|
229
|
+
if (this.isFirst) this.handleSelect(result);
|
|
230
|
+
else {
|
|
231
|
+
this.$emit('onSelect', {
|
|
232
|
+
address: this.defaultValue,
|
|
233
|
+
longitude: this.resultPoint[0],
|
|
234
|
+
latitude: this.resultPoint[1],
|
|
235
|
+
sourceData: null
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
if (!this.isFirst) this.isFirst = true;
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
onSearchComplete: (result) => {
|
|
242
|
+
let select = null;
|
|
243
|
+
//查找地址是否有相同,没有相同返回第一条
|
|
244
|
+
if (result && result['_pois']) {
|
|
245
|
+
result['_pois'].map((item, index) => {
|
|
246
|
+
if (index === 0) {
|
|
247
|
+
select = item
|
|
248
|
+
this.initIndex = index;
|
|
249
|
+
} else {
|
|
250
|
+
if (value === item.address) {
|
|
251
|
+
select = item;
|
|
252
|
+
this.initIndex = index;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
onResultsHtmlSet: (result) => {
|
|
260
|
+
let li = result.getElementsByTagName('li');
|
|
261
|
+
this.isFirst = true;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
console.log('handleSearch',value)
|
|
265
|
+
local.search(value);
|
|
266
|
+
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
handleSelect(result) {
|
|
270
|
+
this.resultPoint = [result['point']['lng'], result['point']['lat']];
|
|
271
|
+
this.address = result['address'];
|
|
272
|
+
this.$emit('onSelect', {
|
|
273
|
+
address: `${this.keyword}@${this.address}`,
|
|
274
|
+
longitude: result['point']['lng'],
|
|
275
|
+
latitude: result['point']['lat'],
|
|
276
|
+
sourceData: result,
|
|
277
|
+
})
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
handleInput() {
|
|
281
|
+
if (this.timeer) clearTimeout(this.timeer);
|
|
282
|
+
this.timeer = setTimeout(() => {
|
|
283
|
+
this.isFirst = false;
|
|
284
|
+
this.handleSearch(this.keyword)
|
|
285
|
+
}, 600)
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
}
|
|
289
|
+
</script>
|
|
290
|
+
|
|
291
|
+
<style lang="less">
|
|
292
|
+
.xd-baidu {
|
|
293
|
+
height: 100%;
|
|
294
|
+
box-sizing: border-box;
|
|
295
|
+
position: relative;
|
|
296
|
+
overflow: hidden;
|
|
297
|
+
|
|
298
|
+
&__content {
|
|
299
|
+
height: 50%;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
&__box {
|
|
304
|
+
position: absolute;
|
|
305
|
+
left: 0;
|
|
306
|
+
right: 0;
|
|
307
|
+
top: unit(10, rpx);
|
|
308
|
+
height:unit(90, rpx);
|
|
309
|
+
box-sizing: border-box;
|
|
310
|
+
|
|
311
|
+
&-search {
|
|
312
|
+
width: unit(500, rpx);
|
|
313
|
+
background: #fff;
|
|
314
|
+
box-shadow: 0 0 unit(20, rpx) rgba(0, 0, 0, 0.3);
|
|
315
|
+
border-radius: unit(36, rpx);
|
|
316
|
+
position: absolute;
|
|
317
|
+
left: unit(20, rpx);
|
|
318
|
+
top: unit(20, rpx);
|
|
319
|
+
z-index: 10;
|
|
320
|
+
height: unit(72, rpx);
|
|
321
|
+
padding: 0 unit(20, rpx);
|
|
322
|
+
|
|
323
|
+
& > input {
|
|
324
|
+
width: 100%;
|
|
325
|
+
height: 100%;
|
|
326
|
+
font-size: @xd-font-size-lg;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
&__result {
|
|
332
|
+
width: 100%;
|
|
333
|
+
height: 50%;
|
|
334
|
+
background: #fff;
|
|
335
|
+
padding: 0 unit(10, rpx);
|
|
336
|
+
overflow-y: auto;
|
|
337
|
+
overflow-x: hidden;
|
|
338
|
+
box-sizing: border-box;
|
|
339
|
+
|
|
340
|
+
& ::v-deep a {
|
|
341
|
+
display: none;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
&-box {
|
|
345
|
+
& > ::v-deep * > *:nth-child(2) {
|
|
346
|
+
display: none;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
</style>
|