工作端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
860 B

1 month ago
const baseUrl = 'http://219.146.91.110:30801/mz-api';
export const request = (options) => {
return new Promise((resolve, reject) => {
uni.request({
url: baseUrl + options.url, // 拼接完整接口地址
method: options.method , // 默认 GET 请求
data: options.data || {}, // 请求参数
header: {
'Content-Type': 'application/json',
Authorization: uni.getStorageSync('token') || '', // 携带 Token
},
success: (res) => {
if (res.statusCode === 200) {
resolve(res.data); // 请求成功返回数据
} else {
uni.showToast({ title: res.data.message || '请求失败', icon: 'none' });
reject(res);
}
},
fail: (err) => {
uni.showToast({ title: '网络异常', icon: 'none' });
reject(err);
},
});
});
};