选择多张图片
This commit is contained in:
parent
f1032ddef1
commit
110512d9cb
@ -871,7 +871,10 @@ export struct ChatP2PPage {
|
|||||||
},
|
},
|
||||||
onDidClickImage: () => {
|
onDidClickImage: () => {
|
||||||
this.showOperationView = false
|
this.showOperationView = false
|
||||||
MediaUtils.showImageVideoPicker().then((result) => {
|
MediaUtils.showImageVideoPicker().then((results) => {
|
||||||
|
if(results!=null&&results.length>0)
|
||||||
|
{
|
||||||
|
results.forEach(result=>{
|
||||||
if (result.errorMsg == null && result.uri) {
|
if (result.errorMsg == null && result.uri) {
|
||||||
if (result.type === photoAccessHelper.PhotoType.IMAGE) {
|
if (result.type === photoAccessHelper.PhotoType.IMAGE) {
|
||||||
this.chatViewModel.sendImageMessage(result.uri);
|
this.chatViewModel.sendImageMessage(result.uri);
|
||||||
@ -880,6 +883,9 @@ export struct ChatP2PPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
},
|
},
|
||||||
onDidClickAudio: () => {
|
onDidClickAudio: () => {
|
||||||
this.showOperationView = false
|
this.showOperationView = false
|
||||||
@ -1018,7 +1024,10 @@ export struct ChatP2PPage {
|
|||||||
})
|
})
|
||||||
} else if (data.type == NEChatMoreOperationType.Image) {
|
} else if (data.type == NEChatMoreOperationType.Image) {
|
||||||
this.showOperationView = false
|
this.showOperationView = false
|
||||||
MediaUtils.showImageVideoPicker().then((result) => {
|
MediaUtils.showImageVideoPicker().then((results) => {
|
||||||
|
if(results!=null&&results.length>0)
|
||||||
|
{
|
||||||
|
results.forEach(result=>{
|
||||||
if (result.errorMsg == null && result.uri) {
|
if (result.errorMsg == null && result.uri) {
|
||||||
if (result.type === photoAccessHelper.PhotoType.IMAGE) {
|
if (result.type === photoAccessHelper.PhotoType.IMAGE) {
|
||||||
this.chatViewModel.sendImageMessage(result.uri);
|
this.chatViewModel.sendImageMessage(result.uri);
|
||||||
@ -1027,6 +1036,15 @@ export struct ChatP2PPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
// if (result.errorMsg == null && result.uri) {
|
||||||
|
// if (result.type === photoAccessHelper.PhotoType.IMAGE) {
|
||||||
|
// this.chatViewModel.sendImageMessage(result.uri);
|
||||||
|
// } else if (result.type === photoAccessHelper.PhotoType.VIDEO) {
|
||||||
|
// this.chatViewModel.sendVideoMessage(result.uri, result.duration, result.width, result.height);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (data.type == NEChatMoreOperationType.Reply) {
|
else if (data.type == NEChatMoreOperationType.Reply) {
|
||||||
|
|||||||
@ -778,15 +778,15 @@ export struct ChatTeamPage {
|
|||||||
},
|
},
|
||||||
onDidClickImage: () => {
|
onDidClickImage: () => {
|
||||||
this.showOperationView = false
|
this.showOperationView = false
|
||||||
MediaUtils.showImageVideoPicker().then((result) => {
|
// MediaUtils.showImageVideoPicker().then((result) => {
|
||||||
if (result.errorMsg == null && result.uri) {
|
// if (result.errorMsg == null && result.uri) {
|
||||||
if (result.type === photoAccessHelper.PhotoType.IMAGE) {
|
// if (result.type === photoAccessHelper.PhotoType.IMAGE) {
|
||||||
this.chatViewModel.sendImageMessage(result.uri);
|
// this.chatViewModel.sendImageMessage(result.uri);
|
||||||
} else if (result.type === photoAccessHelper.PhotoType.VIDEO) {
|
// } else if (result.type === photoAccessHelper.PhotoType.VIDEO) {
|
||||||
this.chatViewModel.sendVideoMessage(result.uri, result.duration, result.width, result.height);
|
// this.chatViewModel.sendVideoMessage(result.uri, result.duration, result.width, result.height);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
},
|
},
|
||||||
onDidClickAudio: () => {
|
onDidClickAudio: () => {
|
||||||
let context = getContext(this) as common.UIAbilityContext
|
let context = getContext(this) as common.UIAbilityContext
|
||||||
|
|||||||
@ -57,6 +57,38 @@ export class MediaUtils {
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
static async showMediaPickerMore(mimeType: photoAccessHelper.PhotoViewMIMETypes): Promise<SelectResult[]> {
|
||||||
|
console.log("net ease show photo picker");
|
||||||
|
const result: SelectResult[] = await new Promise((resolve: Function) => {
|
||||||
|
const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
|
||||||
|
// 过滤选择媒体文件类型为IMAGE
|
||||||
|
photoSelectOptions.MIMEType = mimeType;
|
||||||
|
// 选择媒体文件的最大数目
|
||||||
|
photoSelectOptions.maxSelectNumber = 5;
|
||||||
|
const photoViewPicker = new photoAccessHelper.PhotoViewPicker();
|
||||||
|
photoViewPicker.select(photoSelectOptions)
|
||||||
|
.then(async (photoSelectResult: photoAccessHelper.PhotoSelectResult) => {
|
||||||
|
const context = getContext(photoSelectOptions)
|
||||||
|
const uri = photoSelectResult.photoUris;
|
||||||
|
let selectResult:SelectResult[]=[]
|
||||||
|
// const uri = photoSelectResult.photoUris[0];
|
||||||
|
await uri.forEach(async values=>{
|
||||||
|
selectResult.push(await MediaUtils.getMediaInfo(context, values))
|
||||||
|
})
|
||||||
|
// const selectResult = MediaUtils.getMediaInfo(context, uri)
|
||||||
|
resolve(selectResult);
|
||||||
|
})
|
||||||
|
.catch((err: BusinessError) => {
|
||||||
|
console.error(`net ease Invoke photoViewPicker.select failed, code is ${err.code}, message is ${err.message}`);
|
||||||
|
const selectResult = new SelectResult();
|
||||||
|
selectResult.errorMsg =
|
||||||
|
`net ease Invoke photoViewPicker.select failed, code is ${err.code}, message is ${err.message}`;
|
||||||
|
resolve(selectResult);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 显示相册(图片)选择器
|
// 显示相册(图片)选择器
|
||||||
static async showImagePicker(): Promise<SelectResult> {
|
static async showImagePicker(): Promise<SelectResult> {
|
||||||
@ -73,9 +105,9 @@ export class MediaUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 显示相册(图片+视频)选择器
|
// 显示相册(图片+视频)选择器
|
||||||
static async showImageVideoPicker(): Promise<SelectResult> {
|
static async showImageVideoPicker(): Promise<SelectResult[]> {
|
||||||
console.log("net ease show photo picker");
|
console.log("net ease show photo picker");
|
||||||
const result: SelectResult = await MediaUtils.showMediaPicker(photoAccessHelper.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE)
|
const result: SelectResult[] = await MediaUtils.showMediaPickerMore(photoAccessHelper.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user