v1.2.1版本,优化调整了很多,整改验收阶段新加字段
This commit is contained in:
@@ -181,7 +181,8 @@ import {
|
||||
updateLicense,
|
||||
deleteLicense
|
||||
} from '@/request/three_one_api/license.js';
|
||||
import { baseUrl, getToken, toImageUrl } from '@/request/request.js';
|
||||
import { toImageUrl } from '@/request/request.js';
|
||||
import { uploadSingleWithLoading } from '@/utils/upload.js';
|
||||
|
||||
// 证照列表
|
||||
const licenseList = ref([]);
|
||||
@@ -435,41 +436,22 @@ const chooseImage = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// 上传图片
|
||||
const uploadImage = (filePath) => {
|
||||
uni.showLoading({ title: '上传中...' });
|
||||
|
||||
uni.uploadFile({
|
||||
url: baseUrl + '/frontend/attachment/upload',
|
||||
filePath: filePath,
|
||||
name: 'file',
|
||||
header: {
|
||||
'Authorization': getToken()
|
||||
},
|
||||
success: (uploadRes) => {
|
||||
uni.hideLoading();
|
||||
try {
|
||||
const data = JSON.parse(uploadRes.data);
|
||||
if (data.code === 0 && data.data) {
|
||||
formData.photo = data.data.url || data.data;
|
||||
uni.showToast({ title: '上传成功', icon: 'success' });
|
||||
} else {
|
||||
uni.showToast({ title: data.msg || '上传失败', icon: 'none' });
|
||||
formData.photoPreview = '';
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('解析上传结果失败:', e);
|
||||
uni.showToast({ title: '上传失败', icon: 'none' });
|
||||
formData.photoPreview = '';
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.hideLoading();
|
||||
console.error('上传失败:', err);
|
||||
uni.showToast({ title: '上传失败', icon: 'none' });
|
||||
formData.photoPreview = '';
|
||||
}
|
||||
});
|
||||
// 上传图片(七牛直传,提交表单时使用完整 URL)
|
||||
const uploadImage = async (filePath) => {
|
||||
try {
|
||||
const { url } = await uploadSingleWithLoading(filePath);
|
||||
formData.photo = url;
|
||||
formData.photoPreview = url;
|
||||
uni.showToast({ title: '上传成功', icon: 'success' });
|
||||
} catch (e) {
|
||||
console.error('上传失败:', e);
|
||||
formData.photo = '';
|
||||
formData.photoPreview = '';
|
||||
uni.showToast({
|
||||
title: e?.msg || e?.message || '上传失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 移除图片
|
||||
|
||||
Reference in New Issue
Block a user