Sfoglia il codice sorgente

修改自提点管理

pangqijun 1 anno fa
parent
commit
f36eedc91f
2 ha cambiato i file con 40 aggiunte e 5 eliminazioni
  1. 2 2
      public/index.html
  2. 38 3
      src/views/groupon/selftake.vue

+ 2 - 2
public/index.html

@@ -21,10 +21,10 @@
   <script src="https://cdn.staticfile.org/Sortable/1.10.0-rc2/Sortable.min.js"></script>
   <script>
     window._AMapSecurityConfig = {
-      securityJsCode: 'c5c2dcfea06bf0b83818cc98f5d0a421',
+      securityJsCode: 'dd6ede3ea2bc55c16b4cd3ce1f6dfb5b',
     }
   </script>
-  <script type="text/javascript" src='https://webapi.amap.com/maps?v=1.4.11&key=ca90d6d51568d1d5fb77238fb2d888d2&plugin=AMap.PlaceSearch'></script>
+  <script type="text/javascript" src='https://webapi.amap.com/maps?v=1.4.11&key=e25b98a57b313db65884382a3a939532&plugin=AMap.PlaceSearch'></script>
   <script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
   <link rel="icon" href="<%= BASE_URL %>favicon.png">
   <title>中意购-运营后台</title>

+ 38 - 3
src/views/groupon/selftake.vue

@@ -92,6 +92,7 @@
               prop: "addressTemp",
               labelWidth: 120,
               type: 'map',
+              // component: 'avueMap',
               hide: true,
               rules: [{
                 required: true,
@@ -192,13 +193,24 @@
           ids.push(ele.id);
         });
         return ids.join(",");
-      }
+      },
+    },
+    created() {
+      this.option.column[1].change = function (column) {
+        if (column.value.length > 0) {
+          let value = column.value;
+          this.getAddress(value[0], value[1], (result) => {
+            column.value[2] = result;
+          });
+        }
+
+      }.bind(this);
     },
     methods: {
       rowSave(row, done, loading) {
         row.longitude = row.addressTemp[0];
         row.latitude = row.addressTemp[1];
-        row.address = row.addressTemp[2];
+        row.address = this.address;
         console.log(row)
         add(row).then(() => {
           this.onLoad(this.page);
@@ -215,7 +227,7 @@
       rowUpdate(row, index, done, loading) {
         row.longitude = row.addressTemp[0];
         row.latitude = row.addressTemp[1];
-        row.address = row.addressTemp[2];
+        row.address = this.address;
         update(row).then(() => {
           this.onLoad(this.page);
           this.$message({
@@ -271,6 +283,11 @@
         if (["edit", "view"].includes(type)) {
           getDetail(this.form.id).then(res => {
             this.form = res.data.data;
+            let addressTemp = [];
+            addressTemp.push(this.form.longitude)
+            addressTemp.push(this.form.latitude)
+            addressTemp.push(this.form.address)
+            this.form.addressTemp = addressTemp;
           });
         }
         done();
@@ -339,6 +356,24 @@
           });
         })
       },
+      getAddress (r, p, callback) {
+        new window.AMap.service("AMap.Geocoder", () => {
+          //回调函数
+          let geocoder = new window.AMap.Geocoder({});
+          geocoder.getAddress([r, p], (status, result) => {
+            if (status === "complete" && result.info === "OK") {
+              var address = result.regeocode.formattedAddress;
+              this.address = address;
+              callback(address);
+            } else {
+              this.$message({
+                type: "error",
+                message: "高德地图调用失败!"
+              });
+            }
+          });
+        });
+      }
     }
   };
 </script>