【修复】修复安卓苹果APP下高德地图调用失败的问题。

This commit is contained in:
JianWeie
2022-08-07 12:25:23 +08:00
parent e8c23018d2
commit a1656a12fa

View File

@@ -26,7 +26,7 @@
<u-input :value="pickerValue" type="select" disabled placeholder="请选择省市区区域">
<template slot="suffix">
<!--<u-button text="请选择" type="success" size="mini" @click="toMap"></u-button>-->
<u-button text="请选择" type="success" size="mini" @click="show = true"></u-button>
<u-button text="请选择" type="success" size="mini" @click="show = true"></u-button>
</template>
</u-input>
<!-- #endif -->
@@ -34,13 +34,13 @@
<u--input :value="pickerValue" type="select" disabled placeholder="请选择省市区区域">
<template slot="suffix">
<!--<u-button text="请选择" type="success" size="mini" @click="toMap"></u-button>-->
<u-button text="请选择" type="success" size="mini" @click="show = true"></u-button>
<u-button text="请选择" type="success" size="mini" @click="show = true"></u-button>
</template>
</u--input>
<!-- #endif -->
</u-form-item>
<u-form-item label="街道社区" borderBottom @click="toMap">
<u-form-item label="街道社区" borderBottom @click="toMap">
<!-- 注意由于兼容性差异如果需要使用前后插槽nvue下需使用u--input非nvue下需使用u-input -->
<!-- #ifndef APP-NVUE -->
<u-input :value="form.street" type="text" disabled placeholder="请定位">
@@ -84,7 +84,11 @@
</template>
<script>
// #ifdef MP-WEIXIN
const chooseLocation = requirePlugin('chooseLocation');
// #endif
// #ifdef APP-PLUS || APP-PLUS-NVUE
// #endif
export default {
data() {
return {
@@ -157,43 +161,32 @@
}
},
onShow() {
const location = chooseLocation.getLocation(); // 如果点击确认选点按钮则返回选点结果对象否则返回null
// #ifdef MP-WEIXIN
const chooseLocation = requirePlugin('chooseLocation');
const location = chooseLocation.getLocation();
// #endif
// #ifdef APP-PLUS || APP-PLUS-NVUE
const location = uni.getLocation();
// #endif
if (location != null) {
this.form.latitude = location.latitude;
this.form.longitude = location.longitude;
this.region = [location.province, location.district, location.city];
//let data = {
// provinceName: location.province,
// cityName: location.district,
// countyName: location.city
//};
this.form.street = location.name;
this.form.address = location.address;
//let postData = {
// countyName: location.district,
// cityName: location.city,
// provinceName: location.province,
//}
//this.$u.api.getAreaIdByName(postData).then(res => {
// if (res.status) {
// this.areaId = res.data.areaId;
// this.pickerValue = res.data.fullName;
// } else {
// uni.showModal({
// title: '提示',
// content: '地区选择出现问题,请重新选择地区',
// showCancel: false
// });
// }
//});
console.log("location1:", location);
}
},
onUnload() {
// 页面卸载时设置插件选点数据为null防止再次进入页面geLocation返回的是上次选点结果
// #ifdef MP-WEIXIN
chooseLocation.setLocation(null);
// #endif
// #ifdef APP-PLUS || APP-PLUS-NVUE
//uni.setLocation(null);
// #endif
},
onLoad(e) {
this.getMyLocation();
@@ -424,6 +417,7 @@
this.pickerIndex = [this.provinceKey, this.cityKey, this.areaKey];
},
toMap() {
// #ifdef MP-WEIXIN
const txMapkey = this.$store.state.config.qqMapKey; //使用在腾讯位置服务申请的key
const referer = this.$store.state.config.shopName; //调用插件的app的名称
const location = JSON.stringify({
@@ -436,12 +430,20 @@
url: 'plugin://chooseLocation/index?key=' + txMapkey + '&referer=' + referer + '&location=' +
location + '&category=' + category
});
//if (!this.pickerValue) {
// this.$u.toast('请先获取省市区信息');
// return false;
//} else {
// this.$u.route('/pages/member/address/map/map', { pickerValue: this.pickerValue, areaId: this.areaId, longitude: this.form.longitude, latitude: this.form.latitude });
//}
// #endif
// #ifdef APP-PLUS || APP-PLUS-NVUE
uni.chooseLocation({
success: (res) => {
this.form.street = res.name;
this.form.latitude = res.latitude;
this.form.longitude = res.longitude;
}
});
// #endif
}
},