From ec1390771ec05145cb102d400bf9089d21d117a8 Mon Sep 17 00:00:00 2001 From: hbao Date: Fri, 6 Aug 2021 09:52:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/homestead/index.vue | 107 ++++++++++++++++++++++++++++++---- 1 file changed, 96 insertions(+), 11 deletions(-) diff --git a/src/views/homestead/index.vue b/src/views/homestead/index.vue index e6c3261c..e11b1bf2 100644 --- a/src/views/homestead/index.vue +++ b/src/views/homestead/index.vue @@ -954,6 +954,8 @@ import { currentLocation, coordinatesUpdateGeo, } from "@/api/homestead/index"; +import {uploadFileBase} from "../../api/authenticRight"; +import request from '@/utils/request' export default { name: "homesteadLogin", @@ -1397,6 +1399,8 @@ export default { .then(() => { // on confirm houseInfoList.theGeom ="["+houseInfoList.theGeom+"]" + //houseInfoList.frontHouse = location.protocol+"//"+location.host+request.defaults.baseURL+ this.houseInfoList.frontHouse; + //console.log("地址"+houseInfoList.frontHouse); houseAdd(houseInfoList).then((res) => { if (res.code == 200) { this.landHomesteadEditVisbileFun("hide"); @@ -1432,6 +1436,7 @@ export default { }) .then(() => { // on confirm + //houseInfoList.frontHouse = location.protocol+"//"+location.host+request.defaults.baseURL+ this.houseInfoList.frontHouse; houseEdit(houseInfoList).then((res) => { if (res.code == 200) { this.landHomesteadEditVisbileFun("hide"); @@ -1509,6 +1514,8 @@ export default { .then(() => { // on confirm landInfoList.theGeom ="["+landInfoList.theGeom+"]" + //landInfoList.frontland = location.protocol+"//"+location.host+request.defaults.baseURL+ this.landInfoList.frontland; + //console.log("修改新增"+landInfoList.frontland) landAdd(landInfoList).then((res) => { if (res.code == 200) { this.landHomesteadEditVisbileFun("hide"); @@ -1551,6 +1558,8 @@ export default { }) .then(() => { // on confirm + //landInfoList.frontland = location.protocol+"//"+location.host+request.defaults.baseURL+ this.landInfoList.frontland; + console.log("修改农地"+landInfoList.frontland) landEdit(landInfoList).then((res) => { if (res.code == 200) { this.landHomesteadEditVisbileFun("hide"); @@ -3196,21 +3205,97 @@ export default { this.landInfoList.sfylzyx = value; }, //农房 -- 新建 上传图片方法 + // nfAddimgonRead(file) { + // var formData = new FormData(); //构造一个 FormData,把后台需要发送的参数添加 + // formData.append("file", file.file); //接口需要传的参数 + // console.log(formData); + // commonUpload(formData).then((res) => { + // this.houseInfoList.frontHouse = res.url; + // }); + // }, nfAddimgonRead(file) { - var formData = new FormData(); //构造一个 FormData,把后台需要发送的参数添加 - formData.append("file", file.file); //接口需要传的参数 - console.log(formData); - commonUpload(formData).then((res) => { - this.houseInfoList.frontHouse = res.url; - }); + // 创建Canvas对象(画布) + let canvas = document.createElement('canvas') + // 获取对应的CanvasRenderingContext2D对象(画笔) + let context = canvas.getContext('2d') + // 创建新的图片对象 + let img = new Image() + // 指定图片的DataURL(图片的base64编码数据) + img.src = file.content + img.onload = () => { + const h = img.height + const w = img.width + let ch = img.height/4 + let cw = img.width/4 + let canvas = document.createElement('canvas') + let ctx = canvas.getContext('2d') + canvas.height = ch + canvas.width = cw + ctx.clearRect(0,0,cw,ch) + ctx.drawImage(img,0,0,cw,ch) + let base_img = canvas.toDataURL('image/jpeg') + const blobBin = atob(base_img.split(',')[1]) + let d = [] + for (let i=0;i { + //this.houseInfoList.frontHouse =res.fileName + if(res.code ==200){ + this.houseInfoList.frontHouse = location.protocol+"//"+location.host+request.defaults.baseURL+ res.fileName; + }else{ + return "图片上传失败" + } + }) + } }, //农地 -- 新建 上传图片方法 + // ndAddimgonRead(file) { + // var formData = new FormData(); //构造一个 FormData,把后台需要发送的参数添加 + // formData.append("file", file.file); //接口需要传的参数 + // commonUpload(formData).then((res) => { + // this.landInfoList.frontland = res.url; + // console.log(this.landInfoList.frontland); + // }); + // }, ndAddimgonRead(file) { - var formData = new FormData(); //构造一个 FormData,把后台需要发送的参数添加 - formData.append("file", file.file); //接口需要传的参数 - commonUpload(formData).then((res) => { - this.landInfoList.frontland = res.url; - }); + // 创建Canvas对象(画布) + let canvas = document.createElement('canvas') + // 获取对应的CanvasRenderingContext2D对象(画笔) + let context = canvas.getContext('2d') + // 创建新的图片对象 + let img = new Image() + // 指定图片的DataURL(图片的base64编码数据) + img.src = file.content + img.onload = () => { + const h = img.height + const w = img.width + let ch = img.height/4 + let cw = img.width/4 + let canvas = document.createElement('canvas') + let ctx = canvas.getContext('2d') + canvas.height = ch + canvas.width = cw + ctx.clearRect(0,0,cw,ch) + ctx.drawImage(img,0,0,cw,ch) + let base_img = canvas.toDataURL('image/jpeg') + const blobBin = atob(base_img.split(',')[1]) + let d = [] + for (let i=0;i { + if(res.code ==200){ + this.landInfoList.frontland = location.protocol+"//"+location.host+request.defaults.baseURL+ res.fileName; + }else{ + return "图片上传失败" + } + }) + } }, }, }; From b08d3d492588e460676731463698e3b960ecf8cf Mon Sep 17 00:00:00 2001 From: yujk <990961482@qq.com> Date: Fri, 6 Aug 2021 11:00:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A1=AE=E6=9D=83=E8=B0=83=E6=9F=A5?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=EF=BC=8C=E7=94=B5=E8=AF=9D=E8=B0=83?= =?UTF-8?q?=E6=9F=A5=E6=B7=BB=E5=8A=A0=E8=BA=AB=E4=BB=BD=E8=AF=81=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/authenticRight/index.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/views/authenticRight/index.vue b/src/views/authenticRight/index.vue index ee2b608d..013006f2 100644 --- a/src/views/authenticRight/index.vue +++ b/src/views/authenticRight/index.vue @@ -350,6 +350,14 @@ placeholder="抽查户主名称" :rules="[{ required: true, message: '请填写抽查户主名称' }]" /> +