functionPOST(url, params, success, fail) {
var formId = getFormId();
if (formId) {
params.formId = formId;
}
params.token = token;
params.channel = “xcx_hzm”
params.device_type =
params.platform = “SMALLROUTINE”
params.appid = api.APPID
console.log(‘版本:’ + Edition);
console.log(‘请求路径:’ + url);
console.log(‘POST请求参数:’, params);
wx.request({
method: “POST”
url: ${url}
data: params,
header: {
// ‘Content-Type’: ‘application/x-www-form-urlencoded’,
‘Content-Type’: ‘application/json’
‘Cookie’: ‘token=’ + token,
‘token’: token,
},
success: function(res) {
console.log(‘版本:’ + Edition);
console.log(‘请求路径:’ + url);
console.log(‘POST请求参数:’, params);
console.log(“结果:”, res);
if (res.data.code == 200) {
var data = res.data.data;
// if (data) {
// 请求成功
success(data);
// 返回纯数据
// }
} elseif (res.data.code == 801){
var data=res.data;
success(data);
}
else {
if (res.data.code == 409) {
// 409 分页拉去,为空
success([]);
return
}
if (res.data.code == 402 || res.data.code == 405) {
// 403未登录 401 token过期
console.log(‘登录过期了’
// api.update_token()
login(function(res) {
console.log(‘调用登录’, res)
POST(url, params, success, fail);
}, function(err) {
})
} else {
wx.showModal({
title: ‘系统提示’
content: res.data.msg,
showCancel: false
})
// 按失败返回
fail(res);
}
}
},
fail: function(err) {
console.log(‘版本:’ + Edition);
console.log(‘请求路径:’ + url);
console.log(‘POST请求参数:’, params);
console.log(“请求失败,失败原因:”, err);
fail(err);
}
})