From cbd42033578a170b36b600003e15a9200f73241d Mon Sep 17 00:00:00 2001 From: Swanky <413564165@qq.com> Date: Thu, 14 Mar 2024 21:27:24 +0800 Subject: [PATCH] 1 --- common/helper.js | 22 +++++++++++++++++----- pages/index/index.vue | 23 +++++++++++++++++++---- pages/sjgl/sjgl.vue | 15 ++++++++++++++- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/common/helper.js b/common/helper.js index a501d64..a959f92 100644 --- a/common/helper.js +++ b/common/helper.js @@ -13,7 +13,8 @@ import { getLength } from 'ol/sphere.js'; import { - LineString + LineString, + Point } from "ol/geom"; @@ -50,7 +51,8 @@ const formatLength = function(line) { const generateStyle = (feature, { fillOpt, - strokeOpt + strokeOpt, + withNode }) => { let area = 0; const geom = feature.getGeometry(); @@ -59,7 +61,7 @@ const generateStyle = (feature, { area = formatArea(geom); const lineString = new LineString(geom.getCoordinates()[0]); const length = formatLength(lineString); - lineStyle = new Style({ + lineStyle = [new Style({ geometry: lineString, text: new TextStyle({ text: length, @@ -79,7 +81,17 @@ const generateStyle = (feature, { "overflow": true, "rotation": 0 }) - }) + }), ...(withNode ? geom.getCoordinates()[0]?.map(coordinates => { + return new Style({ + geometry: new Point(coordinates), + image: new CircleStyle({ + fill: new Fill({ + color: '#0ff' + }), + radius: 2 + }) + }) + }) : [])] } return [new Style({ fill: new Fill({ @@ -103,7 +115,7 @@ const generateStyle = (feature, { "overflow": true, "rotation": 0 }) - }), lineStyle].filter(item => item); + }), ...(lineStyle || [])].filter(item => item); } const startMeasure = (map, callback) => { diff --git a/pages/index/index.vue b/pages/index/index.vue index 0c60b69..6825ce3 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -3,9 +3,9 @@ - + - + @@ -147,7 +147,8 @@ token: '', measureStatus: '', currentClickLayerItem: null, - xzgjPoints: [] + xzgjPoints: [], + compassNum: 0 } }, watch: { @@ -193,6 +194,18 @@ xzgjPoints: this.xzgjPoints } }) + + this.compassHandler = res => { + console.log(res) + this.compassNum = res.direction; + } + uni.onCompassChange(this.compassHandler); + }, + onShow() { + uni.startCompass() + }, + onHide() { + uni.stopCompass(); }, methods: { checkLayer(value) { @@ -591,7 +604,8 @@ strokeOpt: { color: '#ffcc33', width: 2, - } + }, + withNode: true }) feature.setStyle(style); vectorLayer.getSource().addFeature(feature) @@ -843,6 +857,7 @@ z-index: 1; font-weight: bold; font-size: 17px; + margin-top: 8px; } .btn-workbench { diff --git a/pages/sjgl/sjgl.vue b/pages/sjgl/sjgl.vue index e869f46..330a55f 100644 --- a/pages/sjgl/sjgl.vue +++ b/pages/sjgl/sjgl.vue @@ -2,7 +2,7 @@ + @cancel="searchCancel" @confirm="search" v-model="searchValue"> @@ -63,6 +63,12 @@ this.searchVisible = true }, methods: { + searchCancel() { + this.searchVisible = false; + this.searchValue = '' + this.datas = []; + this.requestData(); + }, search(value) { this.pageNum = 1; this.datas = [] @@ -145,7 +151,14 @@ } else { this.loadStatus = 'more' } + } else { + this.datas = []; + this.loadStatus = 'no-more' } + }, + fail: err => { + this.datas = []; + this.loadStatus = 'no-more' } }) }