Refactor(首页):改版重构-接口对接
This commit is contained in:
@@ -6,6 +6,19 @@ module.exports = {
|
||||
type: 'wgs84'
|
||||
})
|
||||
},
|
||||
getLocationPromise() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
resolve(res)
|
||||
},
|
||||
fail: () => {
|
||||
resolve({})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
getCurAddress(latitude, longitude) {
|
||||
return uni.request({
|
||||
@@ -14,6 +27,51 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
getLocationSetting(cb) {
|
||||
uni.getSetting({
|
||||
success: res => {
|
||||
if (!res.authSetting['scope.userLocation']) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '当前定位未开启,请点击确定手动开启定位',
|
||||
success: response => {
|
||||
if (response.confirm) {
|
||||
cb && cb ()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '您拒绝了授权,无法获取定位服务',
|
||||
duration: 2000,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
openLocationSettting() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.openSetting({
|
||||
success: res => {
|
||||
if (res.authSetting['scope.userLocation']) {
|
||||
resolve()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '您拒绝了授权,无法获取定位服务',
|
||||
duration: 2000,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
reject()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
getUrlParam(url, name) {
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||||
var r = url.match(reg);
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ function baseRequest(options) {
|
||||
// 如果接口需要登录,携带 token 去请求
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
Authorization: "Bearer " + token
|
||||
Authorization: token ? ('Bearer ' + token) : ''
|
||||
}
|
||||
|
||||
// 结构请求需要的参数
|
||||
|
||||
Reference in New Issue
Block a user