<template>
	<view class="total-page page-box task-bg page-env-20">
		<Nav title="上传征信" :genre="1" is_fixed></Nav>
		<view class="p-lr30 p-t10 container-box">
			<view><text>已上传（{{formData.credit_img.length}}页）</text></view>
			<view class=" container m-t20">
				<view class="column-c justify-center item-box" @click="onUpload">
					<image class="wh-45 m-b10" src="/page_task/static/img/information/credit.png" mode="aspectFill"></image>
					<text class="text-color-666 size-26">上传征信</text>
				</view>
				<view class="item-box" v-for="(item,index) in formData.credit_img">
						<image style="width: 100%;height: 240rpx;" :src="item" @click.stop="previewImage(index)"
						mode="aspectFill">
					</image>
					<image class="wh-30 delete_iocn" src="/page_task/static/img/information/blank_delete.png" @click.stop="delImg(index)" mode=""></image>
				</view>
			</view>
		</view>
    <EnButton :text="'完成'" @onSubmit="onSubmit" ></EnButton>
	</view>
</template>

<script>
	import tools from "@/service/tools";

  export default {
		data() {
			return {
        formData:{
          'credit_img': [ ],
          'deal_data': [],
          'overdue_data': [],
          'query_data': [],
        },
        srcList:[],
        isStart:false,
        creditKey:[]
			}
		},
    onLoad() {
      let creditData = uni.getStorageSync('creditData')
      let creditKey = uni.getStorageSync('clientInfoKey')
      this.formData = creditData
      this.creditKey = creditKey
      setTimeout(()=>{
        this.isStart=true
      },500)

    },
    onShow() {
      if(this.isStart){
        this.formData.credit_img = uni.getStorageSync('creditImg');
      }

    },
    mounted() {

    },
    methods: {
      previewImage(index){
        uni.previewImage({
          urls: this.formData.credit_img,
          current: index,
          success: () => {

          }
        })
      },
      // 完成
      onSubmit() {

        uni.$emit("putCreditData", this.formData);
        setTimeout(()=>{
          tools.leftClick()
        },50)
      },
      delImg(index){
        this.formData.credit_img.splice(index,1)
      },
			onUpload() {
        uni.setStorageSync('creditImg', this.formData.credit_img)
        uni.navigateTo({
          url: `/page_task/credit_upload/camera`
        })
			},

		}
	}
</script>

<style lang="scss" scoped>
	.container {
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		gap: 10px;

		.item-box {
			flex: 0 0 calc(50% - 5px);
			box-sizing: border-box;
			border: 1rpx dashed #999999;
			height: 240rpx;
			border-radius: 10rpx;
			text-align: center;
			background: #F7F9FE;
			position: relative;

			.delete_iocn {
				position: absolute;
				right: -12rpx;
				top: -12rpx;
			}
		}
	}
</style>
