1
0
mirror of https://github.com/chowa/ejyy.git synced 2026-01-21 05:07:48 +08:00

update chooseFile

This commit is contained in:
AYKM
2022-05-07 16:35:14 +08:00
parent 17be5362bc
commit 8a9090d480
2 changed files with 36 additions and 32 deletions

View File

@@ -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,

View File

@@ -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,