{"remainingRequest":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\src\\components\\public\\img-clip.vue?vue&type=script&lang=js&","dependencies":[{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\src\\components\\public\\img-clip.vue","mtime":1614735254000},{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\babel-loader\\lib\\index.js","mtime":499162500000},{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\nimport {\n\tVueCropper\n} from \"vue-cropper\";\n\nexport default {\n\tcomponents: {\n\t\tVueCropper\n\t},\n\tprops: {\n\t\tfolderName: {\n\t\t\ttype: String,\n\t\t\tdefault: \"student\"\n\t\t},\n\t\t// 裁剪区域宽度\n\t\tclipWidth: {\n\t\t\ttype: Number,\n\t\t\tdefault: 400\n\t\t},\n\t\t// 裁剪区域高度\n\t\tclipHeight: {\n\t\t\ttype: Number,\n\t\t\tdefault: 600\n\t\t},\n\t\t// 限制图片上传大小\n\t\tsize: {\n\t\t\ttype: Number,\n\t\t\tdefault: 0.4\n\t\t},\n\t\t// 初始化 显示图片路劲\n\t\tvalue: {\n\t\t\ttype: String,\n\t\t\tdefault: \"\"\n\t\t},\n\t\t// 固定比例裁剪\n\t\tfixedNumber: {\n\t\t\ttype: Array,\n\t\t\tdefault: () => [2, 3]\n\t\t}\n\t},\n\twatch: {\n\t\tvalue(val) {\n\t\t\t// 不为空 切不相等 更新\n\t\t\tif (val) {\n\t\t\t\tthis.viewUrl = val;\n\t\t\t} else {\n\t\t\t\tthis.viewUrl = \"\";\n\t\t\t}\n\t\t}\n\t},\n\tdata() {\n\t\treturn {\n\t\t\tIEVisible: false,\n\t\t\tpreviewVisible: false, //预览图\n\t\t\tuploadLoading: false, //正在上传\n\t\t\tviewUrl: null, //裁剪图url\n\t\t\tclipVisible: false, //显示裁剪区域\n\t\t\toption: {\n\t\t\t\timg: \"\", //裁剪图片的地址\n\t\t\t\toutputType: \"jpg\", //生成的图片格式\n\t\t\t\toutputSize: 1, //图片质量0-1\n\t\t\t\tautoCrop: true, //默认生成截图框\n\t\t\t\t// autoCropWidth: 200, //默认生成截图框宽度\n\t\t\t\t// autoCropHeight: 200, //默认生成截图框高度\n\t\t\t\tfixed: true, //固定截图\n\t\t\t\t// fixedNumber: [1, 1], //固定截图比例\n\t\t\t\tfixedBox: true //固定截图框大小 不允许改变\n\t\t\t},\n\t\t\tfileName: \"\",\n\t\t\tuploadInfo: \"\"\n\t\t};\n\t},\n\tcreated() {\n\t\tthis.IEVersion();\n\t},\n\tmethods: {\n\t\tinit(fiveUrl) {\n\t\t\tthis.viewUrl = fiveUrl\n\t\t},\n\t\t// 选择图片\n\t\tchooseImg(e) {\n\t\t\tconst files = e.target.files;\n\t\t\tconst file = e.target.files[0];\n\n\t\t\tif (!file.name.includes(\".jpg\")) {\n\t\t\t\tthis.$message.warning(\"仅支持.jpg格式的图片\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t// 默认限制20MB 以内的图片\n\t\t\tif (file.size > 1024 * 1024 * 20) {\n\t\t\t\tthis.$message.warning(\"请上传小于20MB的图片\");\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tlet formFile = new FormData();\n\t\t\tformFile.append(\"file\", file);\n\t\t\t// staff 职工 student 学生\n\t\t\tformFile.append(\"folderName\", this.folderName);\n\n\t\t\tthis.$http({\n\t\t\t\t\turl: window.SITE_CONFIG['apiURL'] + '/system/upload',\n\t\t\t\t\tmethod: \"post\",\n\t\t\t\t\tdata: formFile\n\t\t\t\t})\n\t\t\t\t.then(({\n\t\t\t\t\tdata: res\n\t\t\t\t}) => {\n\t\t\t\t\tif (res && res.code === 0) {\n\t\t\t\t\t\tthis.$message.success(\"原图上传成功\");\n\t\t\t\t\t\tsessionStorage.setItem(\"eightPic\", res.data.path)\n\t\t\t\t\t\t// 接下来原图处理成5寸门禁需要的\n\t\t\t\t\t\tthis.setOutputSize(file.size);\n\t\t\t\t\t\tthis.fileName = file.name;\n\t\t\t\t\t\tthis.option.img = this.getObjectURL(file);\n\t\t\t\t\t\tthis.clipVisible = true;\n\t\t\t\t\t\tthis.viewUrl = null;\n\t\t\t\t\t\tthis.$refs.uploadInput.value = null;\n\t\t\t\t\t} else if (res.msg) {\n\t\t\t\t\t\tthis.$message.error(res.msg);\n\t\t\t\t\t\tthis.deleteUpload();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.catch(err => {\n\t\t\t\t\tthis.deleteUpload();\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.uploadLoading = false;\n\t\t\t\t});\n\t\t},\n\t\t// 裁剪\n\t\tclipImg() {\n\t\t\tthis.$refs.cropper.getCropData(data => {\n\t\t\t\t// do something\n\t\t\t\t// var len = this.calcBase64(data);\n\t\t\t\tthis.viewUrl = data;\n\t\t\t\tthis.clipVisible = false;\n\t\t\t\t// 上传图片\n\t\t\t\tthis.uploadImg(data);\n\t\t\t});\n\t\t},\n\t\t// 左旋\n\t\trotateLeft() {\n\t\t\tthis.$refs.cropper.rotateLeft();\n\t\t},\n\t\t// 右旋\n\t\trotateRight() {\n\t\t\tthis.$refs.cropper.rotateRight();\n\t\t},\n\t\t// 删除图片\n\t\tdeleteUpload() {\n\t\t\tthis.fileName = \"\";\n\t\t\tthis.uploadInfo = \"\";\n\t\t\tthis.$emit(\"input\", \"\");\n\t\t\tthis.viewUrl = null;\n\t\t},\n\t\t//将base64转换为文件\n\t\tdataURLtoFile(dataurl, filename) {\n\t\t\tvar arr = dataurl.split(\",\"),\n\t\t\t\tmime = arr[0].match(/:(.*?);/)[1],\n\t\t\t\tbstr = atob(arr[1]),\n\t\t\t\tn = bstr.length,\n\t\t\t\tu8arr = new Uint8Array(n);\n\t\t\twhile (n--) {\n\t\t\t\tu8arr[n] = bstr.charCodeAt(n);\n\t\t\t}\n\t\t\treturn new File([u8arr], filename, {\n\t\t\t\ttype: mime\n\t\t\t});\n\t\t},\n\t\t// 上传图片\n\t\tuploadImg(data) {\n\t\t\tvar fileObj = this.dataURLtoFile(data, \"five\" + new Date().getTime() + this.fileName);\n\t\t\tvar formFile = new FormData();\n\t\t\tformFile.append(\"file\", fileObj);\n\t\t\t// staff 职工 student 学生\n\t\t\tformFile.append(\"folderName\", this.folderName);\n\t\t\tthis.uploadLoading = true;\n\t\t\tthis.uploadInfo = \"上传中\";\n\t\t\tthis.$http({\n\t\t\t\t\turl: window.SITE_CONFIG['apiURL'] + '/system/upload',\n\t\t\t\t\tmethod: \"post\",\n\t\t\t\t\tdata: formFile\n\t\t\t\t})\n\t\t\t\t.then(({\n\t\t\t\t\tdata: res\n\t\t\t\t}) => {\n\t\t\t\t\tif (res && res.code === 0) {\n\t\t\t\t\t\tthis.$message.success(\"上传成功\");\n\t\t\t\t\t\tthis.$emit(\"input\", res.data.path);\n\t\t\t\t\t} else if (res.msg) {\n\t\t\t\t\t\tthis.$message.error(res.msg);\n\t\t\t\t\t\tthis.deleteUpload();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.catch(err => {\n\t\t\t\t\tthis.deleteUpload();\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.uploadLoading = false;\n\t\t\t\t});\n\t\t},\n\t\t// 取消上传\n\t\tcancelClip() {\n\t\t\tthis.clipVisible = false;\n\t\t},\n\t\t//计算base64 文件大小\n\t\tcalcBase64(baseStr) {\n\t\t\tlet tag = \"base64,\";\n\t\t\tbaseStr = baseStr.substring(baseStr.indexOf(tag) + tag.length);\n\t\t\tlet eqTagIndex = baseStr.indexOf(\"=\");\n\t\t\tbaseStr = eqTagIndex != -1 ? baseStr.substring(0, eqTagIndex) : baseStr;\n\t\t\tlet strLen = baseStr.length;\n\t\t\tlet fileSize = strLen - (strLen / 8) * 2;\n\t\t\treturn fileSize / 1024 / 1024;\n\t\t},\n\t\t// 获取本地图片上传路径\n\t\tgetObjectURL(file) {\n\t\t\tvar url = null;\n\t\t\tif (window.createObjectURL != undefined) {\n\t\t\t\t// basic\n\t\t\t\turl = window.createObjectURL(file);\n\t\t\t} else if (window.URL != undefined) {\n\t\t\t\t// mozilla(firefox)\n\t\t\t\turl = window.URL.createObjectURL(file);\n\t\t\t} else if (window.webkitURL != undefined) {\n\t\t\t\t// webkit or chrome\n\t\t\t\turl = window.webkitURL.createObjectURL(file);\n\t\t\t}\n\t\t\treturn url;\n\t\t},\n\t\t// 设置图片质量 压缩比\n\t\tsetOutputSize(size) {\n\t\t\tlet result = 1;\n\t\t\tif (size / 1024 / 1024 > this.size) {\n\t\t\t\tresult = ((this.size * 1024 * 1024) / size).toFixed(2);\n\t\t\t}\n\t\t\tconsole.log(\"当前压缩率:\", result);\n\t\t\tthis.option.outputSize = Number(result);\n\t\t},\n\t\tIEVersion() {\n\t\t\t// 取得浏览器的userAgent字符串\n\t\t\tvar userAgent = navigator.userAgent;\n\t\t\t// 判断是否为小于IE11的浏览器\n\t\t\tvar isLessIE11 = userAgent.indexOf(\"compatible\") > -1 && userAgent.indexOf(\"MSIE\") > -1;\n\t\t\tif (isLessIE11) {\n\t\t\t\tthis.IEVisible = true;\n\t\t\t}\n\t\t}\n\t}\n};\n",{"version":3,"sources":["img-clip.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"img-clip.vue","sourceRoot":"src/components/public","sourcesContent":["\n\t\n\t\t\n\t\t\n\t\t\t\n\t\t\n\n\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t取消\n\t\t\t\t确认\n\t\t\t\n\t\t\n\t\n\t\n\t\t检测到当前浏览器版本较低\n\t\t请使用360浏览器极速模式或使用chrome浏览器等其它高级浏览器\n\t\n\n\n\n"]}]}
\n\t\t\t\t\n\t\t\t