✨ 文件的上传:100%
parent
bc6ac22ce2
commit
b53bfd468c
|
@ -1,5 +1,3 @@
|
||||||
import request2 from '@/sheep/request2';
|
|
||||||
|
|
||||||
const FileApi = {
|
const FileApi = {
|
||||||
// 上传文件
|
// 上传文件
|
||||||
uploadFile: (file) => {
|
uploadFile: (file) => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
import sheep from '@/sheep';
|
import FileApi from '@/sheep/api/infra/file';
|
||||||
|
|
||||||
const ERR_MSG_OK = 'chooseAndUploadFile:ok';
|
const ERR_MSG_OK = 'chooseAndUploadFile:ok';
|
||||||
const ERR_MSG_FAIL = 'chooseAndUploadFile:fail';
|
const ERR_MSG_FAIL = 'chooseAndUploadFile:fail';
|
||||||
|
@ -190,8 +190,8 @@ function uploadFiles(choosePromise, { onChooseFile, onUploadProgress }) {
|
||||||
})
|
})
|
||||||
.then(async (files) => {
|
.then(async (files) => {
|
||||||
for (let file of files.tempFiles) {
|
for (let file of files.tempFiles) {
|
||||||
let { path } = await sheep.$api.app.upload(file.path, 'ugc');
|
const { data } = await FileApi.uploadFile(file.path);
|
||||||
file.url = path;
|
file.url = data;
|
||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<!-- 文件上传,基于 upload-file 和 upload-image 实现 -->
|
||||||
<template>
|
<template>
|
||||||
<view class="uni-file-picker">
|
<view class="uni-file-picker">
|
||||||
<view v-if="title" class="uni-file-picker__header">
|
<view v-if="title" class="uni-file-picker__header">
|
||||||
|
|
Loading…
Reference in New Issue