You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

69 lines
2.3 KiB

const baseURL = 'https://yoursairdata.com/api/applets/map/'
// const baseURL = 'http://47.108.164.110:8080/'
const GET = 'GET';
const POST = 'POST';
const PUT = 'PUT';
const FORM = 'FORM';
const DELETE = 'DELETE';
function request(method, url, data, hasToke = true) {
let token = wx.getStorageSync('access_token')
let Authorization = token && hasToke ? `Bearer ${token}` : 'Basic YXBwOmFwcA==';
// console.log(Authorization)
// console.log(method,url, data,hasToke)
return new Promise(function (resolve, reject) {
let header = {
'content-type': 'application/json',
'Authorization': Authorization,
};
wx.request({
url: baseURL + url,
method: method,
data: method === POST ? JSON.stringify(data) : data,
header: header,
success(res) {
// console.log(res);
if (res.statusCode == 401) {
wx.showToast({
title: '登录过期,请重新登录',
icon: "none",
mask: true,
})
wx.clearStorage();
setTimeout(() => {
wx.navigateTo({
url: "/pages/auth/auth",
})
}, 1500)
} else {
resolve(res.data);
}
},
fail(err) {
//请求失败
reject(err)
}
})
})
}
const API = {
getLandListing: (data) => request(GET, `getLandListing`, data), //已出让
getLandList: (data) => request(GET, `getLandList`, data), //挂牌中
getRegionByLocation: (data) => request(GET, `getRegionByLocation`, data), //行政区
getLandToList: (data) => request(GET, `getLandToList`, data), //待挂牌
getFacilitiesByLocation: (data) => request(GET, `getFacilitiesByLocation`, data), //配套
getLoopLine: (data) => request(GET, `getLoopLine`, data), //环线
getTypeRegionByLocation: (data) => request(GET, `getTypeRegionByLocation`, data), //大组团或者小组团
AJAX: (GET, url, data, is_token) => request(GET, url, data, is_token),
};
module.exports = {
API: API
}