|
@@ -71,62 +71,64 @@
|
|
|
})
|
|
|
|
|
|
function handleSelect(e) {
|
|
|
- doUploadImage(e.tempFilePaths[0])
|
|
|
+ console.log('eee',e)
|
|
|
+ doUploadImage(e)
|
|
|
}
|
|
|
|
|
|
function genderSelect(genderValue){
|
|
|
data.gender = genderValue;
|
|
|
}
|
|
|
|
|
|
- function doUploadImage(filePath) {
|
|
|
- const loading = uni.showLoading({
|
|
|
- title: '上传中...',
|
|
|
- mask: true
|
|
|
- });
|
|
|
+ function doUploadImage(params) {
|
|
|
+ const filePath = params.tempFiles[0];
|
|
|
+ const fileUrl = params.tempFilePaths;
|
|
|
|
|
|
+
|
|
|
try {
|
|
|
- const suffix = filePath.split('.').pop();
|
|
|
+ const suffix = filePath.file.name.split('.').pop();
|
|
|
let req = {
|
|
|
prefix: 'resource/',
|
|
|
- suffix: suffix
|
|
|
+ suffix: suffix,
|
|
|
}
|
|
|
-
|
|
|
+ uni.showLoading({
|
|
|
+ title: '上传中...',
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
getAliyunPolicy(req).then(res => {
|
|
|
if (res.code == 0) {
|
|
|
const policyData = res.data;
|
|
|
+
|
|
|
const formData = {
|
|
|
- key: policyData.key,
|
|
|
- policy: policyData.policy,
|
|
|
- OSSAccessKeyId: policyData.accessid,
|
|
|
- signature: policyData.signature,
|
|
|
- success_action_status: '200',
|
|
|
- file: {
|
|
|
- name: policyData.key,
|
|
|
- uri: filePath
|
|
|
- }
|
|
|
- };
|
|
|
+ key: policyData.key,
|
|
|
+ policy: policyData.policy,
|
|
|
+ signature: policyData.signature,
|
|
|
+ OSSAccessKeyId: policyData.accessid,
|
|
|
+ success_action_status: '200',
|
|
|
+ }
|
|
|
+
|
|
|
uni.uploadFile({
|
|
|
url: policyData.uploadUrl,
|
|
|
- filePath: filePath,
|
|
|
+ filePath: fileUrl[0],
|
|
|
name: 'file',
|
|
|
formData: formData,
|
|
|
- header: {
|
|
|
- 'Content-Type': 'multipart/form-data'
|
|
|
- },
|
|
|
success(uploadRes) {
|
|
|
if (uploadRes.statusCode === 200) {
|
|
|
+ console.log('uploadRes',uploadRes)
|
|
|
data.icon = `${policyData.downloadUrl}/${policyData.key}`;
|
|
|
+ console.log( `${policyData.downloadUrl}/${policyData.key}`)
|
|
|
uni.showToast({
|
|
|
title: '上传成功',
|
|
|
icon: 'success'
|
|
|
});
|
|
|
+
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
title: '上传失败',
|
|
|
});
|
|
|
+ uni.hideLoading();
|
|
|
}
|
|
|
- uni.hideLoading();
|
|
|
+
|
|
|
},
|
|
|
fail(err) {
|
|
|
uni.showToast({
|