Prechádzať zdrojové kódy

新增考场视频定位

JXDS18FUJT 2 rokov pred
rodič
commit
fd15584611

+ 9 - 1
src/api/modules/amap.js

@@ -1,6 +1,6 @@
 import request from '../request'
 
-const amap={
+const amap = {
 	/**
 	 * 逆地理编码
 	 * @param {
@@ -17,6 +17,14 @@ const amap={
 				...params
 			}
 		})
+	},
+	wxmapGetLocation(params) {
+		return request({
+			url: 'student/wxmap/getLocation',
+			method: 'get',
+			params
+		})
+
 	}
 }
 

+ 6 - 2
src/manifest.json

@@ -24,7 +24,7 @@
         "desc": "获取位置可以更好地推荐区域信息"
       }
     },
-    "requiredPrivateInfos":["choosePoi"]
+    "requiredPrivateInfos":["choosePoi","getFuzzyLocation"]
   },
   "mp-toutiao": {
     "appid": "tta896de2b37a8562901",
@@ -37,7 +37,11 @@
     "usingComponents": true,
     "permission": {
       "scope.userLocation": {
-        "desc": "电影院位置定位请求"
+        "desc": "位置定位请求"
+      },
+      "scope.userFuzzyLocation":{
+        "desc": "考场推荐定位请求"
+
       }
     }
   },

+ 84 - 27
src/otherPages/examRoadVideo/index.vue

@@ -110,11 +110,11 @@ export default {
       examProviceList: [],
       examCityList: [],
       examRoomList: [],
-      province: uni.getStorageSync("roadExamProvince") || {
+      province: {
         provinceId: "",
         province: "",
       },
-      city: uni.getStorageSync("roadExamCity") || {
+      city: {
         cityId: "",
         city: "",
       },
@@ -195,15 +195,89 @@ export default {
   },
   onLoad(query) {
     this.query = query;
-    uni.getLocation({
-      type: 'gcj02',
-      success(res){
-        console.log(res)
+    let that = this;
+    uni.getFuzzyLocation({
+      type: "gcj02",
+      success(res) {
+        api.amap
+          .wxmapGetLocation({
+            location: res.latitude + "," + res.longitude,
+          })
+          .then((result) => {
+            console.log(result);
+            //处理直辖市没有省id的问题
+            that.province = {
+              province: result.data.province,
+              provinceId:
+                result.data.provinceCode !== "0"
+                  ? result.data.provinceCode
+                  : result.data.cityCode,
+            };
+            that.city = {
+              city: result.data.city,
+              cityId: result.data.cityCode,
+            };
+            if (that.city.cityId && that.province.provinceId) {
+              api.exam.studentExamInfoGetProvice().then((res) => {
+                that.examProviceList = res.data;
+                if (
+                  that.examProviceList.some((item) => {
+                    return that.province.province == item.province;
+                  })
+                ) {
+                  
+                  api.exam
+                    .studentExamInfoCityProviceId(that.province.provinceId)
+                    .then((res) => {
+                      that.examCityList = res.data;
+
+                      api.exam
+                        .studentExamInfoList({
+                          ...that.city,
+                        })
+                        .then((res) => {
+                          that.examRoomList = res.rows;
+                        });
+                    });
+                } else {
+                  that.city = {
+                    city: "",
+                    cityId: "",
+                  };
+                  that.province = {
+                    province: "",
+                    provinceId: "",
+                  };
+                  api.exam
+                    .studentExamInfoList({
+                      ...that.city,
+                    })
+                    .then((res) => {
+                      that.examRoomList = res.rows;
+                    });
+                }
+              });
+            }
+          });
       },
-      fail(res){
-        console.log(res)
-      }
-    })
+      fail(res) {
+        if (that.city.cityId && that.province.provinceId) {
+          api.exam
+            .studentExamInfoCityProviceId(that.province.provinceId)
+            .then((res) => {
+              that.examCityList = res.data;
+            });
+          api.exam
+            .studentExamInfoList({
+              ...that.city,
+            })
+            .then((res) => {
+              that.examRoomList = res.rows;
+            });
+        }
+        console.log(res);
+      },
+    });
     // api.user.studentVipExamList().then((res) => {
     //   uni.setStorageSync("examRoom", res.rows);
     // });
@@ -226,23 +300,6 @@ export default {
     //       }
     //     });
     // });
-    api.exam.studentExamInfoGetProvice().then((res) => {
-      this.examProviceList = res.data;
-    });
-    if (this.city.cityId && this.province.provinceId) {
-      api.exam
-        .studentExamInfoCityProviceId(this.province.provinceId)
-        .then((res) => {
-          this.examCityList = res.data;
-        });
-      api.exam
-        .studentExamInfoList({
-          ...this.city,
-        })
-        .then((res) => {
-          this.examRoomList = res.rows;
-        });
-    }
   },
 };
 </script>