邓洁 : 提示定位框
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import QQMapWX from "@/utils/qqmap-wx-jssdk.min.js"
|
||||||
export default {
|
export default {
|
||||||
name: "inputAndSwiper",
|
name: "inputAndSwiper",
|
||||||
props: {
|
props: {
|
||||||
@@ -46,8 +47,103 @@
|
|||||||
options: {
|
options: {
|
||||||
styleIsolation: 'shared', // 解除样式隔离
|
styleIsolation: 'shared', // 解除样式隔离
|
||||||
},
|
},
|
||||||
created() {},
|
onShow() {
|
||||||
|
if (this.type !== '0') {
|
||||||
|
this.open()
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
open() {
|
||||||
|
if (!uni.getStorageSync('city') && !uni.getStorageSync('district')) {
|
||||||
|
uni.getSystemInfo({
|
||||||
|
success: (res) => {
|
||||||
|
if (!res.locationEnabled || !res.locationAuthorized) {
|
||||||
|
uni.showModal({
|
||||||
|
content: '检测到您没打开手机系统定位权限,请确保手机系统定位已开启',
|
||||||
|
confirmText: "确认",
|
||||||
|
showCancel: false,
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
this.getUserLocation();
|
||||||
|
} else {
|
||||||
|
console.log('取消');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.getUserLocation()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getUserLocation() {
|
||||||
|
var that = this
|
||||||
|
let qqmapsdk = new QQMapWX({
|
||||||
|
key: that.$api.key
|
||||||
|
});
|
||||||
|
uni.getFuzzyLocation({
|
||||||
|
type: 'wgs84',
|
||||||
|
success(res) {
|
||||||
|
console.log('res.latitude', res.latitude);
|
||||||
|
console.log('res.longitude', res.longitude);
|
||||||
|
uni.setStorageSync('latitude', res.latitude);
|
||||||
|
uni.setStorageSync('longitude', res.longitude);
|
||||||
|
qqmapsdk.reverseGeocoder({
|
||||||
|
location: {
|
||||||
|
latitude: res.latitude,
|
||||||
|
longitude: res.longitude
|
||||||
|
},
|
||||||
|
success: (re) => {
|
||||||
|
console.log("解析地址成功", re);
|
||||||
|
console.log(re.result.ad_info.city);
|
||||||
|
console.log(re.result.ad_info.district);
|
||||||
|
let city = re.result.ad_info.city
|
||||||
|
let district = re.result.ad_info.district
|
||||||
|
console.log('city-code', re.result.ad_info.city_code.substring(3));
|
||||||
|
uni.setStorageSync('city_code', re.result.ad_info.city_code.substring(3));
|
||||||
|
uni.setStorageSync('city', city.slice(0, 2));
|
||||||
|
uni.setStorageSync('district', district);
|
||||||
|
that.getRegionList()
|
||||||
|
// that.position = city.slice(0, 2) + district.slice(0, 2)
|
||||||
|
},
|
||||||
|
fail: (re) => {
|
||||||
|
console.log(re, '失败信息');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fail(err) {
|
||||||
|
console.log("获取经纬度失败", err);
|
||||||
|
uni.getSystemInfo({
|
||||||
|
success: (res) => {
|
||||||
|
if (!res.locationEnabled || !res.locationAuthorized) {
|
||||||
|
uni.showModal({
|
||||||
|
content: '检测到您没打开手机系统定位权限,请确保手机系统定位已开启',
|
||||||
|
confirmText: "确认",
|
||||||
|
showCancel: false,
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
// uni.openSetting({
|
||||||
|
// success: (res) => {
|
||||||
|
// console.log(res);
|
||||||
|
that.getUserLocation();
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
} else {
|
||||||
|
console.log('取消');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
that.getUserLocation()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
//点击轮播图
|
//点击轮播图
|
||||||
handleSwiperList(currentNum, bannerURL) {
|
handleSwiperList(currentNum, bannerURL) {
|
||||||
const item = bannerURL[currentNum]
|
const item = bannerURL[currentNum]
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
searchPageNum: 1,
|
searchPageNum: 1,
|
||||||
shopListLength: '',
|
shopListLength: '',
|
||||||
shopSearchListLength: '',
|
shopSearchListLength: '',
|
||||||
|
isAuth: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
@@ -62,6 +63,33 @@
|
|||||||
this.open()
|
this.open()
|
||||||
this.getClassList()
|
this.getClassList()
|
||||||
},
|
},
|
||||||
|
onShow() {
|
||||||
|
if (this.isAuth) {
|
||||||
|
if (!uni.getStorageSync('city_code')) {
|
||||||
|
uni.getSystemInfo({
|
||||||
|
success: (res) => {
|
||||||
|
if (!res.locationEnabled || !res.locationAuthorized) {
|
||||||
|
uni.showModal({
|
||||||
|
content: '检测到您没打开手机系统定位权限,请确保手机系统定位已开启',
|
||||||
|
confirmText: "确认",
|
||||||
|
showCancel: false,
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
this.getUserLocation();
|
||||||
|
} else {
|
||||||
|
console.log('取消');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.getUserLocation()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
onReachBottom() {
|
onReachBottom() {
|
||||||
if (this.chooseIndex == 0 && this.shopListLength !== 0) {
|
if (this.chooseIndex == 0 && this.shopListLength !== 0) {
|
||||||
this.shopPageNum++
|
this.shopPageNum++
|
||||||
@@ -247,6 +275,7 @@
|
|||||||
uni.authorize({
|
uni.authorize({
|
||||||
scope: 'scope.userFuzzyLocation',
|
scope: 'scope.userFuzzyLocation',
|
||||||
success: function() {
|
success: function() {
|
||||||
|
this.isAuth = true
|
||||||
console.log('授权成功');
|
console.log('授权成功');
|
||||||
uni.getSystemInfo({
|
uni.getSystemInfo({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user