export default (url, method, params, formStatus, headers) => {
let token = uni.getStorageSync("userToken")
if (!headers) {
headers = {
"Content-Type": "application/json; charset=utf-8",
'x-ajax': 'json',
'CLIENT-TOC': 'Y',
'x-requested-with': 'XMLHttpRequest',
'Authorization': `${token}`,
}
}
return new Promise((resolve, reject) => {
uni.request({
url: `/api` + url,
method: method,
data: params,
header: headers,
success: function (res) {
let data = res.data;
if (data.code == 403 || data.code == 424) {
setTimeout(() => {
uni.reLaunch({
url: `/pages/login/login`
})
}, 1500)
}
if (data.code == 1) {
uni.showToast({
title: data.msg,
icon: 'none'
})
}
if (formStatus) {
uni.$u.toast(data.msg);
}
resolve(data);
},
fail(err) {
reject(err);
},
});
});
};
import request from "./request";
const newApi = {
async getCouponsPage(data) {
return await request(`/admin/bsmsActivityCoupon/claimCakeCoupons`, 'GET', data, false)
},
async getAuthToken(data) {
return await request(`/admin/oauth2/token?`, 'POST', data, false, {
'Authorization': 'Basic c3RvcmU6c3RvcmU=',
'Content-type': 'application/x-www-form-urlencoded',
'isToken': false,
'CLIENT-TOC': 'Y'
})
},
export default newApi