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

4 years ago
const baseURL = 'https://yoursairdata.com/api/applets/map/'
4 years ago
// const baseURL = 'http://47.108.164.110:8080/'
4 years ago
const GET = 'GET';
const POST = 'POST';
const PUT = 'PUT';
const FORM = 'FORM';
const DELETE = 'DELETE';
4 years ago
function request(method, url, data, hasToke = true) {
4 years ago
let token = wx.getStorageSync('access_token')
let Authorization = token && hasToke ? `Bearer ${token}` : 'Basic YXBwOmFwcA==';
4 years ago
4 years ago
// console.log(Authorization)
// console.log(method,url, data,hasToke)
4 years ago
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)
}
})
4 years ago
})
}
const API = {
4 years ago
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),
4 years ago
};
module.exports = {
4 years ago
API: API
4 years ago
}