ry-vue-map 0.5.0 → 0.5.2
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/README.MD +1 -1
- package/lib/ryui.common.js +373 -340
- package/lib/ryui.common.js.gz +0 -0
- package/lib/ryui.css +1 -1
- package/lib/ryui.css.gz +0 -0
- package/lib/ryui.umd.js +373 -340
- package/lib/ryui.umd.js.gz +0 -0
- package/lib/ryui.umd.min.js +5 -5
- package/lib/ryui.umd.min.js.gz +0 -0
- package/package.json +2 -2
- package/src/components/maps/ryMap/src/index.vue +8 -0
- package/src/components/maps/ryMapTool/src/index.vue +18 -5
- package/src/utils/Overlay.js +193 -0
- package/src/utils/lMapServices.js +10 -17
- package/src/utils/mapPopover/index.js +2 -0
- package/src/utils/mapPopover/lPopover.js +76 -0
- package/src/utils/marker.js +135 -0
- package/src/views/map/index.vue +1038 -995
package/lib/ryui.umd.min.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ry-vue-map",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "lib/ryui.umd.min.js",
|
|
6
6
|
"description": "ry公共组件库",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"kml-to-geojson": "^1.0.13",
|
|
46
46
|
"nprogress": "~0.2.0",
|
|
47
47
|
"ol": "^6.14.1",
|
|
48
|
-
"ry-map": "^0.4.
|
|
48
|
+
"ry-map": "^0.4.9",
|
|
49
49
|
"vue": "~2.6.14",
|
|
50
50
|
"vue-demi": "^0.13.11",
|
|
51
51
|
"vue-router": "~3.5.2",
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
:hidePoint="hidePoint" :hideCancel="hideCancel" :hideDelete="hideDelete" :hideSave="hideSave"
|
|
12
12
|
:hideLine="hideLine" :hideArea="hideArea" :isSwitchMap="isSwitchMap" :isSwitchMapRight="isSwitchMapRight"
|
|
13
13
|
:gpsType="lastMapType" @loadDrawPolygonEvent="loadDrawPolygonEvent($event)" @success="drawSuccess($event)"
|
|
14
|
+
@drawPolygonEvent="drawPolygonEvent($event)"
|
|
15
|
+
@drawLineEvent="drawLineEvent($event)"
|
|
14
16
|
@error="drawError($event)">
|
|
15
17
|
<template>
|
|
16
18
|
<slot name="maptool"></slot>
|
|
@@ -243,6 +245,12 @@
|
|
|
243
245
|
drawError(obj) {
|
|
244
246
|
this.$emit('drawError', obj);
|
|
245
247
|
},
|
|
248
|
+
drawPolygonEvent(obj){
|
|
249
|
+
this.$emit('drawPolygonEvent',obj);
|
|
250
|
+
},
|
|
251
|
+
drawLineEvent(obj){
|
|
252
|
+
this.$emit('drawLineEvent',obj);
|
|
253
|
+
},
|
|
246
254
|
_mapClickOnce(isBinClick = false) {
|
|
247
255
|
if (!this.mapClick) {
|
|
248
256
|
this.mapClick = evt => {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
</aside>
|
|
18
18
|
|
|
19
19
|
<aside class="map-control" v-if="isShowRangingTool" style="margin-left: 60px;">
|
|
20
|
-
<el-button v-if="!hideLine" class="ele-text-primary el-icon--changdu" @click.stop="
|
|
20
|
+
<el-button v-if="!hideLine" class="ele-text-primary el-icon--changdu" @click.stop="onCreateLine()">
|
|
21
21
|
</el-button>
|
|
22
|
-
<el-button v-if="!hideArea" class="ele-text-primary el-icon--mianji" @click.stop="
|
|
22
|
+
<el-button v-if="!hideArea" class="ele-text-primary el-icon--mianji" @click.stop="onCreateArea()">
|
|
23
23
|
</el-button>
|
|
24
24
|
</aside>
|
|
25
25
|
</template>
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
|
|
28
28
|
<template v-else>
|
|
29
29
|
<aside class="map-control" v-if="isShowRangingTool" style=" margin-right: 60px;">
|
|
30
|
-
<el-button v-if="!hideLine" class="ele-text-primary el-icon--changdu" @click.stop="
|
|
30
|
+
<el-button v-if="!hideLine" class="ele-text-primary el-icon--changdu" @click.stop="onCreateLine()">
|
|
31
31
|
</el-button>
|
|
32
|
-
<el-button v-if="!hideArea" class="ele-text-primary el-icon--mianji" @click.stop="
|
|
32
|
+
<el-button v-if="!hideArea" class="ele-text-primary el-icon--mianji" @click.stop="onCreateArea()">
|
|
33
33
|
</el-button>
|
|
34
34
|
</aside>
|
|
35
35
|
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
import MapToolDto from './../../models/ryMapTool/mapTool.js';
|
|
58
58
|
import {
|
|
59
59
|
fitNew,
|
|
60
|
-
GPS
|
|
60
|
+
GPS,
|
|
61
|
+
generateGuid
|
|
61
62
|
} from 'ry-map';
|
|
62
63
|
export default {
|
|
63
64
|
name: 'RyMapTool',
|
|
@@ -267,6 +268,18 @@
|
|
|
267
268
|
if(!this.lMap) return;
|
|
268
269
|
this.lMap.onCancel();
|
|
269
270
|
},
|
|
271
|
+
onCreateLine(){
|
|
272
|
+
let draw = this.lMap.onCreateLine((id,type) => {
|
|
273
|
+
this.$emit('drawLineEvent',{draw,id,type});
|
|
274
|
+
});
|
|
275
|
+
draw.Id=generateGuid();
|
|
276
|
+
},
|
|
277
|
+
onCreateArea(){
|
|
278
|
+
let draw = this.lMap.onCreateArea((id,type) => {
|
|
279
|
+
this.$emit('drawPolygonEvent',{draw,id,type});
|
|
280
|
+
});
|
|
281
|
+
draw.Id=generateGuid();
|
|
282
|
+
},
|
|
270
283
|
selectGPSAll(type){
|
|
271
284
|
this.lMap.removeDrawArr();
|
|
272
285
|
if(this.drawPolygon){
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
export class Overlay {
|
|
2
|
+
constructor(cesium) {
|
|
3
|
+
if (!Overlay.instance) {
|
|
4
|
+
this.call = null;
|
|
5
|
+
this._viewer = null;
|
|
6
|
+
this.markers = new Set();
|
|
7
|
+
this.cesium = cesium;
|
|
8
|
+
this._isBinEvent = false;
|
|
9
|
+
Overlay.instance = this;
|
|
10
|
+
this.call = () => {
|
|
11
|
+
this.callback();
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return Overlay.instance;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
set setViewer(viewer) {
|
|
19
|
+
this._viewer = viewer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
callback() {
|
|
23
|
+
const scene = this._viewer.scene;
|
|
24
|
+
this.markers.forEach((marker) => {
|
|
25
|
+
const windowCoord = this.cesium.SceneTransforms.wgs84ToWindowCoordinates(
|
|
26
|
+
scene,
|
|
27
|
+
this.cesium.Cartesian3.fromDegrees(...marker.getCenter, 0)
|
|
28
|
+
);
|
|
29
|
+
if (!windowCoord || !windowCoord.x || !windowCoord.y || !marker.isShow)
|
|
30
|
+
return;
|
|
31
|
+
const left =
|
|
32
|
+
windowCoord.x - marker.getDom.offsetWidth / 2 + marker.offset[0];
|
|
33
|
+
const top = windowCoord.y - marker.getDom.offsetHeight + marker.offset[1];
|
|
34
|
+
const dom = marker.getDom;
|
|
35
|
+
dom.style.left = `${left}px`;
|
|
36
|
+
dom.style.top = `${top}px`;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
addEventListener() {
|
|
41
|
+
if (this._isBinEvent) return;
|
|
42
|
+
this._isBinEvent = true;
|
|
43
|
+
const scene = this._viewer.scene;
|
|
44
|
+
scene.postRender.addEventListener(this.call);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
removeEventListener() {
|
|
48
|
+
if (!this._isBinEvent) return;
|
|
49
|
+
this._isBinEvent = false;
|
|
50
|
+
const scene = this._viewer.scene;
|
|
51
|
+
scene.postRender.removeEventListener(this.call);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
add(overlay) {
|
|
55
|
+
if (!this.markers.has(overlay)) {
|
|
56
|
+
this.markers.add(overlay);
|
|
57
|
+
this._viewer.container.appendChild(overlay.getDom);
|
|
58
|
+
}
|
|
59
|
+
if (this.markers.size) {
|
|
60
|
+
this.addEventListener();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
remove(overlay) {
|
|
65
|
+
if (this.markers.has(overlay)) {
|
|
66
|
+
this.markers.delete(overlay);
|
|
67
|
+
this._viewer.container.removeChild(overlay.getDom);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!this.markers.size) {
|
|
71
|
+
this.removeEventListener();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
clearOverlay() {
|
|
75
|
+
this.markers.forEach((overlay) => this.remove(overlay));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default class MarkerBase {
|
|
80
|
+
constructor(opt) {
|
|
81
|
+
this.id = opt.id;
|
|
82
|
+
this.center = opt.center;
|
|
83
|
+
this.style = opt.style;
|
|
84
|
+
this.ele = document.createElement('div');
|
|
85
|
+
this._show = true;
|
|
86
|
+
this.offset = opt.offset || [0, 0];
|
|
87
|
+
this.init();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
init() {
|
|
91
|
+
this.crateOverlay();
|
|
92
|
+
this.show();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
crateOverlay() {
|
|
96
|
+
this.ele = document.createElement('div');
|
|
97
|
+
this.setStyle = this.style;
|
|
98
|
+
this.ele.id = this.id;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
hide() {
|
|
102
|
+
this.ele.style.display = 'none';
|
|
103
|
+
this._show = false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
show() {
|
|
107
|
+
// this.ele.style.display = 'block';
|
|
108
|
+
this.ele.style.display = 'flex';
|
|
109
|
+
this._show = true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
get getCenter() {
|
|
113
|
+
return this.center;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
get getDom() {
|
|
117
|
+
return this.ele;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
_setStyle(styles) {
|
|
121
|
+
styles = styles.split(';').filter((r) => r !== '');
|
|
122
|
+
styles.forEach((item) => {
|
|
123
|
+
const _styles = item.split(':');
|
|
124
|
+
if (_styles.length == 2) {
|
|
125
|
+
this.ele.style.setProperty(..._styles);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
set setStyle(style) {
|
|
131
|
+
this._setStyle(`position:absolute;${style}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get isShow() {
|
|
135
|
+
return this._show;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
setIndex(zIndex = 10) {
|
|
139
|
+
this.ele.style.zIndex = zIndex;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
setAttribute(options) {
|
|
143
|
+
const data = JSON.stringify(options);
|
|
144
|
+
this.ele.setAttribute('data-op', data);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getAttribute() {
|
|
148
|
+
var _a;
|
|
149
|
+
const json =
|
|
150
|
+
(_a = this.ele.dataset.op) === null || _a === void 0
|
|
151
|
+
? void 0
|
|
152
|
+
: _a.toString();
|
|
153
|
+
return JSON.parse(json);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
setText(text) {
|
|
157
|
+
this.ele.innerText = text;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
setId(id) {
|
|
161
|
+
this.ele.id = id;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
getId() {
|
|
165
|
+
return this.ele.id;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
setOffset(offset) {
|
|
169
|
+
this.offset = offset;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
get getOffset() {
|
|
173
|
+
return this.offset;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
binEvent(event, fun) {
|
|
177
|
+
this._fun = fun;
|
|
178
|
+
this.ele.addEventListener(event, this._fun, false);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
setPosition(center) {
|
|
182
|
+
this.center = center;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
hover(fnOver, fnOut) {
|
|
186
|
+
if (fnOver) {
|
|
187
|
+
this.ele.addEventListener('mouseover', fnOver, false);
|
|
188
|
+
}
|
|
189
|
+
if (fnOut) {
|
|
190
|
+
this.ele.addEventListener('mouseout', fnOut, false);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -393,30 +393,23 @@ export default class LMapServices {
|
|
|
393
393
|
return this._lPolygon.getGeoJson();
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
-
onCreateLine() {
|
|
396
|
+
onCreateLine(callback) {
|
|
397
397
|
if (this.map) {
|
|
398
|
-
let drawLine = new LDraw(
|
|
399
|
-
'LineString',
|
|
400
|
-
(e) => {
|
|
401
|
-
// let arrs = e.feature.getGeometry().getCoordinates();
|
|
402
|
-
// let tooltipCoord = e.coordinate;
|
|
403
|
-
// const obj = {
|
|
404
|
-
// pointArr: arrs,
|
|
405
|
-
// color: '#000',
|
|
406
|
-
// width: 2
|
|
407
|
-
// };
|
|
408
|
-
// new Polyline(obj, this.map);
|
|
409
|
-
},
|
|
410
|
-
this.map
|
|
411
|
-
);
|
|
398
|
+
let drawLine = new LDraw('LineString',callback,this.map);
|
|
412
399
|
this.drawLineArr.add(drawLine);
|
|
400
|
+
return drawLine;
|
|
413
401
|
}
|
|
402
|
+
return null;
|
|
414
403
|
}
|
|
415
404
|
|
|
416
|
-
onCreateArea() {
|
|
405
|
+
onCreateArea(callback) {
|
|
406
|
+
console.log(callback);
|
|
417
407
|
if (this.map) {
|
|
418
|
-
|
|
408
|
+
let draw = new LDraw('Polygon', callback, this.map);
|
|
409
|
+
this.drawPolygonArr.add(draw);
|
|
410
|
+
return draw;
|
|
419
411
|
}
|
|
412
|
+
return null;
|
|
420
413
|
}
|
|
421
414
|
|
|
422
415
|
removeDrawArr() {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { LOverlay } from 'ry-map';
|
|
2
|
+
export default class LPopover extends LOverlay {
|
|
3
|
+
static _options() {
|
|
4
|
+
return {
|
|
5
|
+
size: 15,
|
|
6
|
+
color: 'rgba(0,0,0,.6)',
|
|
7
|
+
isHide: true,
|
|
8
|
+
isArrow: false,
|
|
9
|
+
isClose: true
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
constructor(html, options = {}) {
|
|
13
|
+
super();
|
|
14
|
+
const o = { ...LPopover._options(), ...options };
|
|
15
|
+
o.isHide && (this.ele.style.display = 'none');
|
|
16
|
+
o.isArrow && this.ele.append(this.createAside(o));
|
|
17
|
+
o.isClose && this.ele.append(this.createCloseElement());
|
|
18
|
+
this.init(html);
|
|
19
|
+
}
|
|
20
|
+
init(html) {
|
|
21
|
+
const container = document.createElement('div');
|
|
22
|
+
container.id = 'popover-container';
|
|
23
|
+
this.ele.append(container);
|
|
24
|
+
container.innerHTML = html;
|
|
25
|
+
this.addEvent('.close', () => this.hide());
|
|
26
|
+
}
|
|
27
|
+
createAside(options) {
|
|
28
|
+
const aside = document.createElement('aside');
|
|
29
|
+
aside.style.border = `${options.size}px solid transparent`;
|
|
30
|
+
aside.style.borderTop = `${options.size}px solid ${options.color}`;
|
|
31
|
+
aside.style.position = 'absolute';
|
|
32
|
+
aside.style.bottom = `-${options.size * 2 - 2}px`;
|
|
33
|
+
aside.style.left = `calc(50% - ${options.size}px)`;
|
|
34
|
+
return aside;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
createCloseElement() {
|
|
38
|
+
const aside = document.createElement('aside');
|
|
39
|
+
aside.append(document.createTextNode('x'));
|
|
40
|
+
aside.className = 'close';
|
|
41
|
+
aside.style.width = '18px';
|
|
42
|
+
aside.style.height = '18px';
|
|
43
|
+
aside.style.fontSize = '18px';
|
|
44
|
+
aside.style.position = 'absolute';
|
|
45
|
+
aside.style.top = '1px';
|
|
46
|
+
aside.style.right = '1px';
|
|
47
|
+
aside.style.color = '#fff';
|
|
48
|
+
aside.style.cursor = 'pointer';
|
|
49
|
+
return aside;
|
|
50
|
+
}
|
|
51
|
+
updateInnerHtml(html) {
|
|
52
|
+
const el = this.getElement('#popover-container');
|
|
53
|
+
el.innerHTML = html;
|
|
54
|
+
}
|
|
55
|
+
removeInnerHtml() {
|
|
56
|
+
const el = this.getElement('#popover-container');
|
|
57
|
+
el?.removeChild();
|
|
58
|
+
}
|
|
59
|
+
getElement(name) {
|
|
60
|
+
const el = this.ele.querySelector(name);
|
|
61
|
+
return el || '';
|
|
62
|
+
}
|
|
63
|
+
addEvent(select, cb, event = 'click') {
|
|
64
|
+
const elements = this.ele.querySelectorAll(select);
|
|
65
|
+
elements.forEach((v, index) => {
|
|
66
|
+
v.addEventListener(event, (e) => cb(e, index));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
removeEvent(select, fun, event = 'click') {
|
|
70
|
+
const elements = this.ele.querySelectorAll(select);
|
|
71
|
+
elements.forEach((v, index) => {
|
|
72
|
+
v.removeEventListener(event, fun);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
setHTMLElementStyle() {}
|
|
76
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { LOverlay } from 'ry-map';
|
|
2
|
+
export class MarkerHeaderModel {
|
|
3
|
+
constructor(imgUrls = [], width = 50, height = 50) {
|
|
4
|
+
this.width = width;
|
|
5
|
+
this.height = height;
|
|
6
|
+
this.imgUrls = imgUrls;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class MarkerContentModel {
|
|
11
|
+
constructor(
|
|
12
|
+
text = '',
|
|
13
|
+
color = '#fff',
|
|
14
|
+
backgroundColor = '#ff65f9',
|
|
15
|
+
marginTop = 2
|
|
16
|
+
) {
|
|
17
|
+
this.text = text;
|
|
18
|
+
this.color = color;
|
|
19
|
+
this.backgroundColor = backgroundColor;
|
|
20
|
+
this.marginTop = marginTop;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class MarkerBottomModel {
|
|
25
|
+
constructor(url, width = 24, height = 60, marginTop = 5) {
|
|
26
|
+
this.width = width;
|
|
27
|
+
this.height = height;
|
|
28
|
+
this.imgUrl = url;
|
|
29
|
+
this.marginTop = marginTop;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default class Marker extends LOverlay {
|
|
34
|
+
constructor(
|
|
35
|
+
contentDto,
|
|
36
|
+
headerDto,
|
|
37
|
+
bottomDto = new MarkerBottomModel(require('@/assets/mgh.png'))
|
|
38
|
+
) {
|
|
39
|
+
super();
|
|
40
|
+
this.contentDto = contentDto;
|
|
41
|
+
this.headerDto = headerDto;
|
|
42
|
+
this.bottomDto = bottomDto;
|
|
43
|
+
this.header = document.createElement('section');
|
|
44
|
+
this.content = document.createElement('p');
|
|
45
|
+
this.bottom = document.createElement('aside');
|
|
46
|
+
this._init();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setHTMLElementStyle() {}
|
|
50
|
+
|
|
51
|
+
_init() {
|
|
52
|
+
this.ele.style.width = 'max-content';
|
|
53
|
+
this.ele.style.display = 'flex';
|
|
54
|
+
this.ele.style.justifyContent = 'space-between';
|
|
55
|
+
this.ele.style.position = 'relative';
|
|
56
|
+
this.ele.style.textAlign = 'center';
|
|
57
|
+
this.ele.style.flexDirection = 'column';
|
|
58
|
+
|
|
59
|
+
this.header.style.display = 'inline-block';
|
|
60
|
+
|
|
61
|
+
this.content.style.paddingLeft = '3px';
|
|
62
|
+
this.content.style.paddingRight = '3px';
|
|
63
|
+
this.content.style.borderRadius = '3px';
|
|
64
|
+
this.content.style.height = '25px';
|
|
65
|
+
this.content.style.lineHeight = '25px';
|
|
66
|
+
this.content.style.textAlign = 'center';
|
|
67
|
+
this.content.style.color = this.contentDto.color;
|
|
68
|
+
this.content.style.fontSize = '14px';
|
|
69
|
+
this.content.style.display = 'inline-block';
|
|
70
|
+
this.content.style.backgroundColor = this.contentDto.backgroundColor;
|
|
71
|
+
this.content.style.marginTop = `${this.contentDto.marginTop}px`;
|
|
72
|
+
this.setText(this.contentDto.text);
|
|
73
|
+
|
|
74
|
+
this.bottom.style.height = '60px';
|
|
75
|
+
this.bottom.style.textAlign = 'center';
|
|
76
|
+
this.bottom.style.display = 'inline-block';
|
|
77
|
+
|
|
78
|
+
if (this.headerDto) {
|
|
79
|
+
this._initHeaderImgs(this.headerDto);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.bottomDto) {
|
|
83
|
+
this.bottom.style.marginTop = `${this.bottomDto.marginTop}px`;
|
|
84
|
+
this._intBottomImt(this.bottomDto);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this.ele.appendChild(this.header);
|
|
88
|
+
this.ele.appendChild(this.content);
|
|
89
|
+
this.ele.appendChild(this.bottom);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
_initHeaderImgs(dto) {
|
|
93
|
+
dto.imgUrls.forEach((r, index) => {
|
|
94
|
+
const img = document.createElement('img');
|
|
95
|
+
img.src = r;
|
|
96
|
+
img.style.width = `${dto.width}px`;
|
|
97
|
+
img.style.height = `${dto.height}px`;
|
|
98
|
+
if (index !== 0) {
|
|
99
|
+
img.style.marginLeft = '5px';
|
|
100
|
+
}
|
|
101
|
+
this.header.appendChild(img);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_intBottomImt(dto) {
|
|
106
|
+
const img = document.createElement('img');
|
|
107
|
+
img.style.width = `${dto.width}px`;
|
|
108
|
+
img.style.height = `${dto.height}px`;
|
|
109
|
+
img.src = dto.imgUrl;
|
|
110
|
+
this.bottom.appendChild(img);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
setText(text) {
|
|
114
|
+
this.contentDto.text = text;
|
|
115
|
+
this.content.innerHTML = text;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setTestColor(color = '#fff') {
|
|
119
|
+
this.contentDto.color = color;
|
|
120
|
+
this.content.style.color = color;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
setBackgroundColor(color = ' #ff65f9') {
|
|
124
|
+
this.content.backgroundColor = color;
|
|
125
|
+
this.content.style.backgroundColor = color;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
get width() {
|
|
129
|
+
return this.content.offsetWidth;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
get height() {
|
|
133
|
+
return this.ele.offsetHeight;
|
|
134
|
+
}
|
|
135
|
+
}
|