瀏覽代碼

巡检增加地址

seimin 3 年之前
父節點
當前提交
0d49be2517
共有 1 個文件被更改,包括 58 次插入2 次删除
  1. 58 2
      src/views/InspectionDetail.vue

+ 58 - 2
src/views/InspectionDetail.vue

@@ -86,12 +86,15 @@
86 86
     </div>
87 87
     <div class="btns">
88 88
       <div class="btn" @click="createIncident()">生成事件</div>
89
-      <div class="btn submit" @click="submit()">提交</div>
89
+      <div class="btn submit" @click="getLocation()">提交</div>
90 90
       <div class="btn cancel" @click="cancle()">取消</div>
91 91
     </div>
92 92
   </div>
93 93
 </template>
94 94
 <script>
95
+let sdk = new jssdk(3, "https://wx2.zuel.edu.cn"); // 域名更换为对应环境域名, 204 更换为对应环境wid
96
+sdk.config(0); //1表示调试模式,生产环境传0
97
+import { GL } from "./../http/http";
95 98
 export default {
96 99
   data() {
97 100
     return {
@@ -128,6 +131,57 @@ export default {
128 131
     };
129 132
   },
130 133
   methods: {
134
+    //获取位置,经纬度
135
+    getLocation() {
136
+      // 判断是否处于微信浏览器环境
137
+      if (!/MicroMessenger/i.test(window.navigator.userAgent)) {
138
+        this.$createToast({
139
+          txt: "请前往微信中操作",
140
+          type: "warn",
141
+          mask: true,
142
+        }).show();
143
+        return;
144
+      }
145
+      this.toast = this.$createToast({
146
+        time: 0,
147
+        mask: true,
148
+        txt: "正在加载中",
149
+      });
150
+      this.toast.show();
151
+      // 中南财大
152
+      if (this.isZncd) {
153
+        //第二个参数 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
154
+        sdk.getLocation((res) => {
155
+          // alert(JSON.stringify(res));
156
+          // latitude
157
+          // longitude
158
+          this.gl(res);
159
+        });
160
+      } else {
161
+        GL(this).then((res) => {
162
+          this.gl(res);
163
+        });
164
+      }
165
+    },
166
+    //获取地理位置方法
167
+    gl(res) {
168
+      let _this = this;
169
+      $.ajax({
170
+        url: "https://apis.map.qq.com/ws/geocoder/v1",
171
+        data: {
172
+          location: res.latitude + "," + res.longitude,
173
+          key: "TADBZ-IRBWU-QAXVE-2IWED-UW2F5-YVF66",
174
+          output: "jsonp",
175
+        },
176
+        dataType: "jsonp",
177
+        success(result) {
178
+          if (result.status === 0) {
179
+            let address = result.result.formatted_addresses.recommend;
180
+            _this.submit(address);
181
+          }
182
+        },
183
+      });
184
+    },
131 185
     fileSubmitted(files) {
132 186
       this.action.data = { fileName: files.name };
133 187
     },
@@ -188,7 +242,7 @@ export default {
188 242
         });
189 243
     },
190 244
     // 提交
191
-    submit() {
245
+    submit(address) {
192 246
       this.param.loginUser = this.loginUser;
193 247
       this.param.save = this.model.save;
194 248
       this.param.close = this.model.close;
@@ -196,6 +250,7 @@ export default {
196 250
       this.param.toIncident = this.model.toIncident;
197 251
       this.param.handler_code = "resolve";
198 252
       this.param.inspectionProcessActual = this.baseInfo;
253
+      this.param.address = address;
199 254
       console.log(this.param);
200 255
       var that = this;
201 256
       that.$http
@@ -209,6 +264,7 @@ export default {
209 264
         .then(function(res) {
210 265
           console.log(res.data);
211 266
           if (res.data.status == 200) {
267
+            that.toast.hide();
212 268
             that.action.target =
213 269
               that.action.target +
214 270
               that.param.inspectionProcessActual.processInstanceId;