|
@@ -128,73 +128,73 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
//小程序自带获取定位
|
|
|
- getLocation() {
|
|
|
- let that = this;
|
|
|
- return new Promise((resove, reject) => {
|
|
|
- wx.getLocation({
|
|
|
- success: function (res) {
|
|
|
- resove(res)
|
|
|
- },
|
|
|
- fail: function (res) {
|
|
|
- reject(res)
|
|
|
- that.hideAll()
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
+ // getLocation() {
|
|
|
+ // let that = this;
|
|
|
+ // return new Promise((resove, reject) => {
|
|
|
+ // wx.getLocation({
|
|
|
+ // success: function (res) {
|
|
|
+ // resove(res)
|
|
|
+ // },
|
|
|
+ // fail: function (res) {
|
|
|
+ // reject(res)
|
|
|
+ // that.hideAll()
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // },
|
|
|
//授权后调用百度地图接口获取当前城市
|
|
|
- getLocation(_this) {
|
|
|
- // 微信获得经纬度
|
|
|
- let ak = 'GoI7BxLpfvBEyf1TcMXCloi99Vov7flZ'
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- wx.getLocation({
|
|
|
- type: 'wgs84', //gcj02 // wgs84
|
|
|
- success: function (res) {
|
|
|
- let latitude = res.latitude
|
|
|
- let longitude = res.longitude
|
|
|
- wx.request({
|
|
|
- url: 'https://api.map.baidu.com/reverse_geocoding/v3/?ak=sHZTomd7grslfP7sPKB8tRgT49FK9TEu&output=json&coordtype=gcj02&location=' + latitude + ',' + longitude,
|
|
|
- data: {},
|
|
|
- header: {
|
|
|
- 'Content-Type': 'application/json'
|
|
|
- },
|
|
|
- success: function (ops) {
|
|
|
- let {
|
|
|
- province,
|
|
|
- city,
|
|
|
- district
|
|
|
- } = ops.data.result.addressComponent
|
|
|
- let region = province + city + district
|
|
|
- resolve({
|
|
|
- region,
|
|
|
- latitude,
|
|
|
- longitude
|
|
|
- })
|
|
|
- },
|
|
|
- fail: function (err) {
|
|
|
- wx.showModal({
|
|
|
- title: '信息提示',
|
|
|
- content: '请求失败',
|
|
|
- showCancel: false,
|
|
|
- confirmColor: '#f37938'
|
|
|
- });
|
|
|
- },
|
|
|
- complete: function () { }
|
|
|
- })
|
|
|
- },
|
|
|
- fail(err) {
|
|
|
- wx.showModal({
|
|
|
- title: '未授权',
|
|
|
- content: `为保证功能正常使用,点击「右上角」-「关于**」-「右上角」-「设置」,打开位置权限后重试`,
|
|
|
- showCancel: false,
|
|
|
- })
|
|
|
- resolve()
|
|
|
- },
|
|
|
- complete: (data) => {
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
+ // getLocation(_this) {
|
|
|
+ // // 微信获得经纬度
|
|
|
+ // let ak = 'GoI7BxLpfvBEyf1TcMXCloi99Vov7flZ'
|
|
|
+ // return new Promise((resolve, reject) => {
|
|
|
+ // wx.getLocation({
|
|
|
+ // type: 'wgs84', //gcj02 // wgs84
|
|
|
+ // success: function (res) {
|
|
|
+ // let latitude = res.latitude
|
|
|
+ // let longitude = res.longitude
|
|
|
+ // wx.request({
|
|
|
+ // url: 'https://api.map.baidu.com/reverse_geocoding/v3/?ak=sHZTomd7grslfP7sPKB8tRgT49FK9TEu&output=json&coordtype=gcj02&location=' + latitude + ',' + longitude,
|
|
|
+ // data: {},
|
|
|
+ // header: {
|
|
|
+ // 'Content-Type': 'application/json'
|
|
|
+ // },
|
|
|
+ // success: function (ops) {
|
|
|
+ // let {
|
|
|
+ // province,
|
|
|
+ // city,
|
|
|
+ // district
|
|
|
+ // } = ops.data.result.addressComponent
|
|
|
+ // let region = province + city + district
|
|
|
+ // resolve({
|
|
|
+ // region,
|
|
|
+ // latitude,
|
|
|
+ // longitude
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+ // fail: function (err) {
|
|
|
+ // wx.showModal({
|
|
|
+ // title: '信息提示',
|
|
|
+ // content: '请求失败',
|
|
|
+ // showCancel: false,
|
|
|
+ // confirmColor: '#f37938'
|
|
|
+ // });
|
|
|
+ // },
|
|
|
+ // complete: function () { }
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+ // fail(err) {
|
|
|
+ // wx.showModal({
|
|
|
+ // title: '未授权',
|
|
|
+ // content: `为保证功能正常使用,点击「右上角」-「关于**」-「右上角」-「设置」,打开位置权限后重试`,
|
|
|
+ // showCancel: false,
|
|
|
+ // })
|
|
|
+ // resolve()
|
|
|
+ // },
|
|
|
+ // complete: (data) => {
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // },
|
|
|
//网络错误提示
|
|
|
networkError(status = 0) {
|
|
|
const netMessage = {
|