xzqy.js 3.09 KB
$('.area_list li').click(function(){
    $(".area_list li").removeClass("active1")
    $(this).addClass("active1");
   
})

$(".single_input").on("click",function(){
    var par_label = $(this).parent();
    if(this.checked){
        $(".input_label").removeClass("choose_radioed").addClass("choose_radio");
        par_label.removeClass("choose_radio").addClass("choose_radioed");
    }else{
    }
});

layui.use('element', function () {
    let element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
    //监听导航点击
    element.on('nav(demo)', function (elem) {
        //console.log(elem)
        layer.msg(elem.text());
    });
});
//config的设置是全局的
layui.config({
    base: './js/'
}).extend({ //设定模块别名
    common: 'common'
});

layui.use(['form', 'common'], function () {
    var common = layui.common,
        form = layui.form;
    //三级地址联动
    common.showCity('province', 'city');

    //区域选择
    form.on('select(selectCity)', function (data) {
        console.log(data)
        return false;
    });
    //办事大厅
    form.on('select(officehall)', function (data) {
        let latitude= undefined
        let longitude= undefined
        let title= ''
        if(data.value==1) {
            latitude = 116.397469
            longitude = 39.908821
            title = '北京'
        }else if(data.value==2){
            latitude = 121.491119
            longitude = 31.235172
            title = '上海'
        }else {
            latitude = 120.21201
            longitude = 30.2084
            title = '杭州'
        }

        var point = new BMapGL.Point(latitude, longitude);
        var infoWindow = new BMapGL.InfoWindow(title, opts);
        map.openInfoWindow(infoWindow, point);
        return false;
    });

});

var geolocation = new BMap.Geolocation();
var gc = new BMap.Geocoder();
geolocation.getCurrentPosition(function (r) {
    if (this.getStatus() == BMAP_STATUS_SUCCESS) {
        var pt = r.point;
        gc.getLocation(pt, function (rs) {
            var addComp = rs.addressComponents;
            var province = addComp.province;
            var city = addComp.city;
            $('.Pselected').attr('data-area', province)
            $('.Cselected').attr('data-area', city)
            layui.use(['form', 'common'], function () {
                var common = layui.common,
                    form = layui.form;
                //三级地址联动
                common.showCity('province', 'city');
            })
        })
    }
    else {
        alert("定位失败");
    }
}, { enableHighAccuracy: true });

var map = new BMapGL.Map('container');
var point = new BMapGL.Point(108.95309828, 34.2777999);
map.centerAndZoom(point, 15);
var opts = {
    width: 100,
    height: 60,
    title: '办事大厅'
};
var infoWindow = new BMapGL.InfoWindow('雁塔区南二环西段', opts);
map.openInfoWindow(infoWindow, point);


map.centerAndZoom(new BMapGL.Point(108.95309828, 34.2777999), 12); // 初始化地图,设置中心点坐标和地图级别
map.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放