{"remainingRequest":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/vue-loader/lib/index.js??vue-loader-options!/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/src/components/o_image_upload.vue?vue&type=script&lang=js&","dependencies":[{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/src/components/o_image_upload.vue","mtime":1740130327258},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/thread-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/babel-loader/lib/index.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/badp-bcxin-web-5.x-mobile/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//\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//\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//\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 wx from \"weixin-js-sdk\"\nimport { Toast } from 'mint-ui';\nimport Constant from \"@/Constant.js\";\nimport API from \"@/api.js\";\nexport default {\n name: \"o-image-upload\",\n props: [\"id\"],\n computed: {\n field: function() {\n let formData = this.$parent.findField(this.id);\n if(formData.discript) {//识别控件描述最后一个字符为*时,*变红\n if(formData.discript.charAt(formData.discript.length - 1) == \"*\") {\n formData.discript = formData.discript.replace(/(\\s|\\*)+$/g, '');\n formData.essential = true;\n }\n }\n if(formData.value && formData.value.length>0) {\n if(typeof formData.value == 'string') {\n formData.value = JSON.parse(formData.value);\n }else {\n formData.value = formData.value;//选项卡返回的是数组\n }\n }else {\n formData.value = [];\n }\n formData.picUrl = obpmConfig.obpmFilePath;\n return formData;\n }\n },\n data: function() {\n return {\n Constant,\n dialogImageUrl: \"\",\n dialogVisible: false,\n imageType: \"\",\n maxStatus: true,\n multiple: true,\n list: [],\n picUrl: \"\",\n bigPic:\"\",\n popupVisible:false,\n fileSize:0,\n partialRefreshData:[],\n imgList: [],\n\t currentPreviewImg: 0, //预览时显示当前点击的照片\n };\n },\n methods: {\n //图片预览\n picturePreview(filePath,index){\n\t this.currentPreviewImg = index\n // this.bigPic = obpmConfig.obpmFilePath + filePath;\n let picList = this.field.value\n let accessToken = localStorage.getItem(\"accessToken\");\n if(picList.length > 0) {\n let list = [];\n picList.forEach(el => {\n let path = obpmConfig.obpmFilePath + el.path + \"?accessToken=\"+ accessToken; //嗨办公预览破图,加上token\n list.push(path);\n });\n this.imgList = list;\n }\n this.popupVisible = true;\n },\n\n chooseType() {\n let that = this;\n let ua = window.navigator.userAgent;\n if (ua.toLowerCase().indexOf(\"wxwork\") >= 0 || ua.toLowerCase().indexOf(\"weixin\") >= 0){\n let _url = location.href.split(\"#\")[0];\n let maxLength = this.field.limitNumber; //最大上传数量 \n API.getWeixinApi(\n encodeURIComponent(_url),\n {\n onSucess: response => {\n wx.config({\n debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。\n appId: response.data.data.appId, // 必填,公众号的唯一标识\n timestamp: response.data.data.timestamp, // 必填,生成签名的时间戳\n nonceStr: response.data.data.nonceStr, // 必填,生成签名的随机串\n signature: response.data.data.signature, // 必填,签名,见附录1\n jsApiList: [\n \"chooseImage\",\n \"previewImage\",\n \"uploadImage\",\n \"downloadImage\",\n ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2\n });\n\n wx.chooseImage({\n count: maxLength,\n sizeType: [\"original\", \"compressed\"], // o:原图,c:压缩图\n sourceType: [\"album\", \"camera\"], // a:来自相册,c:来自相机\n success: function(res) {\n let r = JSON.stringify(res)\n that.uploadFile(res.localIds);\n },\n fail: function(error) {\n alert(\"网络异常,请再次尝试!\");\n }\n });\n }\n }\n );\n }else {\n document.getElementById(this.field.divId).click();\n }\n },\n\n uploadFile(id) {\n let that = this;\n for(let i = 0; i < id.length; i++) {\n wx.uploadImage({\n localId: id[i],\n isShowProgressTips: 1,// 默认为1,显示进度提示\n success: function (res) {\n let serverId = res.serverId;\n that.$api.uploadWeixinPhoto(serverId,{\n onSucess: (response) => {\n if(response.data.data) {\n let val = response.data.data;\n let valArr = val.split(\"/\")\n that.picUrl = obpmConfig.obpmFilePath +\"/\";\n let obj = {\n name: valArr[valArr.length - 1],\n path: val,\n };\n that.field.value.push(obj);\n // let val = response.data.data;\n // that.photoURL.push(val);\n // that.field.value = that.photoURL;\n }\n }\n });\n },\n fail: function () {\n alert(\"网络异常,请再次尝试!\");\n }\n });\n }\n },\n\n close(index, item) {\n // this.list.splice(index, 1);\n // this.maxStatus = this.list == this.max ? false : true;\n this.partialRefreshData = [];\n let appId = this.$root.appid;\n let formId = this.field.formId;\n let docId = this.field.docId;\n let path = item;\n API.deleteUpload(appId, formId, docId, path, {\n onSucess: () => {\n this.field.value.splice(index, 1);\n this.maxStatus = this.field.value.length == this.field.limitNumber ? false : true;\n if (this.field.refreshOnChanged){\n this.$parent.refresh(this.field.id);\n }\n }\n });\n },\n\n async inputChange(e) {\n let files = e.target.files;\n for(let i=0; i this.field.maxsize) {\n document.getElementById(this.field.divId).value = \"\";\n let size = this.field.maxsize / 1024\n this.$toast(`上传图片大小不能超过${size}M`);\n this.fileSize = 0;\n return;\n }\n\n //限制上传数量\n let len = this.field.value.length + files.length;\n let maxLength = this.field.limitNumber; //最大上传数量 \n if (len > maxLength) {\n document.getElementById(this.field.divId).value = \"\";\n //alert(`最多允许上传${this.max}张`);\n this.$toast(`最多允许上传${maxLength}张图片`);\n return;\n }\n this.dialogVisible = true;\n [].slice.call(files, 0).map(this.upload);\n //let result = await Promise.all(uploadAll);\n document.getElementById(this.field.divId).value = \"\";\n },\n\n upload(file) {\n let nameArr = file.name.split(\".\");\n let name = nameArr[nameArr.length -1];\n let smallName = name.toLowerCase() //把后缀名转为小写,兼容苹果手机\n let arr = ['jpeg','png','gif','jpg'];\n let isSuffix = arr.indexOf(smallName) != -1;\n if(!isSuffix) {\n this.dialogVisible = false;\n Toast(\"图片类型错误\");\n return\n }\n let that = this;\n return new Promise(async () => {\n let form = new FormData();\n form.append(\"files\", file);\n let files = form;\n let actionType = this.imageType;\n let appId = this.$root.appid;\n let allowedTypes = this.field.fileType;\n let fieldId = this.id;\n let fileSaveMode = this.field.fileSaveMode;\n let path = this.field.path;\n this.$api.uploadFile(\n files, \n appId, \n allowedTypes, \n fieldId, \n fileSaveMode, \n path, \n actionType,\n {\n onSucess: response => {\n that.picUrl = obpmConfig.obpmFilePath +\"/\";\n let obj = {\n name: response.data.data[0].fileName,\n path: response.data.data[0].filePath,\n };\n \n that.field.value.push(obj);\n that.dialogVisible = false;\n if (that.field.refreshOnChanged){\n let havePar = false;\n let par = '';\n while(!havePar) {\n par = par + '.$parent';\n let url = 'that' + par + '.refresh';\n if(eval(url)) {\n let path = url + '(' + \"'\"+ this.id +\"'\" + ')';\n eval(path);\n break\n }\n }\n // that.$parent.refresh(that.id);\n }\n \n }\n }\n )\n });\n }\n }\n};\n",null]}