|
@@ -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>
|