mirror of
https://github.com/chowa/ejyy.git
synced 2026-01-21 05:07:48 +08:00
update chooseFile
This commit is contained in:
@@ -37,22 +37,22 @@ export function isVideoFile(item) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function formatImage(res) {
|
function formatImage(res) {
|
||||||
return res.tempFiles.map(item =>
|
return res.tempFiles.map(item =>
|
||||||
Object.assign(Object.assign({}, pickExclude(item, ['path'])), {
|
Object.assign(Object.assign({}, pickExclude(item, ['tempFilePath'])), {
|
||||||
type: 'image',
|
type: 'image',
|
||||||
url: item.path,
|
url: item.tempFilePath,
|
||||||
thumb: item.path
|
thumb: item.tempFilePath
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
function formatVideo(res) {
|
function formatVideo(res) {
|
||||||
return [
|
return res.tempFiles.map(item =>
|
||||||
Object.assign(Object.assign({}, pickExclude(res, ['tempFilePath', 'thumbTempFilePath', 'errMsg'])), {
|
Object.assign(Object.assign({}, pickExclude(item, ['tempFilePath', 'thumbTempFilePath', 'errMsg'])), {
|
||||||
type: 'video',
|
type: 'image',
|
||||||
url: res.tempFilePath,
|
url: item.tempFilePath,
|
||||||
thumb: res.thumbTempFilePath
|
thumb: item.thumbTempFilePath
|
||||||
})
|
})
|
||||||
];
|
);
|
||||||
}
|
}
|
||||||
function formatMedia(res) {
|
function formatMedia(res) {
|
||||||
return res.tempFiles.map(item =>
|
return res.tempFiles.map(item =>
|
||||||
@@ -74,7 +74,8 @@ export function chooseFile({ accept, multiple, capture, compressed, maxDuration,
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
switch (accept) {
|
switch (accept) {
|
||||||
case 'image':
|
case 'image':
|
||||||
wx.chooseImage({
|
wx.chooseMedia({
|
||||||
|
mediaType: ['image'],
|
||||||
count: multiple ? Math.min(maxCount, 9) : 1,
|
count: multiple ? Math.min(maxCount, 9) : 1,
|
||||||
sourceType: capture,
|
sourceType: capture,
|
||||||
sizeType,
|
sizeType,
|
||||||
@@ -94,7 +95,8 @@ export function chooseFile({ accept, multiple, capture, compressed, maxDuration,
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'video':
|
case 'video':
|
||||||
wx.chooseVideo({
|
wx.chooseMedia({
|
||||||
|
mediaType: ['video'],
|
||||||
sourceType: capture,
|
sourceType: capture,
|
||||||
compressed,
|
compressed,
|
||||||
maxDuration,
|
maxDuration,
|
||||||
|
|||||||
@@ -37,22 +37,22 @@ export function isVideoFile(item) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function formatImage(res) {
|
function formatImage(res) {
|
||||||
return res.tempFiles.map(item =>
|
return res.tempFiles.map(item =>
|
||||||
Object.assign(Object.assign({}, pickExclude(item, ['path'])), {
|
Object.assign(Object.assign({}, pickExclude(item, ['tempFilePath'])), {
|
||||||
type: 'image',
|
type: 'image',
|
||||||
url: item.path,
|
url: item.tempFilePath,
|
||||||
thumb: item.path
|
thumb: item.tempFilePath
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
function formatVideo(res) {
|
function formatVideo(res) {
|
||||||
return [
|
return res.tempFiles.map(item =>
|
||||||
Object.assign(Object.assign({}, pickExclude(res, ['tempFilePath', 'thumbTempFilePath', 'errMsg'])), {
|
Object.assign(Object.assign({}, pickExclude(item, ['tempFilePath', 'thumbTempFilePath', 'errMsg'])), {
|
||||||
type: 'video',
|
type: 'image',
|
||||||
url: res.tempFilePath,
|
url: item.tempFilePath,
|
||||||
thumb: res.thumbTempFilePath
|
thumb: item.thumbTempFilePath
|
||||||
})
|
})
|
||||||
];
|
);
|
||||||
}
|
}
|
||||||
function formatMedia(res) {
|
function formatMedia(res) {
|
||||||
return res.tempFiles.map(item =>
|
return res.tempFiles.map(item =>
|
||||||
@@ -74,7 +74,8 @@ export function chooseFile({ accept, multiple, capture, compressed, maxDuration,
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
switch (accept) {
|
switch (accept) {
|
||||||
case 'image':
|
case 'image':
|
||||||
wx.chooseImage({
|
wx.chooseMedia({
|
||||||
|
mediaType: ['image'],
|
||||||
count: multiple ? Math.min(maxCount, 9) : 1,
|
count: multiple ? Math.min(maxCount, 9) : 1,
|
||||||
sourceType: capture,
|
sourceType: capture,
|
||||||
sizeType,
|
sizeType,
|
||||||
@@ -94,7 +95,8 @@ export function chooseFile({ accept, multiple, capture, compressed, maxDuration,
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'video':
|
case 'video':
|
||||||
wx.chooseVideo({
|
wx.chooseMedia({
|
||||||
|
mediaType: ['video'],
|
||||||
sourceType: capture,
|
sourceType: capture,
|
||||||
compressed,
|
compressed,
|
||||||
maxDuration,
|
maxDuration,
|
||||||
|
|||||||
Reference in New Issue
Block a user