function uploadPhotoCheck(that, userInfoObj, width, height, color, render, setType, filePath) {
console.log('上传照片: ', userInfoObj)
return new Promise((resolve, reject) => {
uni.uploadFile({
url: that.$baseUrl + '/api/Upload/UploadCheckImg',
filePath: filePath,
name: 'file',
formData: {
userId: userInfoObj.userId,
color: color,
width: width,
height: height,
render: render,
kb: 50,
setType: setType,
},
success: (res) => {
if (res.statusCode === 200) {
resolve(JSON.parse(res.data));
} else if (res.statusCode === 401) {
uni.showToast({
icon: 'none',
title: "未登录或登录状态已超时",
duration: 1500
});
resolve(new Error("未登录或登录状态已超时"));
} else if (res.statusCode === 405) {
uni.showToast({
icon: 'none',
title: "请求方法错误",
duration: 1500
});
resolve(new Error("请求方法错误"));
} else {
uni.showToast({
icon: 'none',
title: "请求错误" + res.statusCode,
duration: 1500
});
resolve(new Error("请求错误" + res.statusCode));
}
},
fail: (err) => {
console.log("err:", err.errMsg);
uni.showToast({
icon: 'none',
title: '系统异常:文件上传失败!',
duration: 1500
});
reject(err);
}
});
})
}
代码执行字节报错
这个和微信无关,你检查一下自己服务器吧,链接失败得嘛,或者你配置的请求域名和使用的不是同一个