|
@@ -35,13 +35,13 @@
|
|
上传图片:
|
|
上传图片:
|
|
</view>
|
|
</view>
|
|
|
|
|
|
-
|
|
|
|
- <view class="unload-box" @tap="goCamera()">
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ <view class="unload-box" @tap="goCamera()">
|
|
<image v-if="this.imgUrl" mode="aspectFit" style="width:70rpx;height:70rpx" :src="this.imgUrl"
|
|
<image v-if="this.imgUrl" mode="aspectFit" style="width:70rpx;height:70rpx" :src="this.imgUrl"
|
|
:data-src="this.imgUrl"></image>
|
|
:data-src="this.imgUrl"></image>
|
|
- <view v-else style="background:rgb(223 215 215 / 63%);font-size:22rpx;line-height:40rpx;margin-top:20rpx;padding:0 20px;display:inline-block;border-radius:10rpx">请上传 + </view>
|
|
|
|
|
|
+ <view v-else
|
|
|
|
+ style="background:rgb(223 215 215 / 63%);font-size:22rpx;line-height:40rpx;margin-top:20rpx;padding:0 20px;display:inline-block;border-radius:10rpx">
|
|
|
|
+ 请上传 + </view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="form-item margin-top">
|
|
<view class="form-item margin-top">
|
|
@@ -56,11 +56,19 @@
|
|
<button class="bg-blue round margin-top" @click="$noMultipleClicks(addSubmit)">提 交 </button>
|
|
<button class="bg-blue round margin-top" @click="$noMultipleClicks(addSubmit)">提 交 </button>
|
|
</view>
|
|
</view>
|
|
</form>
|
|
</form>
|
|
|
|
+
|
|
|
|
+ <helang-compress ref="helangCompress"></helang-compress>
|
|
|
|
+
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+ import helangCompress from '../../../components/helang-compress/helang-compress';
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
|
|
+ components: {
|
|
|
|
+ helangCompress
|
|
|
|
+ },
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
noClick: true,
|
|
noClick: true,
|
|
@@ -72,7 +80,15 @@
|
|
reportName: '',
|
|
reportName: '',
|
|
radioOne: 0,
|
|
radioOne: 0,
|
|
zb_id: 0,
|
|
zb_id: 0,
|
|
- hasRes:0
|
|
|
|
|
|
+
|
|
|
|
+ params: {
|
|
|
|
+ maxSize: 800,
|
|
|
|
+ fileType: 'png',
|
|
|
|
+ quality: 0.85,
|
|
|
|
+ minSize: 640
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -82,15 +98,6 @@
|
|
},
|
|
},
|
|
|
|
|
|
mounted() {
|
|
mounted() {
|
|
- // 创建附件上传
|
|
|
|
- // var _self = this;
|
|
|
|
- // var input = document.createElement('input'); //创建元素
|
|
|
|
- // input.type = 'file' //添加file类型
|
|
|
|
- // input.onchange = (event) => {
|
|
|
|
- // _self.upFile(input, event)
|
|
|
|
- // }
|
|
|
|
- // this.$refs.input.$el.appendChild(input)
|
|
|
|
-
|
|
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
radioChange(e) {
|
|
radioChange(e) {
|
|
@@ -103,72 +110,53 @@
|
|
uni.chooseImage({
|
|
uni.chooseImage({
|
|
count: 1, // 最多可以选择的图片张数
|
|
count: 1, // 最多可以选择的图片张数
|
|
sizeType: ['original', 'compressed'], //original 原图,compressed 压缩图,默认二者都有
|
|
sizeType: ['original', 'compressed'], //original 原图,compressed 压缩图,默认二者都有
|
|
- sourceType: ['camera','album'],
|
|
|
|
|
|
+ sourceType: ['camera', 'album'],
|
|
success: function(res) {
|
|
success: function(res) {
|
|
console.log(res);
|
|
console.log(res);
|
|
that.imgUrl = res.tempFilePaths[0];
|
|
that.imgUrl = res.tempFilePaths[0];
|
|
var tempFilePaths = res.tempFilePaths[0];
|
|
var tempFilePaths = res.tempFilePaths[0];
|
|
-
|
|
|
|
-
|
|
|
|
- alert(1)
|
|
|
|
- alert(tempFilePaths)
|
|
|
|
-
|
|
|
|
- setTimeout(function(){
|
|
|
|
|
|
+
|
|
|
|
+ that.$refs.helangCompress.compress({
|
|
|
|
+ src: tempFilePaths,
|
|
|
|
+ maxSize: that.params.maxSize,
|
|
|
|
+ fileType: that.params.fileType,
|
|
|
|
+ quality: that.params.quality,
|
|
|
|
+ minSize: that.params.minSize
|
|
|
|
+ }).then((res) => {
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ // uni.showToast({
|
|
|
|
+ // title: "压缩成功",
|
|
|
|
+ // icon: "success"
|
|
|
|
+ // })
|
|
|
|
+ tempFilePaths = [res][0];
|
|
|
|
|
|
uni.uploadFile({
|
|
uni.uploadFile({
|
|
url: that.$BASE_URL + 'Inspection/setUpload',
|
|
url: that.$BASE_URL + 'Inspection/setUpload',
|
|
filePath: tempFilePaths,
|
|
filePath: tempFilePaths,
|
|
name: 'file',
|
|
name: 'file',
|
|
-
|
|
|
|
- // header: {
|
|
|
|
- // 'content-type': 'multipart/form-data'
|
|
|
|
- // },
|
|
|
|
- formData: {
|
|
|
|
- // 'user': 'test'
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
success: (uploadFileRes) => {
|
|
success: (uploadFileRes) => {
|
|
|
|
|
|
- console.log('uploadFileRes')
|
|
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: "上传成功",
|
|
|
|
+ icon: "success"
|
|
|
|
+ })
|
|
that.img = JSON.parse(uploadFileRes.data).img_url;
|
|
that.img = JSON.parse(uploadFileRes.data).img_url;
|
|
- alert(uploadFileRes.data)
|
|
|
|
- alert(that.img)
|
|
|
|
- that.hasRes=1
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
-
|
|
|
|
- },2000)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ }).catch((err) => {
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: "压缩失败",
|
|
|
|
+ icon: "none"
|
|
|
|
+ })
|
|
|
|
+ })
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- // upFile(input, event) {
|
|
|
|
- // var _self = this;
|
|
|
|
- // uni.uploadFile({
|
|
|
|
- // url:this.$BASE_URL+'Inspection/setUpload',
|
|
|
|
- // files: [{
|
|
|
|
- // file: input.files[0],
|
|
|
|
- // uri: event.srcElement.value
|
|
|
|
- // }],
|
|
|
|
- // success: (uploadFileRes) => {
|
|
|
|
- // var data = JSON.parse(uploadFileRes.data)
|
|
|
|
- // this.img = data.img_url;
|
|
|
|
- // alert(this.img)
|
|
|
|
- // },
|
|
|
|
- // fail: (err) => {
|
|
|
|
- // console.log(err)
|
|
|
|
- // }
|
|
|
|
- // });
|
|
|
|
- // },
|
|
|
|
-
|
|
|
|
|
|
+
|
|
addSubmit() {
|
|
addSubmit() {
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
if (!this.reportName.replace(/^\s*/g, '')) {
|
|
if (!this.reportName.replace(/^\s*/g, '')) {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title: "请输入上报名称",
|
|
title: "请输入上报名称",
|