<template>
	<view class="imgView">
		<view v-for="(url, index) in imagesUrl" :key="index">
			<image :src="url"  @tap="previewImage($event,index)" />
		</view>
	</view>
	
	
</template>

<script>
	import httpURL from '../common/httpURL.js';
	export default {
		props: {
			theId: {
				default: null,
				type: [String, Number]
			},
			theTag: {
				default: null,
				type: [String]
			},
			subTag: {
				default: null,
				type: [String]
			}
		},
		data() {
			return {
				imagesUrl:[]
			}
		},
		mounted() {
			this.loadImageUrl();
		},
		methods: {
			loadImageUrl() {
				uni.showLoading({
				    title: '加载中'  
				});
				this.$ajax.request({
					method: 'POST',
					url: 'upload/appDownload',
					data: {
						theId: this.theId,
						subTag: this.subTag,
						theTag: this.theTag
					},
					success:(data)=>{
						uni.hideLoading();
						if(data === null || data.length === 0){
							return ;
						}
						data.forEach(item =>{
							var url = `${httpURL.DOC_BASE_URL}doc/download?reqCode=${item.reqCode}&downCode=${item.downCode}`;
							this.imagesUrl.push(url);
						})
					}
				})
			},
			previewImage: function(e,index) {
				var current = e.target.dataset.src
				uni.previewImage({
					current: index,
					urls: this.imagesUrl
				})
			},
		}
	}
</script>

<style lang="less" scoped>
	image{
		border-width: 2rpx;
		border-color: rgb(229, 229, 229);
		border-style: solid;
		border-radius: 20rpx;
		width: 180rpx;
		height: 180rpx;
		margin-left: 25rpx;
	}
	.imgView{
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		margin-top: 30rpx;
	}
</style>
