mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
fix(Uploader): replace wx.chooseImage with wx.chooseMedia
This commit is contained in:
parent
e0df0181f2
commit
33a7e55a71
@ -45,13 +45,13 @@ export function isVideoFile(item: File): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatImage(
|
function formatImage(
|
||||||
res: WechatMiniprogram.ChooseImageSuccessCallbackResult
|
res: WechatMiniprogram.ChooseMediaSuccessCallbackResult
|
||||||
): File[] {
|
): File[] {
|
||||||
return res.tempFiles.map((item) => ({
|
return res.tempFiles.map((item) => ({
|
||||||
...pickExclude(item, ['path']),
|
...pickExclude(item, ['path']),
|
||||||
type: 'image',
|
type: 'image',
|
||||||
url: item.path,
|
url: item.tempFilePath,
|
||||||
thumb: item.path,
|
thumb: item.tempFilePath,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,10 +101,13 @@ export function chooseFile({
|
|||||||
return new Promise<File | File[]>((resolve, reject) => {
|
return new Promise<File | File[]>((resolve, reject) => {
|
||||||
switch (accept) {
|
switch (accept) {
|
||||||
case 'image':
|
case 'image':
|
||||||
wx.chooseImage({
|
wx.chooseMedia({
|
||||||
count: multiple ? Math.min(maxCount, 9) : 1,
|
count: multiple ? Math.min(maxCount, 9) : 1,
|
||||||
|
mediaType: ['image'],
|
||||||
sourceType: capture,
|
sourceType: capture,
|
||||||
|
maxDuration,
|
||||||
sizeType,
|
sizeType,
|
||||||
|
camera,
|
||||||
success: (res) => resolve(formatImage(res)),
|
success: (res) => resolve(formatImage(res)),
|
||||||
fail: reject,
|
fail: reject,
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user