<template>
    <web-view
        v-if="authtoken"
        :src="dibootUrl">
    </web-view>
</template>

<script>
import webview from './webview'
export default {
    mixins: [webview],
    data() {
        return {
            dibootUrl: '',
            query: {},
        };
    },
    onLoad(query) {
        this.query = query

        this.initData(query)
    },
    watch: {
        authtoken: {
            immediate: false,
            deep: true,
            handler(newVal) {
                this.initData(this.query)
            }
        }
    },
    methods: {
        initData(routeQuery) {
            let protocol = 'https:'
            if (document.location.protocol) {
                protocol = document.location.protocol
            }
            let urlParams = ''
            for (let key in routeQuery) {
                if (key != 'routes') {
                    urlParams += `&${key}=${routeQuery[key]}`
                }
            }
            urlParams += `&token=${this.authtoken}`
            if (process.env.NODE_ENV === 'development') {
                this.dibootUrl = `${protocol}//tq.5000v.com:8035${routeQuery.routes}?${urlParams}`
            } else {
                this.dibootUrl = `${protocol}//${window.location.host}${routeQuery.routes}?${urlParams}`
            }

        },
        getLocation() {

        },
        scanCode() {

        }
    }
}
</script>

<style lang="scss"></style>
