|
|
@@ -58,15 +58,28 @@
|
|
|
const userInfo = ref(null)
|
|
|
|
|
|
const save = () => {
|
|
|
+ userInfo.value.avatarPath = fileList.value[0]?.url||''
|
|
|
if(!userInfo.value?.avatarPath) return proxy.$showToast('请上传用户头像')
|
|
|
if(!userInfo.value?.realName) return proxy.$showToast('请输入用户名')
|
|
|
// if(!proxy.$reg.mobile(userInfo.value.phone)) return proxy.$showToast('请输入正确的手机号')
|
|
|
if(!userInfo.value?.welfareName) return proxy.$showToast('请输入家庭公益名称')
|
|
|
if(!userInfo.value?.welfareSlogan) return proxy.$showToast('请输入家庭公益口号')
|
|
|
+
|
|
|
+ userInfo.value.id = uni.getStorageSync('userInfo')&&JSON.parse(uni.getStorageSync('userInfo')).id;
|
|
|
+ proxy.$api.put('/wx/update',userInfo.value).then(({data:res})=>{
|
|
|
+ if(res.code!==0) return proxy.$showToast(res.msg)
|
|
|
+ proxy.$showToast('保存成功')
|
|
|
+ setTimeout(()=>{
|
|
|
+ uni.reLaunch({
|
|
|
+ url:'/pages/my'
|
|
|
+ })
|
|
|
+ },1000)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const deletePic = (event) => {
|
|
|
fileList.value.splice(event.index, 1);
|
|
|
+ userInfo.value.avatarPath = '';
|
|
|
};
|
|
|
|
|
|
// 新增图片
|
|
|
@@ -83,13 +96,15 @@
|
|
|
});
|
|
|
for (let i = 0; i < lists.length; i++) {
|
|
|
const result = await uploadFilePromise(lists[i].url);
|
|
|
- let item = fileList.value[fileListLen];
|
|
|
- fileList.value.splice(fileListLen, 1, {
|
|
|
- ...item,
|
|
|
- status: 'success',
|
|
|
- message: '',
|
|
|
- url: result,
|
|
|
- });
|
|
|
+ if(result){
|
|
|
+ let item = fileList.value[fileListLen];
|
|
|
+ fileList.value.splice(fileListLen, 1, {
|
|
|
+ ...item,
|
|
|
+ status: 'success',
|
|
|
+ message: '',
|
|
|
+ url: result,
|
|
|
+ });
|
|
|
+ }
|
|
|
fileListLen++;
|
|
|
}
|
|
|
};
|
|
|
@@ -97,17 +112,20 @@
|
|
|
const uploadFilePromise = (url) => {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
let a = uni.uploadFile({
|
|
|
- url: BaseApi+'/uploadFile', // 仅为示例,非真实的接口地址
|
|
|
+ url: BaseApi+'/uploadFile',
|
|
|
filePath: url,
|
|
|
name: 'file',
|
|
|
- formData: {
|
|
|
- user: 'test',
|
|
|
- },
|
|
|
success: (res) => {
|
|
|
setTimeout(() => {
|
|
|
- resolve(res.data.data);
|
|
|
+ let data = JSON.parse(res.data)
|
|
|
+ if(data&&data.code===0){
|
|
|
+ resolve(data.data);
|
|
|
+ }else proxy.$showToast(data?.msg)
|
|
|
}, 1000);
|
|
|
},
|
|
|
+ fail: err =>{
|
|
|
+ resolve('');
|
|
|
+ }
|
|
|
});
|
|
|
});
|
|
|
};
|