南昌市物联网技防平台-前端
shuishen
2021-04-24 9459612c7ef903fd4de76c84f6c172ee3b0ea144
public/map/widgets/supervisoryMap/FlareClusterLayer_v3.js
@@ -229,6 +229,7 @@
            downs = null,
            moves = null,
            ups = null;
          layui.use('layer', function () {
            that.layuiLayer = layui.layer;
            that.layuiLayer.config({
@@ -236,136 +237,103 @@
            });
            that.layuiLayer.close(that.layuiLayer.index);
            //两个弹窗
            // layer.alert('layer 新皮肤');
            //   that.layuiLayer.open({
            //     title: '',
            //     type: 2,
            //     shadeClose: false,
            //     shade: false,
            //     skin: 'demo-class',
            //     // id: 'onelyOne',
            //     maxmin: false, //开启最大化最小化按钮
            //     area: ['200px', '75px'],
            //     // area: 'auto',
            //     offset: posi,
            //     skin: 'flare',
            //     closeBtn: 0, //关闭按钮,可通过配置1和2来展示,0关闭
            //     content: [url, 'no'],
            //     resize: false,
            //     scrollbar: false,
            //     // tipsMore: true, //允许多个tipe
            //     // content: num,
            //     success: function (layero, index) {//成功后添加全局点击关闭
            //       // console.log(evt.graphic.attributes);
            //       $("#layui-layer-iframe" + index).contents().find("#input1").val(setdata);
            //       // console.log(layero, index);
            //       that.indexs = index;
              that.layuiLayer.open({
                title: '',
                type: 2,
                shadeClose: false,
                shade: false,
                skin: 'demo-class',
                // id: 'onelyOne',
                maxmin: false, //开启最大化最小化按钮
                area: ['200px', '70px'],
                // area: 'auto',
                offset: posi,
                skin: 'flares',
                closeBtn: 0, //关闭按钮,可通过配置1和2来展示,0关闭
                content: [url, 'no'],
                resize: false,
                scrollbar: false,
                // tipsMore: true, //允许多个tipe
                // content: num,
                success: function (layero, index) {//成功后添加全局点击关闭
                  // console.log(evt.graphic.attributes);
                  $("#layui-layer-iframe" + index).contents().find("#input1").val(setdata);
                  // console.log(layero, index);
                  that.indexs = index;
            //       var isclickD = true
            //         , endx = null
            //         , endy = null;
            //       layero[0].style.position = 'absolute';
                  var isclickD = true
                    , endx = null
                    , endy = null;
                  layero[0].style.position = 'absolute';
            //       downs = document.onmousedown = () => { //鼠标按下事件
            //         // console.log('down');//start
            //         // downs = document.onmousedown = null;
            //         var mx = window.event.clientX//鼠标初始位置
            //           , my = window.event.clientY
            //           , cx = this.offset[1].replace("px", "")//初始位置
            //           , cy = this.offset[0].replace("px", "");
                  downs = document.onmousedown = () => { //鼠标按下事件
                    // console.log('down');//start
                    // downs = document.onmousedown = null;
                    var mx = window.event.clientX//鼠标初始位置
                      , my = window.event.clientY
                      , cx = this.offset[1].replace("px", "")//初始位置
                      , cy = this.offset[0].replace("px", "");
            //         //判断鼠标是否在地图上
            //         // console.log(mx,'+',my);
            //         if (mx > 359 && mx < 1543 && my > 5 && my < 818) {
            //           // console.log('on map')
            //           if (endx != null && endy != null) {
            //             cx = endx;
            //             cy = endy;
            //           }
            //           moves = document.onmousemove = () => {//鼠标移动事件
            //             // console.log('move');//move
            //             // console.log(this.offset)
            //             var ux = window.event.clientX//记录实时位置
            //               , uy = window.event.clientY;
            //             endx = +cx + (ux - mx)// 初始位置+(鼠标初始位置-实时位置)
            //             endy = +cy + (uy - my);
            //             layero[0].style.left = endx + 'px';
            //             layero[0].style.top = endy + 'px';
            //             // console.log(+cx, +cy,'初始位置');
            //             // console.log(mx, my,'鼠标初始位置');
            //             // console.log(ux, uy,'记录实时位置');
            //             // console.log(ux, uy,'最后位置');
            //             isclickD = false;
            //             ups = document.onmouseup = () => {//鼠标抬起事件
            //               // console.log('up');//end
            //               // downs = document.onmousedown = null;
            //               moves = document.onmousemove = null;
            //               ups = document.onmouseup = null;
            //               var timess = setTimeout(() => {
            //                 clearTimeout(timess);
            //                 timess = null;
            //                 isclickD = true;
            //               }, 1);
            //             }
            //           }
            //         }
            //       }
            //       clickD = document.onclick = () => {
            //         if (isclickD) {
            //           parent[0].layer.close(index);
            //           parent[0].layer.close(+index + 1);
            //           // parent[0].layer.closeAll();
            //           // console.log(111111111111)
            //           clickD = document.onclick = null;
            //         }
            //       }
                    //判断鼠标是否在地图上
                    // console.log(mx,'+',my);
                    if (mx > 359 && mx < 1543 && my > 5 && my < 818) {
                      // console.log('on map')
                      if (endx != null && endy != null) {
                        cx = endx;
                        cy = endy;
                      }
                      moves = document.onmousemove = () => {//鼠标移动事件
                        // console.log('move');//move
                        // console.log(this.offset)
                        var ux = window.event.clientX//记录实时位置
                          , uy = window.event.clientY;
                        endx = +cx + (ux - mx)// 初始位置+(鼠标初始位置-实时位置)
                        endy = +cy + (uy - my);
                        layero[0].style.left = endx + 'px';
                        layero[0].style.top = endy + 'px';
                        // console.log(+cx, +cy,'初始位置');
                        // console.log(mx, my,'鼠标初始位置');
                        // console.log(ux, uy,'记录实时位置');
                        // console.log(ux, uy,'最后位置');
                        isclickD = false;
                        ups = document.onmouseup = () => {//鼠标抬起事件
                          // console.log('up');//end
                          // downs = document.onmousedown = null;
                          moves = document.onmousemove = null;
                          ups = document.onmouseup = null;
                          var timess = setTimeout(() => {
                            clearTimeout(timess);
                            timess = null;
                            isclickD = true;
                          }, 1);
                        }
                      }
                    }
                  }
                  clickD = document.onclick = () => {
                    if (isclickD) {
                      parent[0].layer.close(index);
                      parent[0].layer.close(+index + 1);
                      // parent[0].layer.closeAll();
                      // console.log(111111111111)
                      clickD = document.onclick = null;
                    }
                  }
            //       var mouseWheel = that.map.on("mouse-wheel", myMouseWheelHandler);
                  var mouseWheel = that.map.on("mouse-wheel", myMouseWheelHandler);
            //       function myMouseWheelHandler(event) {
            //         // console.log("Mouse wheel value = " + event.value);
            //         parent[0].layer.close(index);
            //         parent[0].layer.close(+index + 1);
            //         mouseWheel.remove();
            //       }
                  function myMouseWheelHandler(event) {
                    // console.log("Mouse wheel value = " + event.value);
                    parent[0].layer.close(index);
                    parent[0].layer.close(+index + 1);
                    mouseWheel.remove();
                  }
            //     },
            //     end: function () { //关闭事件
                },
                end: function () { //关闭事件
            //     }
            //   });
            // that.layuiLayer.open({ //第二个iframe
            //   title: '',
            //   type: 2,
            //   shadeClose: true,
            //   shade: false,
            //   skin: 'demo-class',
            //   id: 'onelyTwo',
            //   maxmin: false, //开启最大化最小化按钮
            //   area: ['360px', '484px'],
            //   // area: 'auto',
            //   offset: 'r',
            //   skin: 'flare',
            //   isOutAnim: false,
            //   closeBtn: 0, //关闭按钮,可通过配置1和2来展示,0关闭
            //   content: ['./popup/html/FlareClusterLayer_v3 copy.html'],
            //   resize: false,
            //   scrollbar: false,
            //   // tipsMore: true, //允许多个tipe
            //   // content: num,
            //   success: function (layero, index) { //成功后添加全局点击关闭
            //     // var z = document.onclick = ()=>{
            //     //   parent[0].layer.close(index);
            //     // //   // parent[0].layer.close(+index + 1);
            //     //   z = null;
            //     // }
            //     //尝试传值
            //     //js对象转json对象
            //     // $("#layui-layer-iframe" + index).contents().find("input").val(JSON.stringify(evt.graphic.attributes));
            //     $("#layui-layer-iframe" + index).contents().find("#sidIput").val(setdata);
            //   },
            // })
            //一个弹窗
                }
              });
            that.layuiLayer.open({ //第二个iframe
              title: '',
              type: 2,
@@ -386,18 +354,54 @@
              // tipsMore: true, //允许多个tipe
              // content: num,
              success: function (layero, index) { //成功后添加全局点击关闭
                // var z = document.onclick = ()=>{
                //   parent[0].layer.close(index);
                // //   // parent[0].layer.close(+index + 1);
                //   z = null;
                // }
                //尝试传值
                //js对象转json对象
                // $("#layui-layer-iframe" + index).contents().find("input").val(JSON.stringify(evt.graphic.attributes));
                $("#layui-layer-iframe" + index).contents().find("#sidIput").val(setdata);
              },
            })
            //一个弹窗
            //     that.layuiLayer.open({ //第二个iframe
            //       title: '',
            //       type: 2,
            //       shadeClose: true,
            //       shade: false,
            //       skin: 'demo-class',
            //       id: 'onelyTwo',
            //       maxmin: false, //开启最大化最小化按钮
            //       area: ['360px', '484px'],
            //       // area: 'auto',
            //       offset: winSize,
            //       skin: 'flare',
            //       isOutAnim: false,
            //       closeBtn: 2, //关闭按钮,可通过配置1和2来展示,0关闭
            //       content: ['./popup/html/FlareClusterLayer_v3 copy.html'],
            //       resize: false,
            //       scrollbar: false,
            //       // tipsMore: true, //允许多个tipe
            //       // content: num,
            //       success: function (layero, index) { //成功后添加全局点击关闭
            //         $("#layui-layer-iframe" + index).contents().find("#sidIput").val(setdata);
            //       },
            //     })
          })
        }
        if (mySelf.onceTimeMethod == null) { //防抖.限制时间内点击次数,否则会造成不能正确销毁前一个弹窗
          var offsetMy = [+evt.screenY - 300 + 'px', +evt.screenX - 172.5 + 'px'];
          var offsetMy = [+evt.screenY - 310 + 'px', +evt.screenX - 168 + 'px'];
          if (und == '控制端') {//控制端弹窗关闭
          var offsetMy = [+window.innerHeight / 2 - 115 + 'px', (+window.innerWidth - 360) / 2 + 257 + 'px'];
          console.log('控制端中浮',offsetMy)
        }
          // console.log(evt.screenY);
          var winSize = [+window.innerHeight / 2 - 242 + 'px', +window.innerWidth - 380 + 'px']
          // console.log(winSize,4454645634536);
          fCard(offsetMy, setdata, winSize);
          fCard(offsetMy,setdata,winSize);
          mySelf.onceTimeMethod = setTimeout(() => {
            mySelf.onceTimeMethod = null;
          }, mySelf.onceTime);