diff --git a/.env.production b/.env.production index 05754bd..a255385 100644 --- a/.env.production +++ b/.env.production @@ -6,7 +6,7 @@ NODE_ENV=production # 测试0 生产1 VUE_APP_ENV = '1' # 定义变量 -VUE_APP_CITY_TYPE = 'nx' +VUE_APP_CITY_TYPE = 'xj' # base api VUE_APP_BASE_API = '' diff --git a/src/api/config.js b/src/api/config.js index e4e666c..5c56d12 100644 --- a/src/api/config.js +++ b/src/api/config.js @@ -17,8 +17,8 @@ if (process.env.NODE_ENV === 'development') { // 生产环境 // baseURL = '' // 本地 打包以后只需要空路径就行 // baseURL = '/proxy-ah' //安徽 打包以后的路径 - baseURL = '/proxy-nx' //宁夏 打包以后的路径 - // baseURL = '/proxy-xj' //新疆 打包以后的路径 + // baseURL = '/proxy-nx' //宁夏 打包以后的路径 + baseURL = '/proxy-xj' //新疆 打包以后的路径 // baseURL = '/proxy-sx' //山西 打包以后的路径 } diff --git a/src/assets/address.png b/src/assets/address.png new file mode 100644 index 0000000..926da47 Binary files /dev/null and b/src/assets/address.png differ diff --git a/src/store/module/user.js b/src/store/module/user.js index decd8d4..c251e4d 100644 --- a/src/store/module/user.js +++ b/src/store/module/user.js @@ -175,7 +175,6 @@ const actions = { commit('SET_SG_CODE', gw_yc_code) commit('SET_DEPT_ID', dept_id) commit('SET_ENERGY_TYPE', user_category_code) - // commit('GET_USER_LEVEL') resolve(true) } else { resolve(false) diff --git a/src/utils/base64.js b/src/utils/base64.js new file mode 100644 index 0000000..fd91a5e --- /dev/null +++ b/src/utils/base64.js @@ -0,0 +1,29 @@ +export const Base64ToFile = (base64, mime, filename) =>{ + let arr = base64.split(',') + let type = mime || arr[0].match(/:(.*?);/)[1] + let suffix = mime.split('/')[1] + let fileName = filename || `未命名.${suffix}` + let bstr = atob(arr[1]) + let n = bstr.length + let u8arr = new Uint8Array(n) + while (n--) { + u8arr[n] = bstr.charCodeAt(n) + } + return new File([u8arr], fileName, {type}) +} +// export const BlobtoFile = (data, mime, filename) =>{ +// const blob = new Blob([data], {type: 'text/plain'}) +// const file = new File([blob], '') +// } + +export const base64ToBlob = (dataurl, fileName) => { + let arr = dataurl.split(',') + let mime = arr[0].match(/:(.*?);/)[1] + let bstr = atob(arr[1]) + let n = bstr.length + let u8Arr = new Uint8Array(n) + while(n--){ + u8Arr[n] = bstr.charCodeAt(n) + } + return new Blob([u8Arr], {type: mime}) + } \ No newline at end of file diff --git a/src/utils/marker.js b/src/utils/marker.js new file mode 100644 index 0000000..8929b05 --- /dev/null +++ b/src/utils/marker.js @@ -0,0 +1,110 @@ +/** + * 添加水印 + * @param {blob} file + * @param {string} el + * @returns {Promise} + */ +import { formathms } from '@/utils/timeUtil.js' +import { getLocationMessage , getPosition} from '@/utils/dsbridge' +export async function addWaterMarker(file, type) { + return new Promise(async (resolve, reject) => { + try { + // 将文件blob转换成图片 + console.log('-------------------------addWaterMarker---', file); + let img = await blobToImg(file) + // 创建canvas画布 + let canvas = document.createElement('canvas') + canvas.width = img.naturalWidth + canvas.height = img.naturalHeight + let ctx = canvas.getContext('2d') + + // 填充上传的图片 + ctx.drawImage(img, 0, 0, canvas.width, canvas.height) + + // 加水印文字内容 + let text = await getText() + const markerFontSize = 18 + const markerFontOpacity = 1 + ctx.font = `bold ${markerFontSize}px Yahei` + ctx.fillStyle = '#000' + ctx.globalAlpha = markerFontOpacity + ctx.fillText('时\xa0\xa0\xa0间:'+text.time, canvas.width / 20, canvas.height-50) + ctx.fillText('地\xa0\xa0\xa0点:'+text.address, canvas.width/20, canvas.height-30) + ctx.fillText('经纬度:'+text.lglt, canvas.width/20, canvas.height-10) + // 加线 + let line = canvas.getContext('2d') + line.moveTo(canvas.width / 20 - 10, canvas.height-55) + line.lineTo(canvas.width / 20 - 10, canvas.height-5) + line.lineWidth=3 + line.stroke() + // 加位置图标 + let image = await loadImage() + ctx.drawImage(image, canvas.width/20-20, canvas.height-85, 20, 20) + // 将canvas转换成blob + canvas.toBlob(blob => resolve(blob)) + } catch (error) { + reject(error) + } + + }) + } + function loadImage(){ + return new Promise((resolve, reject) => { + // 加图片 + var image = new Image() + image.crossOrigin = true + image.src=require('@/assets/address.png') + image.onload = ()=> { + resolve(image) + } + }) + } + function blobToImg(blob) { + return new Promise((resolve, reject) => { + let reader = new FileReader() + reader.addEventListener('load', () => { + let img = new Image() + img.src = reader.result + img.addEventListener('load', () => resolve(img)) + }) + reader.readAsDataURL(blob) + }) + } + +// 水印文字获取 + function getText() { + return new Promise((resolve, reject) => { + let obj = { + time: formathms(new Date().getTime()), + address: '江苏南京', + lglt: '118.708980°,31.560001°' + } + getLocationMessage((data) => { + console.log('-------------------------getLocationMessage', data); + if (data) { + obj.address = data + } else { + obj.address = '测试地址' + } + }) + getPosition((data) => { + console.log('-------------------------位置信息', data, typeof(data)); + if (data) { + if(typeof(data) == 'string'){ + let dataArr = data.split(',') + let lglt = dataArr[0].match(/\d+\.\d{2}/)[0]+'°,'+dataArr[1].match(/\d+\.\d{2}/)[0] +'°' + obj.lglt = lglt + }else{ + console.log(data.longitude, 'lgitude位置信息') + let lglt = (data.longitude+'').match(/\d+\.\d{2}/)[0] +'°,'+(data.latitude+'').match(/\d+\.\d{2}/)[0]+'°' + obj.lglt = lglt + } + } else { + Notify({ type: 'warning', message: '未获取到位置信息' }) + } + }) + resolve(obj) + + }) + } + \ No newline at end of file diff --git a/src/views/energyEfficiency/TaskFilling.vue b/src/views/energyEfficiency/TaskFilling.vue index fb1bfb1..c4a4d5d 100644 --- a/src/views/energyEfficiency/TaskFilling.vue +++ b/src/views/energyEfficiency/TaskFilling.vue @@ -634,7 +634,7 @@ export default { }) return } - taskList({ consName: this.item.customerName }).then((res) => { + taskList({ taskId: this.taskId }).then((res) => { this.records = res.data.list[0] if (!this.records.buildId) { this.$notify({ diff --git a/src/views/energyEfficiency/constructionInfo.vue b/src/views/energyEfficiency/constructionInfo.vue index 64ca6ab..0f0b393 100644 --- a/src/views/energyEfficiency/constructionInfo.vue +++ b/src/views/energyEfficiency/constructionInfo.vue @@ -24,7 +24,7 @@