viewer.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. <template>
  2. <div>
  3. <i class="cesiumbtn" :class="store.state.viewer_flag ? 'el-icon-aim' : 'el-icon-rank'" :title="isbig ? '缩小' : '放大'"
  4. @click="bigViewerChange"></i>
  5. <div v-show="store.state.viewer_flag" class="viewer">
  6. <div class="bg">
  7. <div class="bg_left"></div>
  8. <div class="bg_right"></div>
  9. <div class="bg_bottom"></div>
  10. </div>
  11. <datePicker @dateChange="dateChange"></datePicker>
  12. <ser-center></ser-center>
  13. <GKZB ref="gkzb_ref" />
  14. <BJXM />
  15. <TDSC />
  16. <HYSY ref="hysy_ref" />
  17. <TDSY />
  18. <GDBH ref="gdbh_ref" />
  19. <STXF ref="stxf_ref" />
  20. <WPJG ref="wpjg_ref" />
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  26. import serCenter from './cockpitNew1/serCenter';
  27. import GKZB from './cockpitNew1/gkzb';
  28. import TDSC from './cockpitNew1/tdsc';
  29. import HYSY from './cockpitNew1/hysy';
  30. import TDSY from './cockpitNew1/tdsy';
  31. import BJXM from './cockpitNew1/bjxm';
  32. import GDBH from './cockpitNew1/gdbh';
  33. import STXF from './cockpitNew1/stxf';
  34. import WPJG from './cockpitNew1/wpjg';
  35. import datePicker from './cockpitNew1/datePicker.vue';
  36. import xzqh from "../../static/data/460200_full.json";
  37. import hyqy from "../../static/data/460200_hyqy.json";
  38. import SerCenter from './cockpitNew1/serCenter.vue';
  39. import { cockpitInfo } from '@/api/cockpit'
  40. export default {
  41. components: { serCenter, GKZB, BJXM, TDSC, HYSY, TDSY, GDBH, STXF, WPJG, datePicker, SerCenter },
  42. data() {
  43. return {
  44. params: {
  45. beginTime: '',
  46. endTime: '',
  47. id: 4602,
  48. },
  49. flag: true,
  50. xzqh_color_click: "rgba(46, 177, 251, 0.6)",
  51. xzqh_color: "rgba(10, 95, 152, 0.5)",
  52. };
  53. },
  54. //监听属性 类似于data概念
  55. computed: {},
  56. //监控data中的数据变化
  57. watch: {},
  58. //方法集合
  59. methods: {
  60. bigViewerChange() {
  61. store.setViewerFlagb(!store.state.viewer_flag);
  62. store.setToolBarShow(!store.state.viewer_flag);
  63. // store.setToolBarShow(true);
  64. },
  65. switch() {
  66. this.flag = !this.flag;
  67. },
  68. setDatas() {
  69. this.$refs.gdbh_ref.setData({ id: this.params.id });
  70. this.$refs.stxf_ref.setData({ id: this.params.id });
  71. this.$refs.wpjg_ref.setData(this.params);
  72. },
  73. dateChange(date) {
  74. this.params.beginTime = date[0]
  75. this.params.endTime = date[1]
  76. this.setDatas()
  77. },
  78. async hysyq(address) {
  79. // 选中xzqh查询
  80. let obj = {
  81. beginTime: store.state.cockpit_date[0],
  82. endTime: store.state.cockpit_date[1],
  83. jscType: 'jsc_hysyq_ztsh',
  84. id: address
  85. };
  86. let data = await cockpitInfo(obj);
  87. let obg_text = {
  88. xzqhdm_number: data.data[0].xzqhdm_number,
  89. zhmj: data.data[0].zhmj == undefined ? 0 : data.data[0].zhmj,
  90. }
  91. obg_text.zhmj == null ? 0 : obg_text.zhmj;
  92. store.setCockpitHysyText(obg_text);
  93. // 图表数据
  94. let obj_echart = {
  95. beginTime: store.state.cockpit_date[0],
  96. endTime: store.state.cockpit_date[1],
  97. jscType: 'jsc_hysyq_yelx',
  98. id: address
  99. };
  100. let data_echart = await cockpitInfo(obj_echart);
  101. let obg_echart = {
  102. x: data_echart.data.map(item => item.yhlx_name),
  103. bar: data_echart.data.map(item => item.zhmj)
  104. }
  105. obg_echart.x.length == 0 ? obg_echart.x = ['渔业基础设施用海', '开放式养殖用海', '旅游基础设施用海', '浴场用海',
  106. '游乐场用海'] : obg_echart.x = obg_echart.x;
  107. obg_echart.bar.length == 0 ? obg_echart.bar = [0, 0, 0, 0, 0,] : obg_echart.bar = obg_echart.bar;
  108. store.setCockpitHysyEchart(obg_echart);
  109. this.$refs.hysy_ref["getRenKou"]();
  110. // getRenKou();
  111. },
  112. hysyq_xzqh() {
  113. const that = this;
  114. that.$refs.hysy_ref["label_data"]();
  115. that.$refs.hysy_ref["echart_data"]();
  116. },
  117. async gkzb_xzqh(address) {
  118. let obj = {
  119. // beginTime: store.state.cockpit_date[0],
  120. // endTime: store.state.cockpit_date[1],
  121. jscType: 'jsc_gkzb_ztgu_stbh',
  122. id: address
  123. };
  124. let data = await cockpitInfo(obj);
  125. let obj_yjjbntmj = {
  126. jscType: 'jsc_gdbh_ztgh_nt',
  127. id: address
  128. };
  129. let obj_yjjbntmj_data = await cockpitInfo(obj_yjjbntmj);
  130. // 永久基本农田保护面积
  131. // that.yjjbntmj = obj_yjjbntmj_data.data[0].yjjbntmj;
  132. let obj_kfbjmj = {
  133. jscType: 'jsc_gkzb_ztgh_kfbj',
  134. id: address
  135. };
  136. let obj_kfbjmj_data = await cockpitInfo(obj_kfbjmj);
  137. // // 城市开发边界
  138. // that.kfbjmj = obj_kfbjmj_data.data[0].kfbjmj;
  139. // // 覆盖城镇开发边界
  140. // that.bfb = obj_kfbjmj_data.data[0].bfb * 100;
  141. store.setCockpitGkzb({
  142. mj: data.data[0].mj,// 生态保护红线面积
  143. ly_mj: data.data[0].ly_mj,// 路域生态保护红线
  144. hy_mj: data.data[0].hy_mj,//近海岸面积
  145. yjjbntmj: obj_yjjbntmj_data.data[0].yjjbntmj,// 永久基本农田保护面积
  146. kfbjmj: obj_kfbjmj_data.data[0].kfbjmj,// 城市开发边界
  147. bfb: obj_kfbjmj_data.data[0].bfb * 100,// 覆盖城镇开发边界
  148. ghdkmj: obj_kfbjmj_data.data[0].ghdkmj//已入库管控范围
  149. });
  150. },
  151. async gkzb() {
  152. const that = this;
  153. that.$refs.gkzb_ref["initData"]();
  154. },
  155. async pick_xzqh() {
  156. const that = this;
  157. const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
  158. handler.setInputAction(async event => {
  159. let pickObj = viewer.scene.pick(event.position);
  160. var position = viewer.scene.pickPosition(event.position);
  161. if (!position)//点击到地球之外
  162. return false;
  163. var cartographic = Cesium.Cartographic.fromCartesian(position);
  164. let longitude = Cesium.Math.toDegrees(cartographic.longitude);
  165. let latitude = Cesium.Math.toDegrees(cartographic.latitude);
  166. let height = cartographic.height;
  167. let heading = viewer.scene.camera.heading;
  168. let pitch = viewer.scene.camera.pitch;
  169. // that.addSceneFun()
  170. // console.log(longitude, latitude, height);
  171. // if (!pickObj)//未获取实体
  172. // return false;
  173. if (!position) {
  174. position = Cesium.Cartesian3.fromDegrees(0, 0, 0);
  175. }
  176. if (Cesium.defined(pickObj)) {
  177. if (pickObj.id && pickObj.id instanceof Cesium.Entity) {//点击entity
  178. if (pickObj.id.properties.hasProperty('name') && pickObj.id.properties.name.getValue() != "海洋区域") {
  179. const name = pickObj.id.properties.name.getValue();
  180. const address = pickObj.id.properties.adcode.getValue();
  181. const center = pickObj.id.properties.centroid.getValue();
  182. store.state.regional_information = {
  183. id: address,
  184. name: name,
  185. }
  186. // pickObj.id.polygon._material.color = Cesium.Color.fromCssColorString(that.xzqh_color_click);
  187. // pickObj.id.polygon.extrudedHeight = 850;
  188. viewer.entities.values.forEach((res) => {
  189. // 恢复其他状态
  190. if (res.properties.name._value != name) {
  191. res.polygon._material.color = Cesium.Color.fromCssColorString(that.xzqh_color)
  192. // res.polygon.extrudedHeight = 450;
  193. // 选中状态
  194. } else {
  195. res.polygon._material.color = Cesium.Color.fromCssColorString(that.xzqh_color_click)
  196. // res.polygon.extrudedHeight = 850;
  197. }
  198. })
  199. that.params.id = address
  200. that.setDatas()
  201. // 驾驶舱海域使用权
  202. that.hysyq(address);
  203. // 驾驶舱土地收储
  204. that.tdsc_xzqh(address);
  205. // 管控指标
  206. that.gkzb_xzqh(address);
  207. } else {
  208. }
  209. }
  210. } else {
  211. // 暂时点击周围数据显示三亚市
  212. // 清除所有xzqh状态
  213. viewer.entities.values.forEach((res) => {
  214. // console.log(res.properties.name._value, "其他的");
  215. // console.log(res);
  216. res.polygon._material.color = Cesium.Color.fromCssColorString(that.xzqh_color)
  217. // res.polygon.extrudedHeight = 450;
  218. })
  219. // 海域使用
  220. that.hysyq_xzqh();
  221. // 土地收储
  222. that.tdsc();
  223. // 管控指标
  224. that.gkzb();
  225. }
  226. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  227. },
  228. tdsc() {
  229. const that = this;
  230. that.store.setCockpitTdsc(true);
  231. },
  232. tdsc_xzqh() {
  233. const that = this;
  234. that.store.setCockpitTdsc(false);
  235. },
  236. colorFun(color) {
  237. const fs = `czm_material czm_getMaterial(czm_materialInput materialInput)
  238. {
  239. czm_material material = czm_getDefaultMaterial(materialInput);
  240. vec2 st = materialInput.st;
  241. float dis = distance(st,vec2(0.5));
  242. material.diffuse = color.rgb;
  243. material.alpha = clamp( dis * 2.0, 0.1, 0.5);
  244. return material;
  245. }
  246. `
  247. const material = new Cesium.Material({
  248. fabric: {
  249. uniforms: {
  250. color: color
  251. },
  252. source: fs,
  253. }
  254. })
  255. const aper = new Cesium.MaterialAppearance({
  256. material,
  257. source: fs,
  258. })
  259. return aper;
  260. },
  261. init_xzqh() {
  262. const that = this;
  263. xzqh.features.forEach((res) => {
  264. let obj = {
  265. 'type': "cockpit",
  266. 'name': res.properties.name,
  267. 'centroid': res.properties.centroid,
  268. 'adcode': res.properties.adcode,
  269. }
  270. res.geometry.coordinates.forEach((item) => {
  271. const twoDArray = item[0];
  272. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  273. viewer.entities.add({
  274. position: Cesium.Cartesian3.fromDegrees(obj.centroid[0], res.properties.centroid[1], 5000),
  275. text: obj.name,
  276. label: {
  277. scale: 1.5,
  278. font: "bolder 16px sans-serif",
  279. style: Cesium.LabelStyle.FILL_AND_OUTLINE,
  280. text: res.properties.name,//图标名称
  281. fillColor: Cesium.Color.fromCssColorString("#ffffff"),
  282. pixelOffset: new Cesium.Cartesian2(5, -15),
  283. zIndex: 3,
  284. // 设置远近裁条件
  285. distanceDisplayCondition: new Cesium.DistanceDisplayCondition(20000, 9999999999.0),
  286. },
  287. billboard: {
  288. // 图像地址,URI或Canvas的属性
  289. image: "./static/images/overview/htq-f.png",
  290. height: 60,
  291. // 宽度(以像素为单位)
  292. width: 150,
  293. // 相对于坐标的垂直位置
  294. // verticalOrigin: Cesium.VerticalOrigin.CENTER,
  295. // // 相对于坐标的水平位置
  296. // horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  297. scale: 1.0,
  298. zIndex: 2,
  299. // 设置远近裁条件
  300. distanceDisplayCondition: new Cesium.DistanceDisplayCondition(20000, 9999999999.0),
  301. show: true
  302. },
  303. properties: obj,
  304. polygon: {
  305. zIndex: 1,
  306. hierarchy: {
  307. positions: Cesium.Cartesian3.fromDegreesArray(oneDArray),
  308. },
  309. // outline: false,
  310. material: Cesium.Color.fromCssColorString(that.xzqh_color),
  311. height: 100,
  312. extrudedHeight: res.properties.extrudedHeight,
  313. outline: true,
  314. // outlineColor : Cesium.Color.BLACK
  315. outlineColor: Cesium.Color.fromCssColorString('#55A1E3'),
  316. // 设置远近裁条件
  317. distanceDisplayCondition: new Cesium.DistanceDisplayCondition(20000, 9999999999.0),
  318. }
  319. });
  320. // let polygon = new Cesium.GeometryInstance({
  321. // geometry: new Cesium.PolygonGeometry({
  322. // polygonHierarchy: new Cesium.PolygonHierarchy(
  323. // Cesium.Cartesian3.fromDegreesArray(oneDArray)
  324. // ),
  325. // height: 100,
  326. // extrudedHeight: res.properties.extrudedHeight,
  327. // })
  328. // })
  329. // let addPolygonGeometry = new Cesium.Primitive({
  330. // geometryInstances: polygon,
  331. // appearance: that.colorFun(Cesium.Color.fromCssColorString("rgba(254, 129, 6, 0.1)"))
  332. // })
  333. // viewer.scene.primitives.add(addPolygonGeometry)
  334. })
  335. })
  336. },
  337. // init_xzqh() {
  338. // const that = this;
  339. // xzqh.features.forEach((res) => {
  340. // let obj = {
  341. // 'type': "cockpit",
  342. // 'name': res.properties.name,
  343. // 'centroid': res.properties.centroid,
  344. // 'adcode': res.properties.adcode,
  345. // }
  346. // res.geometry.coordinates.forEach((item) => {
  347. // const twoDArray = item[0];
  348. // const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  349. // viewer.entities.add({
  350. // position: Cesium.Cartesian3.fromDegrees(obj.centroid[0], res.properties.centroid[1], 5000),
  351. // text: obj.name,
  352. // label: {
  353. // scale: 1.5,
  354. // font: "bolder 16px sans-serif",
  355. // style: Cesium.LabelStyle.FILL_AND_OUTLINE,
  356. // text: res.properties.name,//图标名称
  357. // fillColor: Cesium.Color.fromCssColorString("#ffffff"),
  358. // pixelOffset: new Cesium.Cartesian2(5, -15),
  359. // zIndex: 3,
  360. // // 设置远近裁条件
  361. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(20000, 9999999999.0),
  362. // },
  363. // billboard: {
  364. // // 图像地址,URI或Canvas的属性
  365. // image: "./static/images/overview/htq-f.png",
  366. // height: 60,
  367. // // 宽度(以像素为单位)
  368. // width: 150,
  369. // // 相对于坐标的垂直位置
  370. // // verticalOrigin: Cesium.VerticalOrigin.CENTER,
  371. // // // 相对于坐标的水平位置
  372. // // horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  373. // scale: 1.0,
  374. // zIndex: 2,
  375. // // 设置远近裁条件
  376. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(20000, 9999999999.0),
  377. // show: true
  378. // },
  379. // properties: obj,
  380. // polygon: {
  381. // zIndex: 1,
  382. // hierarchy: {
  383. // positions: Cesium.Cartesian3.fromDegreesArray(oneDArray),
  384. // },
  385. // // outline: false,
  386. // material: that.colorFun(Cesium.Color.fromCssColorString("rgba(254, 129, 6, 0.75)")),
  387. // height: 100,
  388. // extrudedHeight: res.properties.extrudedHeight,
  389. // outline: true,
  390. // // outlineColor : Cesium.Color.BLACK
  391. // outlineColor: Cesium.Color.fromCssColorString('#55A1E3'),
  392. // // 设置远近裁条件
  393. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(20000, 9999999999.0),
  394. // }
  395. // });
  396. // })
  397. // })
  398. // },
  399. init_hyqy() {
  400. const that = this;
  401. // hierarchy: {
  402. // positions: Cesium.Cartesian3.fromDegreesArray([
  403. // 125.9, 35.7,
  404. // 110.20, 34.55,
  405. // 120.20, 50.55
  406. // ]),
  407. // // holes: [{
  408. // // positions: Cesium.Cartesian3.fromDegreesArray([
  409. // // 119, 32,
  410. // // 115, 34,
  411. // // 119, 40
  412. // // ])
  413. // // }]
  414. // },
  415. hyqy.features.forEach((res) => {
  416. const twoDArray = res.geometry.coordinates[0];
  417. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  418. viewer.entities.add({
  419. position: Cesium.Cartesian3.fromDegrees(res.properties.centroid[0], res.properties.centroid[1], 500),
  420. text: res.properties.name,
  421. label: {
  422. scale: 1.5,
  423. font: "bolder 16px sans-serif",
  424. style: Cesium.LabelStyle.FILL_AND_OUTLINE,
  425. text: res.properties.name,//图标名称
  426. fillColor: Cesium.Color.fromCssColorString("#ffffff"),
  427. pixelOffset: new Cesium.Cartesian2(5, -15),
  428. zIndex: 3,
  429. // 设置远近裁条件
  430. distanceDisplayCondition: new Cesium.DistanceDisplayCondition(20000, 9999999999.0),
  431. },
  432. billboard: {
  433. // 图像地址,URI或Canvas的属性
  434. image: "./static/images/overview/htq-f.png",
  435. height: 60,
  436. // 宽度(以像素为单位)
  437. width: 150,
  438. // 相对于坐标的垂直位置
  439. // verticalOrigin: Cesium.VerticalOrigin.CENTER,
  440. // // 相对于坐标的水平位置
  441. // horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  442. scale: 1.0,
  443. zIndex: 2,
  444. // 设置远近裁条件
  445. distanceDisplayCondition: new Cesium.DistanceDisplayCondition(20000, 9999999999.0),
  446. show: true
  447. },
  448. properties: {
  449. 'type': "cockpit",
  450. 'name': res.properties.name,
  451. 'centroid': res.properties.centroid,
  452. 'adcode': res.properties.adcode,
  453. },
  454. polygon: {
  455. zIndex: 1,
  456. hierarchy: {
  457. positions: Cesium.Cartesian3.fromDegreesArray(oneDArray),
  458. },
  459. // outline: false,
  460. material: Cesium.Color.fromCssColorString(that.xzqh_color),
  461. height: 300,
  462. extrudedHeight: 350,
  463. outline: true,
  464. // outlineColor : Cesium.Color.BLACK
  465. outlineColor: Cesium.Color.fromCssColorString('#55A1E3'),
  466. // 设置远近裁条件
  467. distanceDisplayCondition: new Cesium.DistanceDisplayCondition(20000, 9999999999.0),
  468. }
  469. });
  470. })
  471. },
  472. addSceneFun() {
  473. var pitch = viewer.camera.pitch;
  474. //获取当前视角的heading
  475. var heading = viewer.camera.heading;
  476. //获取当前视角的postion(位置)
  477. var position = viewer.camera.position;
  478. var x = position.x;
  479. var y = position.y;
  480. var z = position.z;
  481. var testPitch = pitch;
  482. var testHeading = heading;
  483. // console.log("获取当前视角x,y,z", position.x, position.y, position.z, "pitch", pitch, "heading", heading);
  484. var obj = {
  485. "x": x,
  486. "y": y,
  487. "z": z,
  488. "pitch": pitch,
  489. "heading": heading,
  490. }
  491. console.log(obj, "asd");
  492. },
  493. flatten3DArray(arr) {
  494. let stack = [...arr]; // 初始化栈,并将数组元素压入栈中
  495. let result = []; // 用于存储结果的一维数组
  496. while (stack.length > 0) {
  497. let current = stack.pop(); // 弹出栈顶元素
  498. if (Array.isArray(current)) {
  499. // 如果当前元素是数组,则将其元素压入栈中(逆序)
  500. for (let i = current.length - 1; i >= 0; i--) {
  501. stack.push(current[i]);
  502. }
  503. } else {
  504. // 如果当前元素不是数组,则将其添加到结果数组中
  505. result.push(current);
  506. }
  507. }
  508. // 注意:因为我们是逆序压入栈中的,所以结果数组的顺序与原始三维数组中的顺序相反
  509. // 如果需要保持原始顺序,可以在压入栈时使用unshift代替push,但这样会降低性能
  510. return result;
  511. }
  512. },
  513. beforeCreate() { }, //生命周期 - 创建之前
  514. created() { }, //生命周期 - 创建完成(可以访问当前this实例)
  515. beforeMount() { }, //生命周期 - 挂载之前
  516. async mounted() {
  517. // let obj = { beginTime: '20230612', endTime: '20230817', jscType: 'jsc_wpjc_yelx', id: '46' };
  518. // let data = await cockpitInfo(obj);
  519. // let obj1 = { beginTime: '20230612', endTime: '20230817', jscType: 'jsc_wpjc_ztsh', id: '46' }
  520. // let data1 = await cockpitInfo(obj1);
  521. // console.log(data, "asda");
  522. // console.log(data1, "asda");
  523. // 三亚行政区划加载
  524. this.$nextTick((res) => {
  525. this.pick_xzqh();
  526. this.init_xzqh();
  527. this.init_hyqy();
  528. });
  529. }, //生命周期 - 挂在完成
  530. beforeUpdate() { }, //生命周期 - 更新之前
  531. updated() { }, //生命周期 - 更新之后
  532. beforeDestroy() { }, //生命周期 - 销毁之前
  533. destroy() { },//生命周期 - 销毁完成
  534. activated() { }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用。
  535. deactivated() { } //若组件实例是 <KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用。
  536. };
  537. </script>
  538. <style scoped lang="scss" >
  539. .viewer {
  540. width: 100%;
  541. height: 100%;
  542. }
  543. .bg {
  544. width: 100%;
  545. height: 100%;
  546. .bg_left {
  547. width: 21.6%;
  548. height: calc(100% + 60px);
  549. position: absolute;
  550. top: -60px;
  551. left: 0;
  552. z-index: 100;
  553. background: linear-gradient(to right, rgba(6, 37, 66, 1), rgba(26, 28, 53, 0));
  554. }
  555. .bg_right {
  556. width: 21.6%;
  557. height: calc(100% + 60px);
  558. position: absolute;
  559. top: -60px;
  560. right: 0;
  561. z-index: 100;
  562. background: linear-gradient(to left, rgba(6, 37, 66, 1), rgba(26, 28, 53, 0));
  563. }
  564. .bg_bottom {
  565. width: 100%; // 56.8%;
  566. height: 30%;
  567. position: absolute;
  568. // left: 21.6%;
  569. bottom: 0;
  570. z-index: 100;
  571. background: linear-gradient(to top, rgba(6, 37, 66, 0.5), rgba(26, 28, 53, 0));
  572. }
  573. }
  574. </style>