1
mayisheng
2022-08-15 81f54040c2cb65537c6c6e1db8358a39a57dea0d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<template>
    <div id="app" :class="{ cantdoit: cantdoits }">
        <router-view v-if="isRouterActive"></router-view>
    </div>
</template>
 
<script>
import AMapLoader from '@amap/amap-jsapi-loader'
export default {
    name: 'App',
    provide () {
        return { reload: this.reload }
    },
    data () {
        return {
            cantdoits: false,
            isRouterActive: true
        }
    },
    mounted () {
        var transmitData = {}
 
        var url = window.location.href
 
        if (url.indexOf('?') != -1) {
            var arr = url.split('?')
            var brr = arr[1].split('&')
            brr.forEach((item, index) => {
                var a = item.split('=')
                transmitData[a[0]] = decodeURIComponent(a[1])
            })
            try {
                transmitData = JSON.parse(transmitData)
            } catch (error) { }
        }
 
        this.$store.commit('set_urlParameterData', transmitData) // 传入数据
 
        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('/large')
            this.$router.replace('/pcLayout')
        }
    },
    methods: {
        reload () {
            this.isRouterActive = false
            this.$nextTick(() => {
                this.isRouterActive = true
                this.$store.commit('SET_VIEWEREXIST', false)
            })
        },
        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;
}
#app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #2c3e50;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
.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;
}
</style>