|
|
|
// const baseURL = 'https://yoursairdata.com/api/'
|
|
|
|
const baseURL = 'http://192.168.27.11:9002/'
|
|
|
|
const defaultCity = '重庆'
|
|
|
|
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==';
|
|
|
|
if (method.toUpperCase() === GET) {
|
|
|
|
let city = wx.getStorageSync('city')
|
|
|
|
city = city ? city : defaultCity
|
|
|
|
if (url.indexOf('?') !== -1) {
|
|
|
|
url += `&city=${city}`
|
|
|
|
} else {
|
|
|
|
url += `?city=${city}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let start = new Date().getTime();
|
|
|
|
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) {
|
|
|
|
let time = (new Date().getTime() - start) / 1000;
|
|
|
|
console.log(url + "耗时=====》" + time);
|
|
|
|
if (res.statusCode == 401) {
|
|
|
|
wx.showToast({
|
|
|
|
title: '登录过期,请重新登录',
|
|
|
|
icon: "none",
|
|
|
|
mask: true,
|
|
|
|
})
|
|
|
|
wx.clearStorage();
|
|
|
|
wx.navigateTo({
|
|
|
|
url: "/pages/auth/auth",
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
resolve(res.data);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fail(err) {
|
|
|
|
//请求失败
|
|
|
|
reject(err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 登录方法
|
|
|
|
function requestLogin(method, url, data) {
|
|
|
|
let Authorization = 'Basic YXBwOmFwcA==';
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
let header = {
|
|
|
|
'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
'Authorization': Authorization,
|
|
|
|
};
|
|
|
|
wx.request({
|
|
|
|
url: baseURL + url,
|
|
|
|
method: method,
|
|
|
|
data: data,
|
|
|
|
header: header,
|
|
|
|
success(res) {
|
|
|
|
resolve(res.data);
|
|
|
|
},
|
|
|
|
fail(err) {
|
|
|
|
//请求失败
|
|
|
|
reject(err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const API = {
|
|
|
|
getOpenid: (data) => request(GET, `oauth/token?grant_type=password&username=${data.admin}&password=${data.password}`),
|
|
|
|
getUserAuth: (data) => request(POST, `social/token?code=MINI@${data}`, '', false),
|
|
|
|
registerBind: (data) => request(POST, `social/register-bind`, data, false),
|
|
|
|
getUserInfo: () => request(GET, `user/info`), //获取用户信息
|
|
|
|
//字典
|
|
|
|
getDict: (data) => request(GET, `dict/type/${data}`),
|
|
|
|
//日历
|
|
|
|
calendar: (date) => request(GET, `applets/landlisted/calendar?date=${date}`, false), //日历
|
|
|
|
getLandlistedList: (data) => request(GET, `applets/landlisted/list?annoDate=${data.annoDate}&size=9999`, false), //挂牌
|
|
|
|
getLandlistedList2: (data) => request(GET, `applets/landlisted/list?auctionDate=${data.auctionDate}&size=9999`, false), //拍卖
|
|
|
|
getLandDetail: (data) => request(GET, `applets/landlisted/${data}`), //通过ID获取详情
|
|
|
|
getPreSaleDetailList: (data) => request(GET, `applets/blocks/getPreSaleDetailList?landListedId=${data.landListedId}`), //查询预售明细列表
|
|
|
|
getPreSaleTotal: (data) => request(GET, `applets/blocks/getPreSaleTotal?landListedId=${data.landListedId}`), //销售情况统计
|
|
|
|
//测算
|
|
|
|
getCalulaList: (data) => request(GET, `applets/measuredata/page?queryDate=${data.queryDate}¤t=${data.current}&size=${data.size}&landListedId=${data.landListedId}`), //分页
|
|
|
|
getCalulaDeatail: (data) => request(GET, `applets/measuredata/getByLandListedId/${data}`), //通过地块ID获取测算详情
|
|
|
|
//看地
|
|
|
|
getLandlistedPage: (data) => request(GET, `applets/landlisted/page?startDate=${data.startDate}¤t=${data.current}&size=${data.size}&measureStatus=${data.measureStatus}&transactionStatus=${data.transactionStatus}&canton=${data.canton}&landCode=${data.landCode}&endDate=${data.endDate}`), //分页
|
|
|
|
//消息管理
|
|
|
|
getMessage: (data) => request(GET, `applets/message/page?current=${data.current}&size=${data.size}&messageType=${data.messageType}`), //分页
|
|
|
|
//意见反馈
|
|
|
|
feedback: (data) => request(POST, `feedback`, data, true), //提交意见
|
|
|
|
uploadImg: (data) => request(POST, `file`, data, false), //图片上传
|
|
|
|
//保存测算数据
|
|
|
|
measureData: (data) => request(POST, `applets/measuredata`, data, true), //保存测算数据
|
|
|
|
AJAX: (GET, url, data, is_toke) => request(GET, url, data, is_toke),
|
|
|
|
Login: (GET, url, data) => requestLogin(GET, url, data),
|
|
|
|
getCityList: () => request(GET, 'cityArea/city', false),
|
|
|
|
getAreaList: (city) => request(GET, `cityArea/getArea/${city}`)
|
|
|
|
};
|
|
|
|
module.exports = {
|
|
|
|
API: API,
|
|
|
|
baseURL: baseURL,
|
|
|
|
request: request
|
|
|
|
}
|