This commit is contained in:
Mr.jiang 2024-06-25 11:32:16 +08:00
parent 43f2d0ed9d
commit 148e9b7fd8
2 changed files with 46 additions and 48 deletions

View File

@ -322,36 +322,9 @@
}, },
onLoad() { onLoad() {
let that = this let that = this
uni.getLocation({
type: 'gcj02',
geocode: true, //true
highAccuracyExpireTime: 500,
success: function(res) {
console.log(res, '地理位置-----------------------》')
that.latitude = res.latitude
that.longitude = res.longitude
uni.setStorageSync('latitude', res.latitude)
uni.setStorageSync('longitude', res.longitude)
if (that.amap) {
that.amap.setCenter(new AMap.LngLat(res.latitude, res.longitude));
}
if (that.infoWindow) {
that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude));
}
// that.getTypeList();
},
fail: function(e) {
console.log('获取地址失败1', e)
// #ifdef APP-PLUS
that.checkPermission();
// #endif
}
})
that.city = uni.getStorageSync('city') ? uni.getStorageSync('city') : '请选择城市'
that.getBannerList() that.getBannerList()
that.getHomeArtificerList() that.getHomeArtificerList()
that.getKTCityList(); // that.getKTCityList();
that.remen() that.remen()
}, },
onShow() { onShow() {
@ -360,27 +333,24 @@
that.city = uni.getStorageSync('city') ? uni.getStorageSync('city') : '请选择城市' that.city = uni.getStorageSync('city') ? uni.getStorageSync('city') : '请选择城市'
that.token = uni.getStorageSync('token'); that.token = uni.getStorageSync('token');
that.getKTCityList(); that.getKTCityList();
// if (uni.getStorageSync('token')) { if (uni.getStorageSync('token')) {
if (that.latitude && that.longitude) {
// that.getlist()
} else {
uni.getLocation({ uni.getLocation({
type: 'gcj02', type: 'gcj02',
highAccuracyExpireTime: 500,
geocode: true, //true geocode: true, //true
// geocode: true, //true
success: function(res) { success: function(res) {
console.log(res, '地理位置') console.log('地理位置',res)
that.city=res.address.city
that.latitude = res.latitude that.latitude = res.latitude
that.longitude = res.longitude that.longitude = res.longitude
// that.getTypeList(); that.getBannerList()
// that.getlist() that.getHomeArtificerList()
}, },
fail: function() { fail: function() {
console.log('获取地址失败2') console.log('获取地址失败2')
} }
}) })
} }
// }
// that.myId = uni.getStorageSync('userId') // that.myId = uni.getStorageSync('userId')
}, },
methods: { methods: {
@ -565,8 +535,8 @@
isStart: 1, isStart: 1,
status: 1, status: 1,
city: this.city, city: this.city,
longitude:'125.281198', longitude:this.longitude,
latitude:'43.883036', latitude:this.latitude,
page: 1, page: 1,
limit: 3 limit: 3
} }

View File

@ -536,20 +536,21 @@
geocode: true, //true geocode: true, //true
highAccuracyExpireTime: 500, highAccuracyExpireTime: 500,
success: function(res) { success: function(res) {
console.log(res, '地理位置') console.log( '地理位置',res)
that.latitude = res.latitude that.latitude = res.latitude
that.longitude = res.longitude that.longitude = res.longitude
uni.setStorageSync('latitude', res.latitude) uni.setStorageSync('latitude', res.latitude)
uni.setStorageSync('longitude', res.longitude) uni.setStorageSync('longitude', res.longitude)
// if (that.cmap) { if (that.cmap) {
// that.cmap.setCenter(new TMap.LatLng(res.latitude, res.longitude)); that.cmap.setCenter(new TMap.LatLng(res.latitude, res.longitude));
// } }
// if (that.infoWindow) { if (that.infoWindow) {
// that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude)); that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude));
// } }
// if(that.amap){ if(that.amap){
// } }
that.page = 1 that.page = 1
that.getlist() that.getlist()
}, },
@ -589,6 +590,33 @@
that.getTpCount(); that.getTpCount();
that.getTpMy(); that.getTpMy();
if (uni.getStorageSync('token')) { if (uni.getStorageSync('token')) {
uni.getLocation({
type: 'gcj02',
geocode: true, //true
highAccuracyExpireTime: 500,
success: function(res) {
console.log( '地理位置',res)
that.latitude = res.latitude
that.longitude = res.longitude
uni.setStorageSync('latitude', res.latitude)
uni.setStorageSync('longitude', res.longitude)
if (that.cmap) {
that.cmap.setCenter(new TMap.LatLng(res.latitude, res.longitude));
}
if (that.infoWindow) {
that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude));
}
if(that.amap){
}
that.page = 1
that.getlist()
},
fail: function(e) {
console.log('获取地址失败', e)
}
})
that.getIsVip() that.getIsVip()
} }
that.myId = uni.getStorageSync('userId') that.myId = uni.getStorageSync('userId')