var vms = Vue.component("amplify-jsfh", {
    template: `
        <div>
            <div class="amplify-title-icon">
                <img src="https://fileimg.makalu.cc/WEB_DBD5893450984E50AFF356EF44FF4139.png"  @click="openAmplify">
            </div>
            <transition name="el-zoom-in-top">
                <div class="amplify-fixed" v-show="show"  style="display: none" @click="closeAmplifyAll">
                    <div class="amplify-max">
                        <div class="amplify-title">
                            <div>技术复核</div>
                            <div class="amplify-close" @click="closeAmplify"><i class="el-icon-close"></i></div>
                        </div>   
                        <div class="amplify-content">
                            <!--内容区域-->  
                              <div style="padding-top: 35px;">
                                                    <div class="amplify-rank-chart">
                                                        <!--<div class="rank-chart-title" v-cloak>****技术总结({{srcList.length}})</div>-->
                                                    </div>
<!--                                                   图片展示-->
                             <div @mouseout="costMouseout"  @mouseover="costMouseover">
                                        <slot></slot> 
                                        <div class="amplify-bzh-flex">
                                            <div class="amplify-bzh-btn">
                                                <img src="/images/carousel_left.png" @click="carouselLeft">
                                            </div>
                                            <div class="amplify-bzh-content"  ref="rollImgMax" :style="{'width': number*400+'px'}">
                                                <div class="amplify-bzh-content-img" v-for="item in list">
                                                    <el-image style="width: 360px; height: 360px"
                                                              :src="item" fit="cover" :preview-src-list="list"></el-image>
                                                </div>
                                            </div>
                                            <div class="amplify-bzh-btn">
                                                <img src="/images/carousel_right.png" @click="carouselRight">
                                            </div>
                                        </div>
                                    </div>
                              </div>
                        </div>      
                    </div>
                </div>
            </transition>
        </div>
    `,
    props: {

    },
    data() {
        return {
            show:false,
            costIndex:0,
            imgRollInterval:undefined,
            direction:'left',
            list:[],
            number:2,
            projectId:JSON.parse(window.localStorage.getItem("data")).id,
        }
    },
    mounted(){
        // 图片轮播 定时器
        this.imgRollInterval = setInterval(this.imgRoll,5000);
    },
    methods: {
        openAmplify(){
            this.show = true
            this.getTypeSonListB()
        },
        closeAmplify(){
            this.show = false
        },
        closeAmplifyAll(e){
            if(e.target.className == 'amplify-fixed'){
                this.show = false
            }
        },
        getTypeSonListB() {
            this.list = []
            axios.post("/system/photoTechnicalReview/getPhotoTechnicalReview",{projectId:this.projectId}).then(res => {
                var list = []
                res.data.rows.forEach((item)=>{
                    list.push(item.photoUrl)
                })
                this.list = list
            })
        },
        carouselLeft(){
            this.direction = 'left'
            this.manufacturingCostRoll()
        },
        carouselRight(){
            this.direction = 'right'
            this.manufacturingCostRoll()
        },
        manufacturingCostRoll(){
            var width = $(".bzh-content-img").innerWidth()
            if(this.direction == 'right'){
                if(this.costIndex == this.list.length - this.number){
                    this.costIndex = 0
                }else{
                    this.costIndex = this.costIndex + 1
                }
            }else{
                if(this.costIndex == 0){
                    this.costIndex = this.list.length - this.number
                }else{
                    this.costIndex = this.costIndex - 1
                }
            }
            console.log(this.costIndex)
            $(this.$refs.rollImgMax).animate({scrollLeft:(this.number*width*this.costIndex)+'px'})
            this.direction = 'right'
        },
        imgRoll(){
            var width = $(".bzh-content-img").innerWidth()
            if(this.costIndex == this.list.length - this.number){
                this.costIndex = 0
            }else{
                this.costIndex = this.costIndex + 1
            }
            $(this.$refs.rollImgMax).animate({scrollLeft:(this.number*width*this.costIndex)+'px'})
        },
        costMouseover(){
            clearInterval(this.imgRollInterval);
        },
        costMouseout(){
            this.imgRollInterval=setInterval(this.imgRoll,5000);
        },
    },
    watch:{

    },
})