|
@@ -120,8 +120,8 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- showBuilding:false,
|
|
|
- buildingData:[],
|
|
|
+ showBuilding: false,
|
|
|
+ buildingData: [],
|
|
|
contentText: {
|
|
|
contentrefresh: '上传照片中',
|
|
|
},
|
|
@@ -191,7 +191,7 @@
|
|
|
i.name = i.label;
|
|
|
i.id = i.value;
|
|
|
});
|
|
|
- this.buildingData=JSON.parse(option.buildingData)
|
|
|
+ this.buildingData = JSON.parse(option.buildingData)
|
|
|
this.loading = true
|
|
|
// 接收传值
|
|
|
var data = option.id;
|
|
@@ -207,10 +207,10 @@
|
|
|
this.formData.fpdType = i.id
|
|
|
}
|
|
|
})
|
|
|
- that.buildingData.map(v=>{
|
|
|
- if(v.id==that.formData.buildingId){
|
|
|
- that.formData.buildingName=v.name
|
|
|
- }
|
|
|
+ that.buildingData.map(v => {
|
|
|
+ if (v.id == that.formData.buildingId) {
|
|
|
+ that.formData.buildingName = v.name
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
|
|
@@ -251,7 +251,7 @@
|
|
|
},
|
|
|
onShow() {
|
|
|
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
methods: {
|
|
|
//所属建筑
|
|
@@ -273,71 +273,64 @@
|
|
|
|
|
|
},
|
|
|
photoUpload() {
|
|
|
+ let pictures = [];
|
|
|
let that = this;
|
|
|
-
|
|
|
- function uploadImage(filePath) {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- uni.uploadFile({
|
|
|
- url: baseUrl + '/admin-api/infra/file/upload',
|
|
|
- filePath: filePath,
|
|
|
- name: 'file',
|
|
|
- header: {
|
|
|
- "Authorization": 'Bearer ' + getAccessToken(),
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- let imgUrl = JSON.parse(res.data);
|
|
|
- resolve(imgUrl.data); // 返回图片地址
|
|
|
- },
|
|
|
- fail: () => {
|
|
|
- reject();
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- function displayImage(url) {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- loadImage(
|
|
|
- url,
|
|
|
- function(canvas) {
|
|
|
- canvas.toBlob(function(blob) {
|
|
|
- const compressedFile = blob;
|
|
|
- const fileUrl = URL.createObjectURL(compressedFile);
|
|
|
- that.formData.picVOList.push({
|
|
|
- url: url,
|
|
|
- picname: ''
|
|
|
- });
|
|
|
- that.$forceUpdate();
|
|
|
- URL.revokeObjectURL(fileUrl);
|
|
|
- resolve();
|
|
|
- }, 'image/jpeg', 0.6);
|
|
|
- }, {
|
|
|
- canvas: true,
|
|
|
- maxWidth: 800
|
|
|
- }
|
|
|
- );
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
uni.chooseImage({
|
|
|
- sourceType: ['camera'],
|
|
|
+ sourceType: ['camera'], //实现拍照
|
|
|
count: 3,
|
|
|
sizeType: ['original', 'compressed'],
|
|
|
+ // sourceType: ['album','camera'], //打开系统相册
|
|
|
success(res) {
|
|
|
- that.loading = true;
|
|
|
- if (Array.isArray(res.tempFilePaths)) {
|
|
|
- res.tempFilePaths.forEach(async (item) => {
|
|
|
- try {
|
|
|
- const imgUrl = await uploadImage(item);
|
|
|
- await displayImage(imgUrl);
|
|
|
- that.loading = false;
|
|
|
- } catch (error) {
|
|
|
- that.loading = false;
|
|
|
- }
|
|
|
- });
|
|
|
+ that.loading = true
|
|
|
+ if (Array.isArray(res.tempFilePaths)) { //从相册选择有三张的情况
|
|
|
+ res.tempFilePaths.forEach(item => {
|
|
|
+ loadImage(
|
|
|
+ item,
|
|
|
+ function(canvas) {
|
|
|
+ canvas.toBlob(function(blob) {
|
|
|
+ // 压缩后的 Blob 对象
|
|
|
+ const compressedFile = blob;
|
|
|
+ // 将压缩后的文件 `compressedFile` 转换为临时URL
|
|
|
+ const fileUrl = URL.createObjectURL(
|
|
|
+ compressedFile);
|
|
|
+ uni.uploadFile({
|
|
|
+ url: baseUrl +
|
|
|
+ '/admin-api/infra/file/upload', //后端用于处理图片并返回图片地址的接口
|
|
|
+ filePath: item,
|
|
|
+ name: 'file',
|
|
|
+ header: {
|
|
|
+ "Authorization": 'Bearer ' +
|
|
|
+ getAccessToken(),
|
|
|
+ }, //请求token
|
|
|
+ success: (res) => {
|
|
|
+ let imgUrl = JSON.parse(res
|
|
|
+ .data)
|
|
|
+ that.loading = false
|
|
|
+ //拍照下展示的图片
|
|
|
+ that.formData.picVOList.push({
|
|
|
+ url: imgUrl.data,
|
|
|
+ picname: ''
|
|
|
+ })
|
|
|
+
|
|
|
+ that.$forceUpdate();
|
|
|
+ // // 返回的url
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ that.loading = false
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ URL.revokeObjectURL(fileUrl);
|
|
|
+ }, 'image/jpeg', 0.6); // 设置压缩后的图片格式为 JPEG,压缩质量为 0.6
|
|
|
+ }, {
|
|
|
+ canvas: true,
|
|
|
+ maxWidth: 800
|
|
|
+ } // 设置最大宽度为 800px
|
|
|
+ );
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
submit(ref) {
|
|
|
this.$refs[ref]
|