1 line
11 KiB
Plaintext
1 line
11 KiB
Plaintext
{"version":3,"file":"upload-image.js","sources":["../../../../../../src/sheep/components/s-uploader/upload-image.vue","../../../../../../uniComponent:/RDovQXBwL1dvcmsvYWRkci9hY2RyLXVpL3NyYy9zaGVlcC9jb21wb25lbnRzL3MtdXBsb2FkZXIvdXBsb2FkLWltYWdlLnZ1ZQ"],"sourcesContent":["<template>\r\n <view class=\"uni-file-picker__container\">\r\n <view class=\"file-picker__box\" v-for=\"(url, index) in list\" :key=\"index\" :style=\"boxStyle\">\r\n <view class=\"file-picker__box-content\" :style=\"borderStyle\">\r\n <image\r\n class=\"file-image\"\r\n :src=\"getImageUrl(url)\"\r\n mode=\"aspectFill\"\r\n @click.stop=\"previewImage(url, index)\"\r\n ></image>\r\n <view v-if=\"delIcon && !readonly\" class=\"icon-del-box\" @click.stop=\"delFile(index)\">\r\n <view class=\"icon-del\"></view>\r\n <view class=\"icon-del rotate\"></view>\r\n </view>\r\n <!-- <view v-if=\"item.errMsg\" class=\"file-picker__mask\" @click.stop=\"uploadFiles(item, index)\">\r\n 点击重试\r\n </view> -->\r\n </view>\r\n </view>\r\n <view v-if=\"list.length < limit && !readonly\" class=\"file-picker__box\" :style=\"boxStyle\">\r\n <view class=\"file-picker__box-content is-add\" :style=\"borderStyle\" @click=\"choose\">\r\n <slot>\r\n <view class=\"icon-add\"></view>\r\n <view class=\"icon-add rotate\"></view>\r\n </slot>\r\n </view>\r\n </view>\r\n </view>\r\n</template>\r\n\r\n<script>\r\nimport sheep from '@/sheep'\r\nexport default {\r\n name: 'uploadImage',\r\n emits: ['uploadFiles', 'choose', 'delFile'],\r\n props: {\r\n filesList: {\r\n type: [Array, String],\r\n default() {\r\n return []\r\n },\r\n },\r\n disabled: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n disablePreview: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n limit: {\r\n type: [Number, String],\r\n default: 9,\r\n },\r\n imageStyles: {\r\n type: Object,\r\n default() {\r\n return {\r\n width: 'auto',\r\n height: 'auto',\r\n border: {},\r\n }\r\n },\r\n },\r\n delIcon: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n readonly: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n },\r\n computed: {\r\n list() {\r\n if (typeof this.filesList === 'string') {\r\n if (this.filesList) {\r\n return [this.filesList]\r\n } else {\r\n return []\r\n }\r\n }\r\n return this.filesList\r\n },\r\n styles() {\r\n const styles = {\r\n width: 'auto',\r\n height: 'auto',\r\n border: {},\r\n }\r\n return Object.assign(styles, this.imageStyles)\r\n },\r\n boxStyle() {\r\n const { width = 'auto', height = 'auto' } = this.styles\r\n const obj = {}\r\n if (height === 'auto') {\r\n if (width !== 'auto') {\r\n obj.height = this.value2px(width)\r\n obj['padding-top'] = 0\r\n } else {\r\n obj.height = 0\r\n }\r\n } else {\r\n obj.height = this.value2px(height)\r\n obj['padding-top'] = 0\r\n }\r\n\r\n if (width === 'auto') {\r\n if (height !== 'auto') {\r\n obj.width = this.value2px(height)\r\n } else {\r\n obj.width = '33.3%'\r\n }\r\n } else {\r\n obj.width = this.value2px(width)\r\n }\r\n\r\n let classles = ''\r\n for (const i in obj) {\r\n classles += `${i}:${obj[i]};`\r\n }\r\n return classles\r\n },\r\n borderStyle() {\r\n const { border } = this.styles\r\n let obj = {}\r\n const widthDefaultValue = 1\r\n const radiusDefaultValue = 3\r\n if (typeof border === 'boolean') {\r\n obj.border = border ? '1px #eee solid' : 'none'\r\n } else {\r\n let width = (border && border.width) || widthDefaultValue\r\n width = this.value2px(width)\r\n let radius = (border && border.radius) || radiusDefaultValue\r\n radius = this.value2px(radius)\r\n obj = {\r\n 'border-width': width,\r\n 'border-style': (border && border.style) || 'solid',\r\n 'border-color': (border && border.color) || '#eee',\r\n 'border-radius': radius,\r\n }\r\n }\r\n let classles = ''\r\n for (const i in obj) {\r\n classles += `${i}:${obj[i]};`\r\n }\r\n return classles\r\n },\r\n },\r\n methods: {\r\n getImageUrl(url) {\r\n if (url.substr(0, 10) === 'blob:http:') {\r\n return url\r\n } else {\r\n return sheep.$url.cdn(url)\r\n }\r\n },\r\n uploadFiles(item, index) {\r\n this.$emit('uploadFiles', item)\r\n },\r\n choose() {\r\n this.$emit('choose')\r\n },\r\n delFile(index) {\r\n this.$emit('delFile', index)\r\n },\r\n previewImage(img, index) {\r\n const urls = []\r\n if (Number(this.limit) === 1 && this.disablePreview && !this.disabled) {\r\n this.$emit('choose')\r\n }\r\n if (this.disablePreview) return\r\n this.list.forEach((i) => {\r\n urls.push(this.getImageUrl(i))\r\n })\r\n\r\n uni.previewImage({\r\n urls,\r\n current: index,\r\n })\r\n },\r\n value2px(value) {\r\n if (typeof value === 'number') {\r\n value += 'px'\r\n } else {\r\n if (value.indexOf('%') === -1) {\r\n value = value.indexOf('px') !== -1 ? value : value + 'px'\r\n }\r\n }\r\n return value\r\n },\r\n },\r\n}\r\n</script>\r\n\r\n<style lang=\"scss\">\r\n.uni-file-picker__container {\r\n box-sizing: border-box;\r\n /* #ifndef APP-NVUE */\r\n display: flex;\r\n /* #endif */\r\n flex-wrap: wrap;\r\n margin: -5px;\r\n}\r\n\r\n.file-picker__box {\r\n position: relative;\r\n /* #ifndef APP-NVUE */\r\n box-sizing: border-box;\r\n // flex: 0 0 33.3%;\r\n width: 33.3%;\r\n height: 0;\r\n padding-top: 33.33%;\r\n /* #endif */\r\n}\r\n\r\n.file-picker__box-content {\r\n position: absolute;\r\n top: 0;\r\n right: 0;\r\n bottom: 0;\r\n left: 0;\r\n margin: 5px;\r\n overflow: hidden;\r\n border: 1px #eee solid;\r\n border-radius: 5px;\r\n}\r\n\r\n.file-picker__progress {\r\n position: absolute;\r\n right: 0;\r\n bottom: 0;\r\n left: 0;\r\n /* border: 1px red solid; */\r\n z-index: 2;\r\n}\r\n\r\n.file-picker__progress-item {\r\n width: 100%;\r\n}\r\n\r\n.file-picker__mask {\r\n position: absolute;\r\n top: 0;\r\n right: 0;\r\n bottom: 0;\r\n left: 0;\r\n /* #ifndef APP-NVUE */\r\n display: flex;\r\n align-items: center;\r\n /* #endif */\r\n justify-content: center;\r\n font-size: 12px;\r\n color: #fff;\r\n background-color: rgba(0, 0, 0, 0.4);\r\n}\r\n\r\n.file-image {\r\n width: 100%;\r\n height: 100%;\r\n}\r\n\r\n.is-add {\r\n /* #ifndef APP-NVUE */\r\n display: flex;\r\n /* #endif */\r\n align-items: center;\r\n justify-content: center;\r\n}\r\n\r\n.icon-add {\r\n width: 50px;\r\n height: 5px;\r\n background-color: #f1f1f1;\r\n border-radius: 2px;\r\n}\r\n\r\n.rotate {\r\n position: absolute;\r\n transform: rotate(90deg);\r\n}\r\n\r\n.icon-del-box {\r\n position: absolute;\r\n top: 3px;\r\n right: 3px;\r\n z-index: 2;\r\n /* #ifndef APP-NVUE */\r\n display: flex;\r\n /* #endif */\r\n align-items: center;\r\n justify-content: center;\r\n width: 26px;\r\n height: 26px;\r\n background-color: rgba(0, 0, 0, 0.5);\r\n border-radius: 50%;\r\n transform: rotate(-45deg);\r\n}\r\n\r\n.icon-del {\r\n width: 15px;\r\n height: 2px;\r\n background-color: #fff;\r\n border-radius: 2px;\r\n}\r\n</style>\r\n","import Component from 'D:/App/Work/addr/acdr-ui/src/sheep/components/s-uploader/upload-image.vue'\nwx.createComponent(Component)"],"names":["sheep","uni"],"mappings":";;;AAgCA,MAAK,YAAU;AAAA,EACb,MAAM;AAAA,EACN,OAAO,CAAC,eAAe,UAAU,SAAS;AAAA,EAC1C,OAAO;AAAA,IACL,WAAW;AAAA,MACT,MAAM,CAAC,OAAO,MAAM;AAAA,MACpB,UAAU;AACR,eAAO,CAAC;AAAA,MACT;AAAA,IACF;AAAA,IACD,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACD,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACD,OAAO;AAAA,MACL,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,SAAS;AAAA,IACV;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