Commit 8f30a7f0 authored by 沈良进's avatar 沈良进

二级城市页面开发完成

parent d05e3edb
...@@ -393,9 +393,18 @@ export default { ...@@ -393,9 +393,18 @@ export default {
mounted() { mounted() {
var CategoryName = this.getUrlKey("CategoryName", window.location.href); var CategoryName = this.getUrlKey("CategoryName", window.location.href);
if(CategoryName) { if(CategoryName) {
this.goodsType.find(item => item.Name === CategoryName) let list = this.goodsType.find(item => item.CategoryName === CategoryName)
let arr = []
list.children.forEach(item => {
arr.push(item.Id)
if(item.children && item.children.length) {
item.children.forEach(item2 => {
arr.push(item2.Id)
})
}
})
this.ticked = arr
} }
console
}, },
methods: { methods: {
handleSelected(target) { handleSelected(target) {
......
...@@ -66,6 +66,12 @@ ...@@ -66,6 +66,12 @@
background: #ffffff; background: #ffffff;
border-radius: 8px; border-radius: 8px;
} }
#dialog-map {
width: 800px;
height: 400px;
background: #ffffff;
border-radius: 8px;
}
.name { .name {
top: 20px; top: 20px;
left: 20px; left: 20px;
...@@ -181,6 +187,11 @@ ...@@ -181,6 +187,11 @@
</div> </div>
</div> </div>
<nearCity :name="detail.AreaName" :cityList="detail.AdjacentCityList" /> <nearCity :name="detail.AreaName" :cityList="detail.AdjacentCityList" />
<q-dialog v-model="show">
<div style="width: 900px;">
<div id="dialog-map"></div>
</div>
</q-dialog>
</div> </div>
</div> </div>
</template> </template>
...@@ -192,6 +203,7 @@ export default { ...@@ -192,6 +203,7 @@ export default {
components: { topCard, likeCard, nearCity }, components: { topCard, likeCard, nearCity },
data() { data() {
return { return {
show: false,
detail: null, detail: null,
navList: [ navList: [
{ {
...@@ -254,37 +266,23 @@ export default { ...@@ -254,37 +266,23 @@ export default {
this.$q.loading.hide(); this.$q.loading.hide();
this.$nextTick(() => { this.$nextTick(() => {
this.createMap(); this.createMap();
this.addMarker(); this.createTopMap()
this.addLabel()
}) })
}, },
null null
); );
}, },
createMap() { createMap() {
if (!BMapGL) {
return;
}
let map = new BMapGL.Map("baidu-map"); // 创建地图实例 let map = new BMapGL.Map("baidu-map"); // 创建地图实例
this.map = map; this.map = map;
var myGeo = new BMapGL.Geocoder(); let pointA = new BMapGL.Point(this.detail.Lng, this.detail.Lat); // 创建点坐标
const that = this
let address = '日本东京'
console.log('address', address)
myGeo.getPoint(address, function(point){
if(point){
console.log('get point', point)
that.point = point
let pointA = new BMapGL.Point(point.lng, point.lat); // 创建点坐标
map.centerAndZoom(pointA, 8); // 初始化地图,设置中心点坐标和地图级别 map.centerAndZoom(pointA, 8); // 初始化地图,设置中心点坐标和地图级别
}else{ this.addMarker();
alert('您选择的地址没有解析到结果!'); this.addLabel()
}
},'东京')
}, },
addMarker() { addMarker() {
let icon = require(`../../assets/img/info-time.png`); let icon = require(`../../assets/img/marker.png`);
var myIcon = new BMapGL.Icon(icon, new BMapGL.Size(23, 25), { var myIcon = new BMapGL.Icon(icon, new BMapGL.Size(27, 32), {
// 指定定位位置。 // 指定定位位置。
// 当标注显示在地图上时,其所指向的地理位置距离图标左上 // 当标注显示在地图上时,其所指向的地理位置距离图标左上
// 角各偏移10像素和25像素。您可以看到在本例中该位置即是 // 角各偏移10像素和25像素。您可以看到在本例中该位置即是
...@@ -295,30 +293,89 @@ export default { ...@@ -295,30 +293,89 @@ export default {
// 需要指定大图的偏移位置,此做法与css sprites技术类似。 // 需要指定大图的偏移位置,此做法与css sprites技术类似。
// imageOffset: new BMapGL.Size(0, 0 - 25) // 设置图片偏移 // imageOffset: new BMapGL.Size(0, 0 - 25) // 设置图片偏移
}); });
let point = new BMapGL.Point(this.point.lng, this.point.lat); // 创建点坐标 let point = new BMapGL.Point(this.detail.Lng, this.detail.Lat); // 创建点坐标
// 创建标注对象并添加到地图 // 创建标注对象并添加到地图
var marker = new BMapGL.Marker(point, { icon: myIcon }); var marker = new BMapGL.Marker(point, { icon: myIcon });
this.map.addOverlay(marker); this.map.addOverlay(marker);
}, },
addLabel() { addLabel() {
var point = new BMapGL.Point(this.point.lng, this.point.lat); var point = new BMapGL.Point(this.detail.Lng, this.detail.Lat);
var content = "label"; var content = `<div style="font-size: 16px; font-weight: bold;">${this.detail.AreaName}</div><div style="font-size:14px">点击查看附近信息</div>`;
var label = new BMapGL.Label(content, { var label = new BMapGL.Label(content, {
// 创建文本标注 // 创建文本标注
position: point, // 设置标注的地理位置 position: point, // 设置标注的地理位置
offset: new BMapGL.Size(10, -80), // 设置标注的偏移量 offset: new BMapGL.Size(10, -80), // 设置标注的偏移量
}); });
this.map.addOverlay(label); // 将标注添加到地图中 this.map.addOverlay(label); // 将标注添加到地图中
const that = this
label.addEventListener("click", function () {
that.openDialog()
});
label.setStyle({
// 设置label的样式
color: "#000",
backgrond: "#fff",
padding: '4px',
border: 'none'
});
},
createTopMap() {
let map = new BMapGL.Map("map"); // 创建地图实例
this.topMap = map;
let pointA = new BMapGL.Point(this.detail.Lng, this.detail.Lat); // 创建点坐标
map.centerAndZoom(pointA, 8); // 初始化地图,设置中心点坐标和地图级别
this.addTopMarker()
this.addTopLabel()
},
addTopMarker() {
let icon = require(`../../assets/img/marker.png`);
var myIcon = new BMapGL.Icon(icon, new BMapGL.Size(27, 32), {
// 指定定位位置。
// 当标注显示在地图上时,其所指向的地理位置距离图标左上
// 角各偏移10像素和25像素。您可以看到在本例中该位置即是
// 图标中央下端的尖角位置。
anchor: new BMapGL.Size(10, 25),
// 设置图片偏移。
// 当您需要从一幅较大的图片中截取某部分作为标注图标时,您
// 需要指定大图的偏移位置,此做法与css sprites技术类似。
// imageOffset: new BMapGL.Size(0, 0 - 25) // 设置图片偏移
});
let point = new BMapGL.Point(this.detail.Lng, this.detail.Lat); // 创建点坐标
// 创建标注对象并添加到地图
var marker = new BMapGL.Marker(point, { icon: myIcon });
this.topMap.addOverlay(marker);
},
addTopLabel() {
var point = new BMapGL.Point(this.detail.Lng, this.detail.Lat);
var content = `<div style="font-size: 16px; font-weight: bold;">${this.detail.AreaName}</div><div style="font-size:14px">点击查看附近信息</div>`;
var label = new BMapGL.Label(content, {
// 创建文本标注
position: point, // 设置标注的地理位置
offset: new BMapGL.Size(10, -80), // 设置标注的偏移量
});
this.topMap.addOverlay(label); // 将标注添加到地图中
const that = this
label.addEventListener("click", function () { label.addEventListener("click", function () {
alert("您点击了标注"); that.openDialog()
}); });
label.setStyle({ label.setStyle({
// 设置label的样式 // 设置label的样式
color: "#000", color: "#000",
fontSize: "30px", backgrond: "#fff",
border: "2px solid #1E90FF", padding: '4px',
border: 'none'
}); });
}, },
openDialog() {
this.show = true
this.$nextTick(() => {
let map = new BMapGL.Map("dialog-map"); // 创建地图实例
this.map = map;
let pointA = new BMapGL.Point(this.detail.Lng, this.detail.Lat); // 创建点坐标
map.centerAndZoom(pointA, 11); // 初始化地图,设置中心点坐标和地图级别
map.enableScrollWheelZoom()
})
}
}, },
}; };
</script> </script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment