<template>
	<image :style="{ width: size + 'px', height: size + 'px', flexShrink: 0 }" src="/static/copy.svg" mode="aspectFit" @click="handleCopy"></image>
</template>

<script>
export default {
	name: 'CopyIcon',
	props: {
		value: {
			type: String,
			required: false,
			default: ''
		},
		size: {
			type: Number,
			required: false,
			default: 14
		}
	},
	methods: {
		handleCopy() {
			const that = this;
			uni.setClipboardData({
				data: this.value.toString(),
				success: function () {
					uni.showToast({
						title: that.$t('common.success.copy'),
						icon: 'success',
						duration: 2000
					});
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
@import './index.scss';
</style>
