shuishen
2022-03-07 c9570001ad913c37e161618c99ce2f194298ae3a
src/App.vue
@@ -1,169 +1,168 @@
<template>
  <div id="app" :class="{ cantdoit: cantdoits }">
    <router-view></router-view>
  </div>
    <div id="app" :class="{ cantdoit: cantdoits }">
        <router-view></router-view>
    </div>
</template>
<script>
import AMapLoader from "@amap/amap-jsapi-loader";
import AMapLoader from '@amap/amap-jsapi-loader'
export default {
  name: "App",
  data() {
    return {
      //   consoles: 1,
      //   consoles1: 1,
      cantdoits: false,
    };
  },
  mounted() {
    let that = this;
    // console.log(frames, 789456);
    // setInterval(function () {
    //   check();
    // }, 4000);
    // var check = function () {
    //   function doCheck(a) {
    //     if (("" + a / a)["length"] !== 1 || a % 20 === 0) {
    //       //   (function () {}["constructor"]("debugger")());
    //       console.log("已打开控制台1");
    //       that.consoles++;
    //       return;
    //     } else {
    //       //   (function () {}["constructor"]("debugger")());
    //       //   console.log("已打开控制台2");
    //       //   return;
    //       that.consoles++;
    //     }
    //     doCheck(++a);
    //   }
    //   try {
    //     doCheck(0);
    //   } catch (err) {}
    // };
    // check();
    // console.log(this.getQueryString("data"), "window.location");
    // var reg = new RegExp("(^|&)" + "data" + "=([^&]*)(&|$)");
    let data = this.getQueryString("data");
    // console.log(data);
    try {
      data = JSON.parse(data);
    } catch (error) {}
    this.$store.commit("set_urlParameterData", data); //传入数据
    let d = {
      methods: "goto",
      jd: 125.11111,
      wd: 25.555555,
    };
    // console.log(
    //   "http://192.168.0.222:8080/#/mobileLayout/default?data=" +
    //     JSON.stringify(d)
    // );
    if (this._isMobile()) {
      this.cantdoits = true;
      // 手机端
      this.$router.replace("/mobileLayout");
      AMapLoader.load({
        key: "9c4b1a0ce88821775605e726073c52b5", // 申请好的Web端开发者Key,首次调用 load 时必填
        version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
        plugins: [], //插件列表
      })
        .then((AMap) => {
          console.log(AMap);
          window.AMap = AMap;
          // that.map = new AMap.Map("mymap", {
          //   center: [115.84414205551147, 28.678983439095823],
          //   zoom: 14,
          // });
          // this.map.on('touchmove', (e) => {
          //     console.log(e)
          // })
          // that.getLocationInfor(AMap, 115.84414205551147, 28.678983439095823);
          // that.map.on("mapmove", () => {
          //   that.mouseMoveFlag = false;
          //   that.mouseMoveFlag = true;
          //   var currentCenter = that.map.getCenter();
          //   if (that.setime) {
          //     clearTimeout(that.setime);
          //   }
          //   that.setime = setTimeout(() => {
          //     that.getLocationInfor(AMap, currentCenter.lng, currentCenter.lat);
          //     clearTimeout(that.setime);
          //     that.setime = null;
          //   }, 200);
          // });
          // this.map.on('mousemove', (e) => {
          //     console.log(e)
          // })
        })
        .catch((e) => {
          console.log(e);
        });
    } else {
      // pc端
      this.$router.replace("/pcLayout");
    }
  },
  methods: {
    getQueryString(name) {
      let inlength =
        window.location.href.indexOf("?" + name + "=") + name.length + 2;
      // console.log(inlength);
      // console.log(window.location.href);
      var r = window.location.href.slice(inlength);
      if (r != null) return decodeURIComponent(r);
      return null;
    },
    getQueryVariable(variable) {
      var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
          return pair[1];
    name: 'App',
    data () {
        return {
            //   consoles: 1,
            //   consoles1: 1,
            cantdoits: false
        }
      }
      return false;
    },
    _isMobile() {
      const flag = navigator.userAgent.match(
        /(phone|pad|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows phone)/i
      );
      return flag;
    mounted () {
        const that = this
        // console.log(frames, 789456);
        // setInterval(function () {
        //   check();
        // }, 4000);
        // var check = function () {
        //   function doCheck(a) {
        //     if (("" + a / a)["length"] !== 1 || a % 20 === 0) {
        //       //   (function () {}["constructor"]("debugger")());
        //       console.log("已打开控制台1");
        //       that.consoles++;
        //       return;
        //     } else {
        //       //   (function () {}["constructor"]("debugger")());
        //       //   console.log("已打开控制台2");
        //       //   return;
        //       that.consoles++;
        //     }
        //     doCheck(++a);
        //   }
        //   try {
        //     doCheck(0);
        //   } catch (err) {}
        // };
        // check();
        // console.log(this.getQueryString("data"), "window.location");
        // var reg = new RegExp("(^|&)" + "data" + "=([^&]*)(&|$)");
        let data = this.getQueryString('data')
        // console.log(data);
        try {
            data = JSON.parse(data)
        } catch (error) { }
        this.$store.commit('set_urlParameterData', data) // 传入数据
        const d = {
            methods: 'goto',
            jd: 125.11111,
            wd: 25.555555
        }
        // console.log(
        //   "http://192.168.0.222:8080/#/mobileLayout/default?data=" +
        //     JSON.stringify(d)
        // );
        if (this._isMobile()) {
            this.cantdoits = true
            // 手机端
            this.$router.replace('/mobileLayout')
            AMapLoader.load({
                key: '9c4b1a0ce88821775605e726073c52b5', // 申请好的Web端开发者Key,首次调用 load 时必填
                version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
                plugins: [] // 插件列表
            })
                .then((AMap) => {
                    window.AMap = AMap
                    // that.map = new AMap.Map("mymap", {
                    //   center: [115.84414205551147, 28.678983439095823],
                    //   zoom: 14,
                    // });
                    // this.map.on('touchmove', (e) => {
                    //     console.log(e)
                    // })
                    // that.getLocationInfor(AMap, 115.84414205551147, 28.678983439095823);
                    // that.map.on("mapmove", () => {
                    //   that.mouseMoveFlag = false;
                    //   that.mouseMoveFlag = true;
                    //   var currentCenter = that.map.getCenter();
                    //   if (that.setime) {
                    //     clearTimeout(that.setime);
                    //   }
                    //   that.setime = setTimeout(() => {
                    //     that.getLocationInfor(AMap, currentCenter.lng, currentCenter.lat);
                    //     clearTimeout(that.setime);
                    //     that.setime = null;
                    //   }, 200);
                    // });
                    // this.map.on('mousemove', (e) => {
                    //     console.log(e)
                    // })
                })
                .catch((e) => {
                    console.log(e)
                })
        } else {
            // pc端
            this.$router.replace('/pcLayout')
        }
    },
  },
};
    methods: {
        getQueryString (name) {
            const inlength =
                window.location.href.indexOf('?' + name + '=') + name.length + 2
            // console.log(inlength);
            // console.log(window.location.href);
            var r = window.location.href.slice(inlength)
            if (r != null) return decodeURIComponent(r)
            return null
        },
        getQueryVariable (variable) {
            var query = window.location.search.substring(1)
            var vars = query.split('&')
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split('=')
                if (pair[0] == variable) {
                    return pair[1]
                }
            }
            return false
        },
        _isMobile () {
            const flag = navigator.userAgent.match(
                /(phone|pad|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows phone)/i
            )
            return flag
        }
    }
}
</script>
<style>
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  width: 100%;
  height: 100%;
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #2c3e50;
    width: 100%;
    height: 100%;
}
.cantdoit * {
  -webkit-touch-callout: none !important; /*系统默认菜单被禁用*/
  -webkit-user-select: none !important; /*webkit浏览器*/
  -khtml-user-select: none !important; /*早期浏览器*/
  -moz-user-select: none !important; /*火狐*/
  -ms-user-select: none !important; /*IE10*/
  user-select: none !important;
    -webkit-touch-callout: none !important; /*系统默认菜单被禁用*/
    -webkit-user-select: none !important; /*webkit浏览器*/
    -khtml-user-select: none !important; /*早期浏览器*/
    -moz-user-select: none !important; /*火狐*/
    -ms-user-select: none !important; /*IE10*/
    user-select: none !important;
}
</style>