瀏覽代碼

修复数组转字符串

wangcc 2 年之前
父節點
當前提交
aab61d663a
共有 2 個文件被更改,包括 26 次插入25 次删除
  1. 19 25
      src/components/amapPow.vue
  2. 7 0
      src/service/index.js

+ 19 - 25
src/components/amapPow.vue

@@ -3,7 +3,7 @@
  * @Author: wangcc
  * @Date: 2022-10-19 09:32:46
  * @LastEditors: wangcc
- * @LastEditTime: 2022-12-12 17:31:55
+ * @LastEditTime: 2022-12-13 11:31:52
  * @FilePath: \castgroup_bigscreen\src\components\amapPow.vue
  * @Copyright: Copyright (c) 2016~2022 by wangcc, All Rights Reserved. 
 -->
@@ -36,6 +36,7 @@ import {
   forestSample,
   alarmDataApi,
   financeBasePlant,
+  basePlantList,
   financeBaseDetail,
   farmInfo,
   smallClassDetail,
@@ -1924,7 +1925,7 @@ export default {
     // 林业经济
     getEconomics() {
       let _this = this;
-      financeBasePlant({
+      basePlantList({
         cityId: this.$store.state.addr.selectCity.areaId,
         countyId: this.$store.state.addr.selectDistrict.areaId
         // townId: this.$store.state.addr.selectStreet.areaId
@@ -1932,20 +1933,20 @@ export default {
         let economicsList = [];
         let baseList = [];
         res.rows.forEach((element) => {
-          if (element.cateLongitude && element.cateLatitude) {
-            economicsList.push({
-              longitude: element.cateLongitude,
-              latitude: element.cateLatitude,
-              icon: element.image
-            });
-          }
+          // if (element.cateLongitude && element.cateLatitude) {
+          //   economicsList.push({
+          //     longitude: element.cateLongitude,
+          //     latitude: element.cateLatitude,
+          //     icon: element.image
+          //   });
+          // }
           if (element.baseLongitude && element.baseLatitude) {
             baseList.push({
               baseId: element.baseId,
               baseName: element.baseName,
               longitude: element.baseLongitude,
               latitude: element.baseLatitude,
-              icon: element.image
+              cateInfoList: element.cateInfoList
             });
           }
         });
@@ -1968,7 +1969,7 @@ export default {
         //   // this.economicsArr.push(this.smallMarker);
         //   // this.smallMarker.setMap(this.map);
         // });
-        console.log(baseList);
+        // console.log(baseList);
         baseList.forEach((element) => {
           let lanLatArr = [element.longitude, element.latitude];
           let baseIcon = require('@/assets/img/postion.png');
@@ -1979,12 +1980,12 @@ export default {
             imageSize: new AMap.Size(iconMeta[0], iconMeta[1]) // 根据所设置的大小拉伸或压缩图片
           });
           let imgList = [];
-          console.log(element.icon);
-          if (element.icon) {
-            imgList.push(`<img id="baseMarkerLabel" src="${element.icon}"/>`);
-          } else {
-            imgList.push('暂无图片');
+          if (element.cateInfoList.length > 0) {
+            element.cateInfoList.forEach((item) => {
+              imgList.push(`<img src="${item.image}"/>`);
+            });
           }
+          console.log(imgList.join(' '));
           this.baseMarker = new AMap.Text({
             map: this.map,
             position: lanLatArr,
@@ -1998,9 +1999,9 @@ export default {
             }
           });
           this.baseMarker.setLabel({
-            direction: 'bottom',
+            direction: 'left',
             offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
-            content: '<div class="base-marker-imgs">' + imgList + '</div>' //设置文本标注内容
+            content: '<div class="base-marker-imgs">' + imgList.join(' ') + '</div>' //设置文本标注内容
           });
           this.baseMarkerArr.push(this.baseMarker);
           this.baseMarker.on('click', function (e) {
@@ -2324,13 +2325,6 @@ export default {
   }
 }
 /deep/ .base-marker-imgs {
-  // display: flex;
-    // line-height: 18px !important;
-    // width: 376px;
-    // overflow: auto;
-    // justify-content: left;
-    // align-items: center;
-
   img {
     width: 30px;
     height: 30px;

+ 7 - 0
src/service/index.js

@@ -271,6 +271,13 @@ export const financeBasePlant = data =>
     prefixUrl: "api2"
   });
 
+   
+  export const basePlantList = data =>
+  callApi({
+    url: "finance/basePlantList",
+    data,
+    prefixUrl: "api2"
+  });
 //林下经济-查询基地农作物详情
 export const financeBaseDetail = data =>
   callApi({