增加文件上传组件
parent
781d04dc10
commit
cfb7e9bd5d
|
@ -76,6 +76,7 @@ const form = reactive({
|
|||
|
||||
// 新增图片
|
||||
const afterRead = async (event) => {
|
||||
console.log("event:",event)
|
||||
let name = event.name;
|
||||
let lists = [].concat(event.file);
|
||||
let fileListLen = fileList1.value.length;
|
||||
|
@ -97,7 +98,6 @@ const afterRead = async (event) => {
|
|||
url: store.state.user.QNDomain+result,
|
||||
furl:result
|
||||
});
|
||||
console.log("返回的数据:", store.state.user.QNDomain+result);
|
||||
emit('fileList', fileList1.value);
|
||||
fileListLen++;
|
||||
} catch (error) {
|
||||
|
@ -107,8 +107,18 @@ const afterRead = async (event) => {
|
|||
};
|
||||
|
||||
const uploadFilePromise = async (fileInfo1, name) => {
|
||||
fileInfo.name = store.state.user.phoneType + "_" + name;
|
||||
console.log("fileInfo1:",fileInfo1.name)
|
||||
let fileNameOld = [0,1]
|
||||
if(fileInfo1.name !== undefined){
|
||||
fileNameOld = fileInfo1.name.split('.')
|
||||
}
|
||||
|
||||
fileInfo.name =fileNameOld[0]+"_"+ store.state.user.phoneType + "_" + name;
|
||||
let extension1 = fileInfo1.url.split('.');
|
||||
//防止h5报错
|
||||
if(extension1[1] == null){
|
||||
extension1[1] = fileNameOld[1]
|
||||
}
|
||||
fileInfo.type = fileInfo1.type + "/" + extension1[1];
|
||||
fileInfo.extension = extension1[1];
|
||||
try {
|
||||
|
@ -122,7 +132,17 @@ const uploadFilePromise = async (fileInfo1, name) => {
|
|||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const observer = {
|
||||
next(res){
|
||||
console.log("next:",res)
|
||||
},
|
||||
error(err){
|
||||
console.log("error:",err)
|
||||
},
|
||||
complete(res){
|
||||
console.log("complete:",res)
|
||||
}
|
||||
}
|
||||
const uploadQN = (file) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
</uni-grid-item>
|
||||
</uni-grid>
|
||||
</view>
|
||||
<fileUpload @fileList="handleFileList"></fileUpload>
|
||||
<fileUpload @fileList="handleFileList" ></fileUpload>
|
||||
|
||||
<view class="album" v-for="(item,index) in fileList1" :key="index">
|
||||
<view class="album__avatar">
|
||||
|
@ -87,7 +87,7 @@ import fileUpload from './../common/file/fileUpload/index.vue'
|
|||
import {ref, reactive} from 'vue'
|
||||
import { useStore } from 'vuex';
|
||||
const store = useStore();
|
||||
|
||||
const fileTypeInfo = ref("images,video")
|
||||
const QNDomain = store.state.user.QNDomain
|
||||
const current = ref(0)
|
||||
const swiperDotIndex = ref(0)
|
||||
|
|
Loading…
Reference in New Issue