mirror of
https://gitee.com/java110/PropertyApp.git
synced 2026-02-23 21:36:39 +08:00
优化代码
This commit is contained in:
parent
14b8a68b0f
commit
73a8c1bbac
@ -11,26 +11,29 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {getHeaders} from '../../lib/java110/api/SystemApi.js';
|
import {
|
||||||
|
getHeaders
|
||||||
|
} from '../../lib/java110/api/SystemApi.js';
|
||||||
import url from '@/constant/url.js'
|
import url from '@/constant/url.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name:"vcUploadFile",
|
name: "vcUploadFile",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
fileName:'',
|
fileName: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods:{
|
methods: {
|
||||||
_setFileName:function(_fileName){
|
_setFileName: function(_fileName) {
|
||||||
this.fileName = _fileName;
|
this.fileName = _fileName;
|
||||||
},
|
},
|
||||||
_doUploadFile: function() {
|
_doUploadFile: function() {
|
||||||
let _that = this;
|
let _that = this;
|
||||||
uni.chooseMessageFile({
|
// #ifdef H5
|
||||||
|
uni.chooseFile({
|
||||||
count: 1, //默认100
|
count: 1, //默认100
|
||||||
type:'all',
|
type: 'all',
|
||||||
extension: ['.zip','.jpg','.png','.xlsx','.doc','docx','.xls'],
|
extension: ['.zip', '.jpg', '.png', '.xlsx', '.doc', 'docx', '.xls'],
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.tempFiles[0].size / 1024 / 1024 > 20) {
|
if (res.tempFiles[0].size / 1024 / 1024 > 20) {
|
||||||
@ -43,8 +46,27 @@
|
|||||||
_that.resultPath(res.tempFiles[0].path, res.tempFiles[0].name);
|
_that.resultPath(res.tempFiles[0].path, res.tempFiles[0].name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// #endif
|
||||||
|
// #ifndef H5
|
||||||
|
uni.chooseMessageFile({
|
||||||
|
count: 1, //默认100
|
||||||
|
type: 'all',
|
||||||
|
extension: ['.zip', '.jpg', '.png', '.xlsx', '.doc', 'docx', '.xls'],
|
||||||
|
success: (res) => {
|
||||||
|
console.log(res);
|
||||||
|
if (res.tempFiles[0].size / 1024 / 1024 > 20) {
|
||||||
|
_that.$refs.uToast.show({
|
||||||
|
title: '附件大小不能超过20M',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_that.resultPath(res.tempFiles[0].path, res.tempFiles[0].name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
},
|
},
|
||||||
resultPath(path,fileName) {
|
resultPath(path, fileName) {
|
||||||
let _that = this;
|
let _that = this;
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '上传中...',
|
title: '上传中...',
|
||||||
@ -53,7 +75,7 @@
|
|||||||
url: url.uploadVideo,
|
url: url.uploadVideo,
|
||||||
filePath: path,
|
filePath: path,
|
||||||
name: 'uploadFile',
|
name: 'uploadFile',
|
||||||
header:getHeaders(),
|
header: getHeaders(),
|
||||||
formData: {
|
formData: {
|
||||||
// 'user': 'test'
|
// 'user': 'test'
|
||||||
},
|
},
|
||||||
@ -62,14 +84,14 @@
|
|||||||
let obj = JSON.parse(uploadFileRes.data);
|
let obj = JSON.parse(uploadFileRes.data);
|
||||||
_that.fileName = obj.fileName;
|
_that.fileName = obj.fileName;
|
||||||
_that.realFileName = obj.realFileName;
|
_that.realFileName = obj.realFileName;
|
||||||
_that.$emit('uploadFile',obj);
|
_that.$emit('uploadFile', obj);
|
||||||
|
|
||||||
},
|
},
|
||||||
fail:(err) =>{
|
fail: (err) => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon:'none',
|
icon: 'none',
|
||||||
title:'上传失败'
|
title: '上传失败'
|
||||||
})
|
})
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user