mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-03-22 22:57:20 +08:00
【调整】因腾讯获取高精度坐标接口【wx.getLocation】非常难申请,而导致功能可能受影响,使用【wx.getFuzzyLocation】模糊获取经纬度,但是确实是模糊的,精度不够高,误差有点大;
This commit is contained in:
@@ -128,11 +128,11 @@
|
||||
"optimization": {
|
||||
"subPackages": true
|
||||
},
|
||||
"requiredPrivateInfos" : [ "getLocation", "chooseAddress" ]
|
||||
"requiredPrivateInfos": [ "getFuzzyLocation", "chooseAddress" ]
|
||||
},
|
||||
"h5": {
|
||||
"title": "南山田舍",
|
||||
"domain" : "https://h5.coreshop.coreshop.net",
|
||||
"domain": "https://h5.demo.coreshop.cn",
|
||||
"router": {
|
||||
"base": "./",
|
||||
"mode": "hash"
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
<view slot="right">
|
||||
</view>
|
||||
</u-navbar>
|
||||
|
||||
<view class="coreshop-padding-10" v-if="alert.show">
|
||||
<u-alert :title="alert.title" type="error" :description="alert.description" effect="dark"></u-alert>
|
||||
</view>
|
||||
|
||||
<view class="coreshop-padding-10">
|
||||
<u--form :model="form" :rules="rules" ref="uForm" errorType="message" labelPosition="left" labelWidth="80">
|
||||
<u-form-item label="收货人" prop="name" borderBottom clearValidate>
|
||||
@@ -78,6 +83,9 @@
|
||||
|
||||
<view class="coreshop-bottomBox">
|
||||
<button class="coreshop-btn coreshop-btn-square coreshop-btn-w" @click="delShip" v-if="id && id != 0" :disabled='submitStatus' :loading='submitStatus'>删除</button>
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<button class="coreshop-btn coreshop-btn-square coreshop-btn-b" @click="wechatAddress" hover-class="btn-hover2">从微信获取</button>
|
||||
<!-- #endif -->
|
||||
<button class="coreshop-btn coreshop-btn-square coreshop-btn-b" @click="saveShip" :disabled='submitStatus' :loading='submitStatus'>保存</button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -158,10 +166,15 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
alert: {
|
||||
title: '获取定位失败,请检查是否开启定位功能。',
|
||||
description: '未获取到您的经纬度坐标,我们需要获取您的经纬度坐标,来计算与发货点的配送距离。不然无法开启同城配送计算运费。',
|
||||
closable: true,
|
||||
show: false
|
||||
},
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
const chooseLocation = requirePlugin('chooseLocation');
|
||||
const location = chooseLocation.getLocation();
|
||||
@@ -208,17 +221,32 @@
|
||||
// 获取自己的位置信息
|
||||
getMyLocation() {
|
||||
let _this = this;
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.getFuzzyLocation({
|
||||
type: 'wgs84',
|
||||
success(res) {
|
||||
_this.latitude = res.latitude
|
||||
_this.longitude = res.longitude
|
||||
console.log('当前位置的经度1:' + res);
|
||||
},
|
||||
fail: function () {
|
||||
_this.$u.toast("获取您的经纬度坐标失败")
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: function (res) {
|
||||
_this.longitude = res.longitude;
|
||||
_this.latitude = res.latitude;
|
||||
console.log('当前位置的经度2:' + res);
|
||||
},
|
||||
fail: function () {
|
||||
_this.$u.toast("获取位置信息失败")
|
||||
_this.$u.toast("获取您的经纬度坐标失败")
|
||||
}
|
||||
});
|
||||
|
||||
// #endif
|
||||
},
|
||||
onConfirm(e) {
|
||||
console.log(e);
|
||||
@@ -442,10 +470,33 @@
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
// #ifdef MP-WEIXIN
|
||||
wechatAddress: function () {
|
||||
let _that = this;
|
||||
wx.chooseAddress({
|
||||
success: res => {
|
||||
if (res.errMsg == "chooseAddress:ok") {
|
||||
//获取成功
|
||||
//存储这个收获地区信息到数据库
|
||||
let data = {
|
||||
provinceName: res.provinceName,
|
||||
cityName: res.cityName,
|
||||
countyName: res.countyName,
|
||||
postalCode: res.postalCode
|
||||
};
|
||||
|
||||
console.log(res);
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
this.$refs.uToast.show({ title: '获取微信地址失败', type: 'error' });
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// #endif
|
||||
|
||||
},
|
||||
|
||||
|
||||
@@ -251,30 +251,37 @@
|
||||
},
|
||||
// 查询现在的位置
|
||||
getLocation() {
|
||||
let this_ = this
|
||||
uni.getLocation({
|
||||
// type: 'gcj02', // 返回国测局坐标
|
||||
geocode: true,
|
||||
success: function (res) {
|
||||
this_.initMap(res)
|
||||
//console.log(res);
|
||||
let _this = this;
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.getFuzzyLocation({
|
||||
type: 'wgs84',
|
||||
success(res) {
|
||||
_this.initMap(res)
|
||||
},
|
||||
fail: function (e) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '获取地址失败, 请检查是否开启定位权限~~'
|
||||
})
|
||||
fail: function () {
|
||||
_this.$u.toast("获取您的经纬度坐标失败")
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: function (res) {
|
||||
_this.initMap(res)
|
||||
},
|
||||
fail: function () {
|
||||
_this.$u.toast("获取您的经纬度坐标失败")
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
// 查询现在的位置
|
||||
getOldLocation(longitude, latitude) {
|
||||
let this_ = this;
|
||||
var res = {
|
||||
longitude: longitude,
|
||||
latitude: latitude
|
||||
}
|
||||
this_.initMap(res)
|
||||
this.initMap(res)
|
||||
},
|
||||
// 初始化我的位置
|
||||
async initMap(res) {
|
||||
|
||||
@@ -64,11 +64,52 @@
|
||||
//获取门店列表
|
||||
getStoreAddress() {
|
||||
let _this = this;
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.getFuzzyLocation({
|
||||
type: 'wgs84',
|
||||
success(res) {
|
||||
_this.latitude = res.latitude
|
||||
_this.longitude = res.longitude
|
||||
console.log('当前位置的经度1:' + res);
|
||||
},
|
||||
fail: function () {
|
||||
_this.$u.toast("获取您的经纬度坐标失败")
|
||||
},
|
||||
complete: function (res) {
|
||||
if (!_this.longitude || !_this.latitude) {
|
||||
_this.longitude = '0';
|
||||
_this.latitude = '0';
|
||||
}
|
||||
let data = {
|
||||
'key': _this.key,
|
||||
'longitude': _this.longitude,
|
||||
'latitude': _this.latitude,
|
||||
'page': _this.page,
|
||||
'limit': _this.limit,
|
||||
}
|
||||
_this.$u.api.storeList(data).then(e => {
|
||||
if (e.status) {
|
||||
console.log(e);
|
||||
_this.storeList = [..._this.storeList, ...e.data]
|
||||
} else {
|
||||
_this.$u.toast("门店数据获取失败。");
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: function (res) {
|
||||
_this.longitude = res.longitude;
|
||||
_this.latitude = res.latitude;
|
||||
console.log('当前位置的经度2:' + res);
|
||||
},
|
||||
fail: function () {
|
||||
_this.latitude = 0;
|
||||
_this.longitude = 0;
|
||||
_this.$u.toast("获取您的经纬度坐标失败")
|
||||
},
|
||||
complete: function (res) {
|
||||
let data = {
|
||||
@@ -88,6 +129,7 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,12 +83,50 @@
|
||||
//获取门店列表
|
||||
getStoreList() {
|
||||
let _this = this;
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.getFuzzyLocation({
|
||||
type: 'wgs84',
|
||||
success(res) {
|
||||
_this.latitude = res.latitude
|
||||
_this.longitude = res.longitude
|
||||
console.log('当前位置的经度1:' + res);
|
||||
},
|
||||
fail: function () {
|
||||
_this.$u.toast("获取您的经纬度坐标失败")
|
||||
},
|
||||
complete: function (res) {
|
||||
if (!_this.longitude || !_this.latitude) {
|
||||
_this.longitude = '0';
|
||||
_this.latitude = '0';
|
||||
}
|
||||
let data = {
|
||||
'key': _this.key,
|
||||
'longitude': _this.longitude,
|
||||
'latitude': _this.latitude,
|
||||
'page': _this.page,
|
||||
'limit': _this.limit,
|
||||
}
|
||||
_this.$u.api.storeList(data).then(e => {
|
||||
if (e.status) {
|
||||
console.log(e);
|
||||
_this.storeList = [..._this.storeList, ...e.data]
|
||||
} else {
|
||||
_this.$u.toast("门店数据获取失败。");
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
type: 'wgs84',
|
||||
success: function (res) {
|
||||
_this.longitude = res.longitude;
|
||||
_this.latitude = res.latitude;
|
||||
},
|
||||
fail: function () {
|
||||
_this.$u.toast("获取您的经纬度坐标失败")
|
||||
},
|
||||
complete: function (res) {
|
||||
if (!_this.longitude || !_this.latitude) {
|
||||
_this.longitude = '0';
|
||||
@@ -111,6 +149,7 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
//门店选择
|
||||
selectStore(id, name, mobile, address) {
|
||||
|
||||
@@ -78,6 +78,27 @@
|
||||
// 获取自己的位置信息
|
||||
getMyLocation() {
|
||||
let _this = this;
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.getFuzzyLocation({
|
||||
type: 'wgs84',
|
||||
success(res) {
|
||||
_this.longitude = res.longitude;
|
||||
_this.latitude = res.latitude;
|
||||
_this.getStoreList();
|
||||
},
|
||||
fail: function () {
|
||||
_this.$u.toast("获取您的经纬度坐标失败")
|
||||
},
|
||||
complete: function (res) {
|
||||
if (!_this.longitude || !_this.latitude) {
|
||||
_this.longitude = '0';
|
||||
_this.latitude = '0';
|
||||
}
|
||||
_this.getStoreList();
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: function (res) {
|
||||
@@ -86,26 +107,34 @@
|
||||
_this.getStoreList();
|
||||
},
|
||||
fail: function () {
|
||||
_this.$u.toast("获取位置信息失败")
|
||||
_this.$u.toast("获取您的经纬度坐标失败")
|
||||
},
|
||||
complete: function (res) {
|
||||
if (!_this.longitude || !_this.latitude) {
|
||||
_this.longitude = '0';
|
||||
_this.latitude = '0';
|
||||
}
|
||||
_this.getStoreList();
|
||||
}
|
||||
});
|
||||
|
||||
// #endif
|
||||
},
|
||||
// 获取店铺列表信息
|
||||
getStoreList() {
|
||||
let _this = this;
|
||||
|
||||
let data = {
|
||||
'longitude': _this.longitude,
|
||||
'latitude': _this.latitude,
|
||||
'page': _this.page,
|
||||
'limit': _this.limit,
|
||||
}
|
||||
|
||||
_this.$u.api.storeList(data).then(res => {
|
||||
if (res.status) {
|
||||
_this.storeList = res.data;
|
||||
let storeList = res.data;
|
||||
if (storeList.length > 0) {
|
||||
_this.longitude = storeList[0].longitude;
|
||||
_this.latitude = storeList[0].latitude;
|
||||
for (let i = 0; i < storeList.length; i++) {
|
||||
let mark = {
|
||||
id: storeList[i].id,
|
||||
@@ -117,6 +146,7 @@
|
||||
}
|
||||
_this.covers.push(mark);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_this.$u.toast("门店信息获取失败")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user