//直接调用submitForm方法即可 @click="submitForm"
methods: {
submitForm() {
// console.log(this.FormData);
Api.User.xsrz(this.FormData).then(res => {
console.log(res);
if (res.code === 200) {
uni.showToast({
title: res.msg,
icon: 'success',
duration: 2000,
success: () => {
// 关闭当前页面跳转到个人中心
setTimeout(() => {
uni.redirectTo({ url: '/pages/personal_center/personal_center' })
}, 2000);
}
});
} else {
uni.showToast({
title: res.msg,
icon: 'none',
duration: 2000
});
}
})
},
// 上传资格证书
uploadn_eeds() {
uni.chooseImage({
success: (chooseImageRes) => {
const tempFilePaths = chooseImageRes.tempFilePaths;
uni.showLoading({
title: '文件上传中',
mask: true
})
uni.uploadFile({
url: 'http://localhost:3000/upload/img', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: 'file',//
formData: {
'user': 'test'
},
success: (uploadFileRes) => {
uni.hideLoading();
console.log('上传成功');
let res = JSON.parse(uploadFileRes.data)
this.FormData.professional_certificate_url = res.file.url
}
});
}
});
}
}
Last modification:August 19, 2023
© Allow specification reprint