You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
949 B
JavaScript

import {
BASE_URL
} from "@/common/baseurl.js"
export const request = (url, data, method) => {
return new Promise((resolve, reject) => {
uni.showLoading({
mask: true,
title: "加载中",
});
uni.request({
url: BASE_URL + url,
data: data,
header: {
1 year ago
// 'content-type': 'application/json',
'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
// 'content-type':'multipart/form-data',
},
method,
success: (res) => {
if (res) {
uni.hideLoading()
}
if (!res.code == 200) {
console.log('错误的url' + url);
}
resolve(res.data)
},
fail: (err) => {
uni.showLoading({
mask: true,
title: "加载中",
})
if (err) {
uni.hideLoading()
uni.showToast({
icon: "none",
title: "网络异常!"
})
}
if (err) {
console.log(" 错误信息接口URL" + BASE_URL + url);;
}
reject(err)
}
})
})
}