suerprisePlus
2024-06-25 c93d4b3af5739f786cfdf20b16b28ec60403f709
src/assets/js/map/modelLayer.js
@@ -1,7 +1,10 @@
import {
  getPublickey,
  getSecurityLogin,
  getListCanview
  getListCanview,
  getmapConfig,
  getQueryEentity,
  getSettingPublickey
} from "../../../api/modelBase.js";
import JSEncrypt from "jsencrypt";
import store from "../../../store/index.js";
@@ -14,35 +17,43 @@
  modelBase: null,
  dbid: null,
  geom: null,
  // 获取Publickey
  layers: null,
  publickey: null,
  init() {
    this.modelBase = config.modelBase;
    getPublickey().then((response) => {
      const password = this.modelBase.password;
      const userId = this.modelBase.userId;
      const publickey = response.data;
      const encrypt = new JSEncrypt();
      encrypt.setPublicKey(publickey);
      let encrypted = encrypt.encrypt(password.substring(0, 50)) + "";
      let submit = {
        userid: userId,
        password: encrypted
      };
      this.setLoginsubmit(submit);
    this.getSettingPublicKey();
    const token = getToken();
    console.log("token", token);
    if (token) {
      this.getModelLayerList();
    } else {
      getPublickey().then((response) => {
        const password = this.modelBase.password;
        const userId = this.modelBase.userId;
        const publickey = response.data;
        const encrypt = new JSEncrypt();
        encrypt.setPublicKey(publickey);
        let encrypted = encrypt.encrypt(password.substring(0, 50)) + "";
        let submit = {
          userid: userId,
          password: encrypted
        };
        this.setLoginsubmit(submit);
      });
    }
  },
  getSettingPublicKey() {
    getSettingPublickey().then((response) => {
      this.publickey = response.data;
    });
  },
  // 获取Token
  setLoginsubmit(res) {
    // const token = getToken();
    // if (token) {
    getSecurityLogin(res).then((response) => {
      const val = response.data.token;
      setToken(val);
      this.getModelLayerList();
    });
    // } else {
    //   this.getModelLayerList( );
    // }
  },
  // 获取列表
  getModelLayerList() {
@@ -56,19 +67,40 @@
      });
      if (obj.length > 0) {
        this.dbid = obj[0].dbid;
        this.getmapConfig();
      }
    });
    this.setLayerQuery();
  },
  getmapConfig() {
    getmapConfig({
      dbid: this.dbid,
      token: getToken()
    }).then((response) => {
      if (response.code != 200) return;
      const layers = response.data.layers;
      this.layers = layers;
      for (var i in layers) {
        if (layers[i].name == "建筑") {
          const url = layers[i].lod_url["3d"][""];
          mapServer.addServer({
            sourceType: "Tileset",
            url: url,
            id: layers[i].id
          });
        }
      }
    });
  },
  setLayerQuery() {
    const token = getToken();
    this.geom = mapConfig.setPointToCrical(120.27, 14.79, null);
    const obj = {
      type: "FeatureCollection",
      totalFeatures: 1086,
      features: [this.geom]
    };
    // const obj = {
    //   type: "FeatureCollection",
    //   totalFeatures: 1086,
    //   features: [this.geom]
    // };
    // earthCtrl.factory.createFeatureLayer({
    //   sourceType: "geojson",
    //   url: obj,
@@ -168,11 +200,11 @@
    //
    a.push([
      // "${id} == '1_b092c0c26de646b984801e29fba37f82'",
      '${id} == 1_b092c0c26de646b984801e29fba37f82',
       'color("purple", 0.5)'
      "${id} == 1_b092c0c26de646b984801e29fba37f82",
      'color("purple", 0.5)'
    ]);
    a.push(["true", "color('#E8F1F2', 0.5)"]);
    console.log(   tileset);
    console.log(tileset);
    tileset.style = new Cesium.Cesium3DTileStyle({
      // color: "vec4(1.0,1.0,1.0, 1.0)", // 红色
      color: {
@@ -180,7 +212,7 @@
          [
            // "${id} == '1_b092c0c26de646b984801e29fba37f82'",
            '${targettype} == "军事目标"',
             'color("purple", 0.5)'
            'color("purple", 0.5)'
          ]
        ]
      }