浏览代码

—定位

zhengkaixin 4 年之前
父节点
当前提交
96a1c60a39

+ 5 - 0
src/projects/business/views/Master/Health/WorkerInfo.vue

@@ -69,6 +69,11 @@
 					<label style="width:70%" >是否接触重点疫区高危人群</label>
 					<span style="width:30%" v-text="detail.personHealthLedger.isTouch?'是':'否'">否</span>
 				</div>
+				<div class="mui-input-row" style="height: 100px;">
+					<label style="width:30%;height: 100px;">定位</label>
+					<span   class="vongi-yidi-location aaa" >{{detail.personHealthLedger.address}}</span>
+				</div>
+
 			</form>
 
 		</div>

+ 68 - 4
src/projects/business/views/Master/Health/WorkerReport.vue

@@ -119,6 +119,16 @@
 
 					</div>
 				</div>
+
+				<div class="mui-input-row"   style="height: 100px" >
+					<label  style="width:30%;height: 100px;">定位<i class="colorfe616c"  v-if="!curDateIsUpload">*</i></label>
+					<span v-if="!curDateIsUpload" style="text-align: left;" class="vongi-yidi-location" @click="getPoint"
+
+					>{{report.address}}<i class="mui-icon mui-icon-location" style="color: #096DD9;font-size: 13px;">重新定位</i></span>
+					<span v-if="curDateIsUpload" class="vongi-yidi-location aaa" >{{address?address:report.address}}</span>
+
+				</div>
+
 			</form>
 			<div class="vongi-btn vongi-login-btn" v-if="!curDateIsUpload&&!send">
 				<button class="mui-btn mui-btn-primary " @click="submitReport()">
@@ -152,7 +162,7 @@
 	import Common from '$project/components/Common.vue'
 	import Loading from '$project/components/Loading.vue'
 	import TopHeader from '$project/components/TopHeader.vue'
-
+    import MapLoader from '$project/utils/AMap'
 	import * as WxJsApi from '$project/utils/wxJsApi'
 	import {
 		mapGetters,
@@ -175,6 +185,7 @@
 				id: '',
 				student: {},
 				report: {
+
 					healthStatus: "",
 					healthStatusN: "请选择",
 					healthRemark: "",
@@ -182,8 +193,13 @@
 					familyStatusN: "请选择",
 					pictures: [],
 					isGoto: false,
-					isTouch: false
-				},
+					isTouch: false,
+
+                    longitude: 112.276527,
+                    latitude: 30.306427,
+                    address: '湖北省荆州市江津东路附155号荆鹏软件园',
+                },
+                address:'',
 				curDateIsUpload: false,
 				send: false,
 				isLoading: false,
@@ -211,6 +227,7 @@
 							this.report.isTouch = response.personHealthLedger.isTouch;
 							this.report.pictures = response.personHealthLedger.familyGreenCode.split(',');
 							this.report.temperature = response.personHealthLedger.temperature;
+                            this.address=response.personHealthLedger.address;
 
 						}
 
@@ -253,6 +270,47 @@
 
 		},
 		methods: {
+            getPoint(){
+                this.report.address=='定位中……';
+                this.isLoading = true;
+                WxJsApi.getLocation().then((res) => {
+                    this.isLoading = false;
+
+                    this.report.latitude = parseFloat(res.latitude);
+                    this.report.longitude = parseFloat(res.longitude);
+
+                    //获取定位地址
+                    this.getPositionByLonLats()
+                }).catch(error => {
+
+                    this.isLoading = false;
+                    console.log(error)
+                    mui.toast(JSON.stringify(error));
+                })
+			},  //获取定位地址
+            getPositionByLonLats() {
+                var _this = this;
+                MapLoader().then(AMap => {
+                    var lnglatXY = [_this.report.longitude, _this.report.latitude];
+                    AMap.service('AMap.Geocoder', function() {
+                        let geocoder = new AMap.Geocoder({});
+                        geocoder.getAddress(lnglatXY, function(status, result) {
+                            console.log(lnglatXY);
+                            console.log(status, result);
+                            if (status === 'complete' && result.info === 'OK') {
+                                var address = result.regeocode.formattedAddress;
+                                console.log(address);
+                                _this.report.address = address;
+                            } else {
+                                _this.report.address = '无法获取定位';
+                            }
+                        });
+                    });
+                }).catch(error => {
+                    console.log(error)
+                    mui.toast(JSON.stringify(error));
+                })
+            },
 			asynCallBack() {},
 			delImg(index) {
 
@@ -390,6 +448,10 @@
 			},
 			submitReport() {
 
+                if (this.report.address=='定位中……'||this.report.address=='无法获取定位') {
+                    mui.alert("定位失败,请点击<span class=\"mui-icon mui-icon-location\" style=\"color: #096DD9;font-size: 16px;\"></span>蓝色定位图标重新获取位置信息!");
+                    return;
+                }
 				if (this.report.healthStatus.length == 0) {
 					mui.toast("请选择自身健康情况!");
 					return;
@@ -470,7 +532,9 @@
 			asynCallBack() {},
 		},
 		mounted() {
-			WxJsApi.getWxConfig();
+            WxJsApi.getWxConfig(['chooseImage', 'getLocalImgData', 'getLocation']);
+            //获取经纬度
+            this.getPoint();
 		},
 		destroyed() {