jxdnsong
2022-10-25 bf5ba56e8a82f0ef699f2eae413d0dc2c4e4f67d
src/components/mobileWindow/index.vue
@@ -6,17 +6,17 @@
            <span class="mobile_audio" @click="openAudio" v-show="introduce && !video">
                <!-- <i class="el-icon-video-play icon" v-show="!audioState"></i>
                <i class="el-icon-video-pause icon" v-show="audioState"></i>-->
                <img src="/zhjg/img/icon/start-video.png" class="icon" alt v-show="!audioState" />
                <img src="/zhjg/img/icon/close-video.png" class="icon" alt v-show="audioState" />
                <img src="/zhjg/img/icon/start-video.png" class="icon" alt v-show="audioState" />
                <img src="/zhjg/img/icon/close-video.png" class="icon" alt v-show="!audioState" />
                <!-- <div id="bdtts_div_id">
          <audio id="tts_autio_id" autoplay="autoplay">
            <source
              id="tts_source_id"
              src="https://tts.baidu.com/text2audio?lan=zh&amp;ie=UTF-8&amp;spd=5&amp;per=1&amp;text=请输入文字"
              type="audio/mpeg"
            />
            <embed id="tts_embed_id" height="0" width="0" src="" />
          </audio>
                    <audio id="tts_autio_id" autoplay="autoplay">
                        <source
                        id="tts_source_id"
                        src="https://tts.baidu.com/text2audio?lan=zh&amp;ie=UTF-8&amp;spd=5&amp;per=1&amp;text=请输入文字"
                        type="audio/mpeg"
                        />
                        <embed id="tts_embed_id" height="0" width="0" src="" />
                    </audio>
                </div>-->
            </span>
        </div>
@@ -83,55 +83,59 @@
</template>
<script>
import { mapGetters } from "vuex"
import {
    Message
} from 'element-ui'
import { mapGetters } from 'vuex'
export default {
    name: "mobileWindow",
    name: 'mobileWindow',
    computed: {
        ...mapGetters([
            "MobileWindowsHide",
            "query",
            "MobileWindowChangeData",
            "audioState",
            'MobileWindowsHide',
            'query',
            'MobileWindowChangeData',
            'audioState'
            // "areaLayerSelect",
        ]),
        ])
    },
    watch: {
        MobileWindowChangeData () {
            this.$store.dispatch("MSET_GETAUDIOBEGIN", "notOpen")
            this.$store.dispatch('MSET_GETAUDIOBEGIN', 'notOpen')
            this.quzheD = false
            //数据更改
            // 数据更改
            //   this.fullscreenLoading = true;
            if (!this.MobileWindowsHide) {
                this.video = "" //清除视频
                this.seebut = [] //清除按钮
                let queryData = this.query.query
                // console.log(queryData, 789);
                this.video = '' // 清除视频
                this.seebut = [] // 清除按钮
                const queryData = this.query.query
                this.title = queryData.name
                //判断是否显示操作按钮
                // 判断是否显示操作按钮
                if (queryData.seebut) {
                    this.seebut = queryData.seebut
                    if (queryData.from == "活动") {
                    if (queryData.from == '活动') {
                        this.seebut = []
                        this.seebut.push({
                            name: "图集",
                            name: '图集'
                        })
                        this.seebut.push({
                            name: "显示活动",
                            name: '显示活动'
                        })
                        if (queryData.notAddGoOn == "notAddGoOn") {
                        if (queryData.notAddGoOn == 'notAddGoOn') {
                            this.seebut.push({
                                name: "去这",
                                name: '去这'
                            })
                        }
                    }
                    for (let k in this.seebut) {
                        if (this.seebut[k].name == "定位") {
                    for (const k in this.seebut) {
                        if (this.seebut[k].name == '定位') {
                            this.seebut.splice(k, k + 1)
                        }
                    }
                    if (queryData.notAddGoOn != "notAddGoOn") {
                    if (queryData.notAddGoOn != 'notAddGoOn') {
                        this.seebut.push({
                            name: "去这",
                            name: '去这'
                        })
                    }
                } else {
@@ -140,227 +144,308 @@
                        //   name: "实景",
                        // },
                        {
                            name: "图集",
                            name: '图集'
                        },
                        {
                            name: "去这",
                        },
                            name: '去这'
                        }
                    ]
                }
                //图集
                // 图集
                if (queryData.bgImg) {
                    this.srcList = queryData.bgImg.split(",")
                    this.srcList = queryData.bgImg.split(',')
                    this.url = this.srcList[0]
                } else {
                    this.seebut = this.seebut.filter((res) => {
                        return res.name != "图集"
                        return res.name != '图集'
                    })
                }
                //视频
                // 视频
                if (queryData.video) {
                    if (queryData.from == "labels") {
                    if (queryData.from == 'labels') {
                        this.seebut = []
                        this.video = queryData.video
                    } else {
                        this.seebut.push({ name: "视频" })
                        this.seebut.push({ name: '视频' })
                    }
                }
                //全景
                // 全景
                if (queryData.panoramaurl) {
                    this.panoramaurl = queryData.panoramaurl
                    this.seebut = this.seebut.filter((res) => {
                        return res.name != "实景"
                        return res.name != '实景'
                    })
                    this.seebut.splice(0, 0, { name: "实景" })
                    this.seebut.splice(0, 0, { name: '实景' })
                } else {
                    this.panoramaurl = ""
                    this.panoramaurl = ''
                    this.seebut = this.seebut.filter((res) => {
                        return res.name != "实景"
                        return res.name != '实景'
                    })
                }
                //中心内容
                // 中心内容
                this.center = []
                for (let k in queryData) {
                    for (let n in this.getCenter) {
                for (const k in queryData) {
                    for (const n in this.getCenter) {
                        if (
                            k == this.getCenter[n].name &&
                            queryData[k] &&
                            queryData.from != "活动" &&
                            this.getCenter[n].value == "地址"
                            queryData.from != '活动' &&
                            this.getCenter[n].value == '地址'
                        ) {
                            this.center.push({
                                name: this.getCenter[n].value,
                                value: queryData[k] ? queryData[k] : "暂无",
                                value: queryData[k] ? queryData[k] : '暂无'
                            })
                        }
                        if (k == "introduce") {
                        if (k == 'introduce') {
                            this.introduce = queryData[k]
                            if (this.introduce) {
                                setTimeout(() => {
                                    let Str = document.querySelector(
                                        ".mobileBig-center-introduce"
                                    const Str = document.querySelector(
                                        '.mobileBig-center-introduce'
                                    ).innerText
                                    this.$store.dispatch("MSET_GETAUDIO", Str) //加入语音
                                    this.$store.dispatch('MSET_GETAUDIO', Str) // 加入语音
                                }, 20)
                            }
                        }
                    }
                }
            }
        },
        }
    },
    data () {
        return {
            // 导航是否开起
            navigationFlag: false,
            getCenter: [
                {
                    name: "websiteUrl",
                    value: "网址",
                    name: 'websiteUrl',
                    value: '网址'
                },
                {
                    name: "telePhone",
                    value: "电话",
                    name: 'telePhone',
                    value: '电话'
                },
                {
                    name: "address",
                    value: "地址",
                },
                    name: 'address',
                    value: '地址'
                }
                // {
                //   name: "introduce",
                //   value: "详情",
                // },
            ],
            introduce: "暂无详情数据",
            title: "",
            introduce: '暂无详情数据',
            title: '',
            fullscreenLoading: false,
            url: "",
            video: "",
            positions: "",
            url: '',
            video: '',
            positions: '',
            srcList: [],
            seebut: [],
            center: [],
            panoramaurl: "",
            quzheD: false, //是否点击了去这,并不能再按,以及不应用路线导航
            panoramaurl: '',
            quzheD: false // 是否点击了去这,并不能再按,以及不应用路线导航
        }
    },
    mounted () {
        this.$EventBus.$on('clearTimoutTime', () => {
            if (this.navigationFlag == true) {
                window.geolocation.clearWatch()
                this.$store.dispatch('removeLabelLayerIconMobelUse')
            }
        })
    },
    methods: {
        //按钮点击事件
        // 按钮点击事件
        openOnce (val) {
            let that = this
            const that = this
            const query = this.query.query
            that.routerS = []
            let once = true
            let query = this.query.query
            // console.log(query);
            if (val == "去这") {
            if (val == '去这') {
                if (that.quzheD) {
                    console.log("不可点击")
                    console.log('不可点击')
                    return
                }
                that.navigationFlag = false
                that.quzheD = true
                that.$EventBus.$emit('clearTimoutTime')
                // return;
                //定位
                // 定位
                // console.log(this.query.query);
                // that.$store.commit("set_endPosition", this.query.query.lntLat);
                let doit = (now) => {
                    if (now[0] == "失败") {
                        that.quzheD = false
                        return
                    }
                    let ints = {
                        start: [+now[0], +now[1]],
                        end: [+query.lntLat[0], +query.lntLat[1], 360],
                        // start: [+query.lntLat[0], +query.lntLat[1], 360],
                        // end: [114.031946, 27.621475],
                        type: "driving",
                        fn: function (datas) {
                            //获取回调路径
                            that.routerS.push(datas)
                            that.quzheD = false
                            if (once) {
                                once = false
                                //加载第一条线路
                                that.$store.commit("set_choiceRouterS", 0)
                                that.$store.dispatch("MSET_DRAWALINELAYER", [datas.Str, query])
                                that.$store.commit("cameraSetView", ints.start)
                            }
                        },
                    }
                    that.$store.dispatch("MSET_GOTOWHERE", ints)
                }
                that.$store.commit("GET_NOWPOSITION", (res) => {
                    console.log(res)
                    doit(res)
                })
            } else if (val == "实景") {
                console.log(this.panoramaurl, query)
                this.$store.commit("MSET_OPENMOBILEPANORAMA", this.panoramaurl)
                that.getCurrentLocation()
            } else if (val == '实景') {
                this.$store.commit('MSET_OPENMOBILEPANORAMA', this.panoramaurl)
                return
                this.$store.commit(
                    "MSET_OPENMOBILEPANORAMA",
                    "https://www.kuleiman.com/110487/index.html?m=1"
                    'MSET_OPENMOBILEPANORAMA',
                    'https://www.kuleiman.com/110487/index.html?m=1'
                )
            } else if (val == "图集") {
                let imgsDom = document.getElementById("mobileBigImgs")
            } else if (val == '图集') {
                const imgsDom = document.getElementById('mobileBigImgs')
                if (imgsDom) {
                    imgsDom.click()
                }
            } else if (val == "视频") {
                this.seebut[this.seebut.length - 1].name = "返回"
            } else if (val == '视频') {
                this.seebut[this.seebut.length - 1].name = '返回'
                this.video = this.query.query.video
            } else if (val == "返回") {
                this.seebut[this.seebut.length - 1].name = "视频"
                this.video = ""
            } else if (val == "显示活动") {
                let addressOur = this.changeData(query, "addressname", "address")
                let lxOur = this.changeData(query, "lxname", "lx")
                console.log(addressOur, lxOur)
                that.$store.dispatch("MSET_DRAWALINELAYERMANY", [
            } else if (val == '返回') {
                this.seebut[this.seebut.length - 1].name = '视频'
                this.video = ''
            } else if (val == '显示活动') {
                const addressOur = this.changeData(query, 'addressname', 'address')
                const lxOur = this.changeData(query, 'lxname', 'lx')
                that.$store.dispatch('MSET_DRAWALINELAYERMANY', [
                    lxOur,
                    addressOur,
                    query,
                    query
                ])
            }
        },
        //修改数据
        // 修改数据
        changeData (data, name, value) {
            let arr = []
            for (let k in data[name]) {
            const arr = []
            for (const k in data[name]) {
                arr.push({
                    name: data[name][k],
                    value:
                        name == "lxname"
                        name == 'lxname'
                            ? data[value][k]
                                .split("(")[1]
                                .split(")")[0]
                                .split(",")
                                .join(";")
                                .split(" ")
                                .join(",")
                            : [+data[value][k].split(",")[0], +data[value][k].split(",")[1]],
                                .split('(')[1]
                                .split(')')[0]
                                .split(',')
                                .join(';')
                                .split(' ')
                                .join(',')
                            : [+data[value][k].split(',')[0], +data[value][k].split(',')[1]]
                })
            }
            return arr
        },
        closeWindow () {
            if (!this.MobileWindowsHide) {
                let that = this
                this.$store.dispatch("closeMobileWindowsDom") //关闭随地图弹窗
                const that = this
                this.$store.dispatch('closeMobileWindowsDom') // 关闭随地图弹窗
                if (window.select.overlay != undefined) {
                    window.select.overlay.setStyle({
                        material: window.select.color,
                        outline: false,
                        outline: false
                    })
                    that.$store.commit("mset_changeSelect", [undefined, undefined])
                    that.$store.commit('mset_changeSelect', [undefined, undefined])
                }
            }
        },
        openAudio () {
            if (this.introduce) {
                this.$store.dispatch("MSET_GETAUDIOBEGIN")
                this.$store.dispatch('MSET_GETAUDIOBEGIN')
            }
        },
    },
};
        doit (now) {
            console.log(now)
            const that = this
            const query = this.query.query
            if (now[0] == '失败') {
                that.quzheD = false
                return
            }
            const ints = {
                start: [now[0], now[1]],
                end: [query.lntLat[0], query.lntLat[1], 360],
                // start: [+query.lntLat[0], +query.lntLat[1], 360],
                // end: [114.031946, 27.621475],
                type: 'driving',
                fn: function (datas) {
                    // 获取回调路径
                    that.routerS.push(datas)
                    that.quzheD = false
                    // 加载第一条线路
                    // that.$store.commit('set_choiceRouterS', 0)
                    that.$store.dispatch('MSET_DRAWALINELAYER', datas.Str)
                    // that.$store.commit('cameraSetView', ints.start)
                }
            }
            that.$store.dispatch('MSET_GOTOWHERE', ints)
        },
        getCurrentLocation (flag = true) {
            const that = this
            window.geolocation.watchPosition(that.showPosition)
            window.geolocation.getLocation(that.showPosition, that.showErrow, {
                timeout: 8000
            })
        },
        showPosition (result) {
            const that = this
            const position = global.DC.CoordTransform.GCJ02ToWGS84(result.lng, result.lat)
            const data = {
                name: '我的位置',
                jd: position[0],
                wd: position[1]
            }
            that.$store.dispatch('addLabelLayerIconMobelUse', {
                data: data,
                clear: true,
                mviewer: global.viewer
            })
            if (that.navigationFlag == true) return
            if (position[0] > 115.78815057 && position[0] < 115.80346610 && position[1] > 28.63771847 && position[1] < 28.64981682) {
                that.$store.dispatch('pcMoveView', {
                    jd: position[0],
                    wd: position[1],
                    viewer: global.viewer
                })
                that.$store.dispatch('addLabelLayerIconMobelUse', {
                    data: data,
                    clear: true,
                    mviewer: global.viewer
                })
                that.doit([position[0], position[1]])
                that.navigationFlag = true
            } else {
                Message({
                    message: '您当前位置超出学校范围',
                    type: 'warning',
                    duration: 2000
                })
                that.doit(['失败'])
                that.$EventBus.$emit('clearTimoutTime')
            }
        },
        showErrow (result) {
            if (result.code == 1) {
                confirm('您拒绝了定位功能')
            } else if (result.code == 3 || result.code == 5) {
                confirm('请求超时')
            }
            this.$EventBus.$emit('clearTimoutTime')
        }
    }
}
</script>
<style lang="scss">