let URLALL = ‘https://mp1.zhupinhr.com/api‘;
function request (url, method, data, head, dataType, doSuccess, doFail, doComplete) {
let header
if (head == 0) {
header = {
‘Content-Type‘: ‘appliaction/json‘,
‘cookie‘: wx.getStorageSync(‘cookieKey‘),
}
} else if (head == 1) {
header = {
‘Content-Type‘: ‘application/x-www-form-urlencoded‘,
‘cookie‘: wx.getStorageSync(‘cookieKey‘),
}
}
// let promise = new Promise(function (resolve, reject) {
wx.request({
url: URLALL + url,
data: data,
header: header,
method: method,
dataType: dataType,
responseType: ‘text‘,
// success: resolve,
// fail: reject
success: (res) => {
if (typeof doSuccess == "function") {
doSuccess(res);
}
},
fail: (res) => {
if (typeof doFail == "function") {
doFail(res);
}
},
complete: (res) => {
if (typeof doComplete == "function") {
doComplete(res);
}
},
})
// })
// return promise
};
let URLALL1 = ‘https://mp1.zhupinhr.com‘
function ajax(url, method, data, head, dataType, doSuccess, doFail, doComplete) {
let header
if (head == 0) {
header = {
‘Content-Type‘: ‘appliaction/json‘,
‘cookie‘: wx.getStorageSync(‘cookieKey‘),
}
} else if (head == 1) {
header = {
‘Content-Type‘: ‘application/x-www-form-urlencoded‘,
‘cookie‘: wx.getStorageSync(‘cookieKey‘),
}
}
wx.request({
url: URLALL1 + url,
data: data,
header: header,
method: method,
dataType: dataType,
responseType: ‘text‘,
success: (res) => {
if (typeof doSuccess == "function") {
doSuccess(res);
}
},
fail: (res) => {
if (typeof doFail == "function") {
doFail(res);
}
},
complete: (res) => {
if (typeof doComplete == "function") {
doComplete(res);
}
},
})
};
module.exports = {
request: request,
ajax: ajax
}