Commit ff55d339 authored by 王建威's avatar 王建威

压缩图片

parent 6f3f8eb4
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
<view class="apply_desc">支持(zip/rar)格式</view> <view class="apply_desc">支持(zip/rar)格式</view>
</view> </view>
<view class="apply_data_item"> <view class="apply_data_item">
<view class="apply_upload" v-if="!params.bank_card_record" @click="uploadZip('bank_card_record')"> <view class="apply_upload" v-if="!params.bank_card_record" ref="compress">
<text class="eosfont icons">&#xe60d;</text> <text class="eosfont icons">&#xe60d;</text>
<text class="upload_font">企业半年银行流水</text> <text class="upload_font">企业半年银行流水</text>
</view> </view>
...@@ -140,14 +140,70 @@ ...@@ -140,14 +140,70 @@
} }
}); });
}, },
mounted() {
// #ifdef H5
const _input = document.createElement('input');
_input.type = 'file';
_input.accept = 'application/x-zip-compressed,application/x-rar-compressed';
_input.style.position = 'absolute';
_input.style.top = '0';
_input.style.width = '100%';
_input.style.height = '100%';
_input.style.opacity = '0';
this.$refs.compress.$el.append(_input);
_input.onchange = (e) => {
let file = e.target.files[0];
let fileName = file.name;
let pos = fileName.lastIndexOf(".");
let lastName = fileName.substring(pos, fileName.length);
if ((lastName.toLowerCase() != ".zip" ) && (lastName.toLowerCase() != ".rar")) {
uni.showToast({
title: "文件必须为.zip或.rar类型",
icon: 'none',
duration: 2000
})
return;
}
let url = null;
if (window.createObjectURL != undefined) {
// basic
url = window.createObjectURL(file);
} else if (window.webkitURL != undefined) {
// webkit or chrome
url = window.webkitURL.createObjectURL(file);
} else if (window.URL != undefined) {
// mozilla(firefox)
url = window.URL.createObjectURL(file);
}
uni.showLoading({
title: '上传中'
})
uni.uploadFile({
url: '/uni/api/resources',
filePath: url,
name: 'file',
formData: {
name: file.name
},
success: (uploadFileRes) => {
const data = JSON.parse(uploadFileRes.data)
this.params['bank_card_record'] = data.data;
this.compressName = fileName;
uni.hideLoading();
}
});
}
// #endif
},
methods: { methods: {
uploadImage(key) { uploadImage(key) {
uni.chooseImage({ uni.chooseImage({
sizeType: ['compress'],
success: (res) => { success: (res) => {
const tempFilePaths = res.tempFilePaths;
uni.showLoading({ uni.showLoading({
title: '上传中' title: '上传中'
}) })
const tempFilePaths = res.tempFilePaths;
uni.uploadFile({ uni.uploadFile({
url: '/uni/api/resources', url: '/uni/api/resources',
filePath: tempFilePaths[0], filePath: tempFilePaths[0],
...@@ -161,56 +217,6 @@ ...@@ -161,56 +217,6 @@
} }
}) })
}, },
uploadZip(key) {
// #ifdef H5
const _input = document.createElement('input');
_input.type = 'file';
_input.accept = 'application/x-zip-compressed,application/x-rar-compressed';
_input.click();
_input.onchange = (e) => {
let file = e.target.files[0];
let fileName = file.name;
let pos = fileName.lastIndexOf(".");
let lastName = fileName.substring(pos, fileName.length);
if ((lastName.toLowerCase() != ".zip" ) && (lastName.toLowerCase() != ".rar")) {
uni.showToast({
title: "文件必须为.zip或.rar类型",
icon: 'none',
duration: 2000
})
return;
}
let url = null;
if (window.createObjectURL != undefined) {
// basic
url = window.createObjectURL(file);
} else if (window.webkitURL != undefined) {
// webkit or chrome
url = window.webkitURL.createObjectURL(file);
} else if (window.URL != undefined) {
// mozilla(firefox)
url = window.URL.createObjectURL(file);
}
uni.showLoading({
title: '上传中'
})
uni.uploadFile({
url: '/uni/api/resources',
filePath: url,
name: 'file',
formData: {
name: file.name
},
success: (uploadFileRes) => {
const data = JSON.parse(uploadFileRes.data)
this.params[key] = data.data;
this.compressName = fileName;
uni.hideLoading();
}
});
}
// #endif
},
clearParams(key) { clearParams(key) {
this.params[key] = ''; this.params[key] = '';
}, },
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
<view class="apply_desc">支持(zip/rar)格式</view> <view class="apply_desc">支持(zip/rar)格式</view>
</view> </view>
<view class="apply_data_item"> <view class="apply_data_item">
<view class="apply_upload" @click="uploadZip('legal_card_record')" v-if="!params.legal_card_record"> <view class="apply_upload" v-if="!params.legal_card_record">
<text class="eosfont icons">&#xe60d;</text> <text class="eosfont icons">&#xe60d;</text>
<text class="upload_font">法人半年银行流水</text> <text class="upload_font">法人半年银行流水</text>
</view> </view>
...@@ -111,9 +111,65 @@ ...@@ -111,9 +111,65 @@
} }
}); });
}, },
mounted() {
// #ifdef H5
const _input = document.createElement('input');
_input.type = 'file';
_input.accept = 'application/x-zip-compressed,application/x-rar-compressed';
_input.style.position = 'absolute';
_input.style.top = '0';
_input.style.width = '100%';
_input.style.height = '100%';
_input.style.opacity = '0';
this.$refs.compress.$el.append(_input);
_input.onchange = (e) => {
let file = e.target.files[0];
let fileName = file.name;
let pos = fileName.lastIndexOf(".");
let lastName = fileName.substring(pos, fileName.length);
if ((lastName.toLowerCase() != ".zip" ) && (lastName.toLowerCase() != ".rar")) {
uni.showToast({
title: "文件必须为.zip或.rar类型",
icon: 'none',
duration: 2000
})
return;
}
let url = null;
if (window.createObjectURL != undefined) {
// basic
url = window.createObjectURL(file);
} else if (window.webkitURL != undefined) {
// webkit or chrome
url = window.webkitURL.createObjectURL(file);
} else if (window.URL != undefined) {
// mozilla(firefox)
url = window.URL.createObjectURL(file);
}
uni.showLoading({
title: '上传中'
})
uni.uploadFile({
url: '/uni/api/resources',
filePath: url,
name: 'file',
formData: {
name: file.name
},
success: (uploadFileRes) => {
const data = JSON.parse(uploadFileRes.data)
this.params['legal_card_record'] = data.data;
this.compressName = fileName;
uni.hideLoading();
}
});
}
// #endif
},
methods: { methods: {
uploadImage(key) { uploadImage(key) {
uni.chooseImage({ uni.chooseImage({
sizeType: ['compress'],
success: (res) => { success: (res) => {
uni.showLoading({ uni.showLoading({
title: '上传中', title: '上传中',
...@@ -134,56 +190,6 @@ ...@@ -134,56 +190,6 @@
} }
}) })
}, },
uploadZip(key) {
// #ifdef H5
const _input = document.createElement('input');
_input.type = 'file';
_input.accept = 'application/x-zip-compressed,application/x-rar-compressed';
_input.click();
_input.onchange = (e) => {
let file = e.target.files[0];
let fileName = file.name;
let pos = fileName.lastIndexOf(".");
let lastName = fileName.substring(pos, fileName.length);
if ((lastName.toLowerCase() != ".zip" ) && (lastName.toLowerCase() != ".rar")) {
uni.showToast({
title: "文件必须为.zip或.rar类型",
icon: 'none',
duration: 2000
})
return;
}
let url = null;
if (window.createObjectURL != undefined) {
// basic
url = window.createObjectURL(file);
} else if (window.webkitURL != undefined) {
// webkit or chrome
url = window.webkitURL.createObjectURL(file);
} else if (window.URL != undefined) {
// mozilla(firefox)
url = window.URL.createObjectURL(file);
}
uni.showLoading({
title: '上传中'
})
uni.uploadFile({
url: '/uni/api/resources',
filePath: url,
name: 'file',
formData: {
name: file.name
},
success: (uploadFileRes) => {
const data = JSON.parse(uploadFileRes.data)
this.params[key] = data.data;
this.compressName = fileName;
uni.hideLoading();
}
});
}
// #endif
},
clearParams(key) { clearParams(key) {
this.params[key] = ''; this.params[key] = '';
}, },
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
methods: { methods: {
uploadImage(key) { uploadImage(key) {
uni.chooseImage({ uni.chooseImage({
sizeType: ['compress'],
success: (res) => { success: (res) => {
uni.showLoading({ uni.showLoading({
title: '上传中' title: '上传中'
......
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
}, },
uploadImage(key) { uploadImage(key) {
uni.chooseImage({ uni.chooseImage({
sizeType: ['compress'],
success: (res) => { success: (res) => {
uni.showLoading({ uni.showLoading({
title: '上传中' title: '上传中'
......
...@@ -505,15 +505,16 @@ ...@@ -505,15 +505,16 @@
.installment_table_box { .installment_table_box {
padding: 0 28rpx 40rpx; padding: 0 28rpx 40rpx;
background: #fff; background: #fff;
overflow: scroll;
.installment_table { .installment_table {
background: #FBFBFB; background: #FBFBFB;
border-radius:16rpx; border-radius:16rpx;
border:1px solid rgba(236,236,236,1); border:1px solid rgba(236,236,236,1);
padding: 40rpx 40rpx 16rpx; padding: 40rpx 40rpx 16rpx;
display: flex; display: flex;
overflow: scroll;
.table_title { .table_title {
margin-right: 20rpx; margin-right: 20rpx;
min-width: 160rpx;
view { view {
height:36rpx; height:36rpx;
line-height: 36rpx; line-height: 36rpx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment