1 line
4.3 KiB
Plaintext
1 line
4.3 KiB
Plaintext
|
{"version":3,"file":"su-image.js","sources":["../../../../../../src/sheep/ui/su-image/su-image.vue","../../../../../../uniComponent:/RDovQXBwL1dvcmsvYWRkci9hY2RyLXVpL3NyYy9zaGVlcC91aS9zdS1pbWFnZS9zdS1pbWFnZS52dWU"],"sourcesContent":["<template>\r\n <image\r\n v-if=\"!state.isError\"\r\n class=\"su-img\"\r\n :style=\"customStyle\"\r\n :draggable=\"false\"\r\n :mode=\"mode\"\r\n :src=\"sheep.$url.cdn(src)\"\r\n @tap=\"onImgPreview\"\r\n @load=\"onImgLoad\"\r\n @error=\"onImgError\"\r\n ></image>\r\n</template>\r\n\r\n<script setup>\r\n/**\r\n * 图片组件\r\n *\r\n * @property {String} src \t\t\t\t\t\t- 图片地址\r\n * @property {Number} mode \t\t\t\t\t\t- 裁剪方式\r\n * @property {String} isPreview \t\t \t\t- 是否开启预览\r\n * @property {Number} previewList \t\t\t\t- 预览列表\r\n * @property {String} current \t\t \t\t\t- 预览首张下标\r\n *\r\n * @event {Function} load \t\t\t\t\t\t- 图片加载完毕触发\r\n * @event {Function} error \t\t\t\t\t\t- 图片加载错误触发\r\n *\r\n */\r\n\r\nimport { reactive, computed } from 'vue'\r\nimport sheep from '@/sheep'\r\n\r\n// 组件数据\r\nconst state = reactive({\r\n isError: false,\r\n imgHeight: 600,\r\n})\r\n\r\n// 接收参数\r\nconst props = defineProps({\r\n src: {\r\n type: String,\r\n default: '',\r\n },\r\n errorSrc: {\r\n type: String,\r\n default: '/static/img/shop/empty_network.png',\r\n },\r\n mode: {\r\n type: String,\r\n default: 'widthFix',\r\n },\r\n isPreview: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n previewList: {\r\n type: Array,\r\n default() {\r\n return []\r\n },\r\n },\r\n current: {\r\n type: Number,\r\n default: -1,\r\n },\r\n height: {\r\n type: Number,\r\n default: 0,\r\n },\r\n width: {\r\n type: Number,\r\n default: 0,\r\n },\r\n radius: {\r\n type: Number,\r\n default: 0,\r\n },\r\n})\r\n\r\nconst emits = defineEmits(['load', 'error'])\r\n\r\nconst customStyle = computed(() => {\r\n return {\r\n height: (props.height || state.imgHeight) + 'rpx',\r\n width: props.width ? props.width + 'rpx' : '100%',\r\n borderRadius: props.radius ? props.radius + 'rpx' : '',\r\n }\r\n})\r\n\r\n// 图片加载完成\r\nfunction onImgLoad(e) {\r\n if (props.height === 0) {\r\n state.imgHeight = (e.detail.height / e.detail.width) * 750\r\n }\r\n}\r\n\r\n// 图片加载错误\r\nfunction onImgError(e) {\r\n state.isError = true\r\n emits('error', e)\r\n}\r\n\r\n// 预览图片\r\nfunction onImgPreview() {\r\n if (!props.isPreview) return\r\n uni.previewImage({\r\n urls: props.previewList.length < 1 ? [props.src] : props.previewList,\r\n current: props.current,\r\n longPressActions: {\r\n itemList: ['发送给朋友', '保存图片', '收藏'],\r\n success: function (data) {\r\n console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片')\r\n },\r\n fail: function (err) {\r\n console.log(err.errMsg)\r\n },\r\n },\r\n })\r\n}\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n \r\n.su-img {\r\n position: relative;\r\n display: block;\r\n width: 100%;\r\n height: 100%;\r\n}\r\n</style>\r\n","import Component from 'D:/App/Work/addr/acdr-ui/src/sheep/ui/su-image/su-image.vue'\nwx.createComponent(Component)"],"names":["reactive","computed","uni"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,UAAM,QAAQA,cAAAA,SAAS;AAAA,MACrB,SAAS;AAAA,MACT,WAAW;AAAA,IACb,CAAC;AAGD,UAAM,QAAQ;AAyCd,UAAM,QAAQ;AAEd,UAAM,cAAcC,cAAQ,SAAC,MAAM;AACjC,aAAO;AAAA,QACL,SAAS,MAAM,UAAU,MAAM,aAAa;AAAA,QAC5C,OAAO,MAAM,QAAQ,MAAM,QAAQ,QAAQ;AAAA,QAC3C,cAAc,MAAM,SAAS,MAAM,SAAS,QAAQ;AAAA,MACrD;AAAA,IACH,CAAC;AAGD,aAAS,UAAU,GAAG;AACpB,UAAI,MAAM,WAAW,GAAG;AACtB,cAAM,YAAa,EAAE,OAAO,SAAS,EAAE,OAAO,QAAS;AAAA,MACxD;AAAA,IACH;AAGA,aAAS,WAAW,GAAG;AACrB,YAAM,UAAU;AAChB,YAAM,SAAS,CAAC;AAAA,IAClB;AAGA,aAAS,eAAe;AACtB,UAAI,CAAC,MAAM;AAAW;AACtBC,oBAAAA,MAAI,aAAa;AAAA,QACf,MAAM,MAAM,YAAY,SAAS,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM;AAAA,QACzD,SAA
|