<template>
    <div>
        <el-dialog v-model="show" append-to-body :close-on-click-modal="false" :close-on-press-escape="false" :title="title" width="960px" modal-class="model-dialog-show">
            <div :id="elId"></div>
        </el-dialog>
    </div>
</template>

<script>
import useBimStore from '@/store/modules/bim'
export default {
    data() {
        return {
            show: false,
            title: '',
            row: null,
            bimStore: null,
            sapi_1: null,
            elId: 'gis' + +new Date(),
        }
    },
    mounted() {
        this.bimStore = useBimStore()
        window.xapp = this
    },
    methods: {
        showDialog(row) {
            this.elId = 'gis' + +new Date()
            this.row = row
            this.show = true
            this.title = row.name
            this.$nextTick(() => {
                this.initCesium()
            })
        },
        initCesium() {
            debugger
            var api = new SAPI(
                {
                    serverIP: `//model.jhncidg.com`, //服务ip地址
                    port: 8000, //HTTP端口
                    useHttps: true, //使用Https
                    container: this.elId, //[必须]容器id
                    secretKey:
                        'cbe8c300dfb0280d71bf6546087c6d2fa49260085f53fca8e5bdce7cde8509800e60acd60891a0dfaedaed48706cede62c884a84004218a7c2eb3de18b4f3783258c47f45b34485a2edb350010e2f42cd5b388af45c6b070850288d284cbbbcda2d085ba47169a7d4fc79609ffbef2dc54455448c112333d4b48d4870843cd1a156822f418515a2ad17683749ba4ff5118ae3f686e966fbfdd71fd75e0bbc3738a94867b381ae88ecd6668e8ca6b6d286dce7e5d799b0a175d5afe5554a4332203e774bed8a04535067c9aac0a18108055b1db541f70363b277050951ab91fcbccd8329463d92cd2f81b95abdf8d437c4965454914fcc7b07d28062bc2976948356e76d9d11fd5b479eb391b46cc93e66da10e0ba1fed735c8b1b1f086973f6152b6a2299e3e22c9cc8c33b16ea71cc03013404ec41c18c9cc748e652ce16fe7061c32d550edfda330c1555e0c08e51f698f96b91615d8220acd9cb22f32e9757681487e0680adfbfacb9b5d2ce5a13b664d8466043270f9f3bde6ac6a05cf25ab0ccc0659a290c9669997be7ccc0086c3d61f7cf5f649cb25f0dbad9f7f66e3165cad25065145affac91bea061f4ff485af667dd7ebaf4baeea64611acbe5c74018be5a8b704fcd4f53d18504940411fac91bea061f4ff49a2f853c245297edc3d61f7cf5f649cb0f9b84173857a7b67c27928b58b4a6a65f517a43f106335e8b1d5c423a171723ffa04d0ac4e5c1a1853fcb2bc95ee8056cd5b4826fa55926733ef859a5f169e6afafd0506174e86864d53d967da98ab0b0e08d14be6d452c6c69755ac3a391993370a029761da893cfbf575da87c6b5ca602467b79c6c9532f438aaafb9ec915692f0287a8db979969e5635404d6fdfb753151533a277044afdd825f7197f2896c69755ac3a391993370a029761da893af24d88c02bccfae6cd5b4826fa55926f7722b78090b30b986f9287101582d8841187054ec673ebd2042f9836ea453c3afafd0506174e86800225b7f4102e3585b1923cb186fe0ceee54c6f17ab8555da26ecd334722494fc515b205e9624a4494c772ef4f023a606882e118fa6321c24ddee4821c840fb56aac929d6d0a052d5ff97d71e43811db939f7340826236af6f10316a04bf618d494a26e0fd06f7daa07177989e1680a4cf14829a5847f70377d6c12f1649400fcab44f4ff52989cf129aa6cca660be152a75b8e35648925dbce381b345d9e137c04a02a4c8252625f5625eed58fd34b7be4266e54212e88b23f012bead9abaef9e18aa308f0ecffaf3dda7d7b4efd2e0c4b8de161864620fc1f2af98bde031b29e0865381c96bbc10921b48a068558915ff023d18526f5d399e0893df43db7122415d52565dc982ea24fbd825734dbaefadc6df0f19d925c7f63d343a622134b1c934d130d662447add19064adbbb2fd24a82c0fbfcbc3175fc32761df099156daf4e86455740207eb4e4a5300d9c1a17ffd43703d476c36ef07df2206bd8d232b844ff3c1d7cf7c47ec502183af4e27b644d89a77efad286dee59796b124081510f8a6ea5c1dff9c3d61f7cf5f649cb25f0dbad9f7f66e3e0e7c3406ae4dd4eebc424f09f933d0eb1a881ed05ca8d5c70958237eb5b91d4e574440ea0c9179a582dc966bcfc1f21cf3630a2823a9a2d22bd09a00b213aae3866768ae2f24dde6784fbf292c2cba136689b286e75a81e016aa63061505f57a8c1113b833628e3a18dff8ae8ac8eaa7a4fba6045bc9b4b',
                    openEarth: false, //[可选]开启Gis场景
                    bgColor: 'rgba(135 ,206 ,250,1)', //[可选]bim场景背景色, 传值即为纯色天空盒
                    tintColor: 'rgba(255,255,0,1)', //[可选]osgb单体化颜色
                    sceneTime: ['13:00', '6:00', '18:00'], //[可选]分别为当前时间、日出时间、日落时间
                    cadMode: false, // 是否是Cad图纸预览模式
                },
                () => {
                    console.log('初始化成功') //初始化成功后在进行其他操作，如加载模型等
                }
            )
            console.log('---->', api)
        },
        initCesium2() {
            // const defaults = { ...this.bimStore.defaults }
            let defaults = {
                container: 'cesiumContainer', //[必须]容器id
                showfps: false,
                openterrain: true,
                imageryprovider: 'tianditu_image',
                openearth: false,
                maxspaceerror: 2000,
                loading: false,
                bgcolor: '#87CEFA',
                outlinecolor: '#000000',
                outlineScaleVal: 1.001,
                selectedcolor: '#ff0000',
                sceneMode: 3,
                TwoMapNavigationEnable: false,
                throughwall: true,
                searchbox: false,
                mapbox: true,
                secretkey: window.BIM_CONFIG.secretKey, //token.txt文件里的内容
                editmode: false,
                cadmode: false,
                isRequestWebgl2: true,
                requestRenderMode: true,
                colorBlendMode: 2,
                loadAnimation: false,
                isStrictClip: true,
                isMsaaSamples: true,
                isOpenVR: false,
                language: 'zh-CN',
            }

            defaults.container = this.elId
            defaults.bgcolor = '#c6c9d1'
            defaults.secretkey = window.BIM_CONFIG.secretKey
            this.sapi_1 = new API(defaults)
            this.sapi_1.Model.add(this.row.modelAccessAddress, this.row.lightweightName)
            let mapOptions = {
                imgs: {
                    // 六面图片
                    top: './Engine/Assets/Images/Navigation/bim/top.png',
                    bottom: './Engine/Assets/Images/Navigation/bim/under.png',
                    east: './Engine/Assets/Images/Navigation/bim/east.png',
                    south: './Engine/Assets/Images/Navigation/bim/south.png',
                    west: './Engine/Assets/Images/Navigation/bim/west.png',
                    north: './Engine/Assets/Images/Navigation/bim/north.png',
                },
                offset: {
                    // 屏幕坐标偏移
                    corner: GLENavigationCube.RightTop,
                    x: 25,
                    y: 20,
                },
                cube: {
                    hoverColor: '#7193dc', // 立方导航快鼠标移过显示颜色
                    size: 75, // 导航立方尺寸
                    hotPointSize: 7, // 导航立方棱角热点区域尺寸
                    cubeTextColor: '#4c4c4ccc', // cube 各个面文字颜色
                    cubeStrokeColor: '#374769cc', // cube 各个面边框颜色
                    cubeFillColor: '#374769cc', // cube 各个面填充颜色
                },
                zoomRatios: 1, // 缩放倍率
                show: true, // 是否显示
                showAxes: true, // 是否显示XYZ轴线
            }
            this.sapi_1.Plugin.initNavCube(mapOptions)
            //this.sapi_1.Public.setDisableMouseState(false)
            //this.sapi_1.Public.setIsflipUnderground(false)
        },
    },
}
</script>

<style></style>