index.js 2.8 KB
import pageInit from "../../../minixs/pageInit.js";
import {Information} from "../../../../assets/img/data/serviceSecond.js";
export default {
    name: 'information',
    template: '',
    mixins:[pageInit],
    components: {},
    props: [],
    setup(props, {attrs, slots, emit}) {
        let InformationData=Information();
        //页签高亮显示
        let tabActive=Vue.ref(0);
        //优势hover显示的图片
        let advantageImg=Vue.ref();
        let setAdvantage=()=>{
            if(InformationData.data && InformationData.data.length>0){
                InformationData.data.map(item=>{
                    if(item.type=='advantage'){
                        advantageImg.value=item.dataSecond[0].img
                    }
                })
            }
        }
        setAdvantage();
        //优势hover高亮显示
        let advantageActive=Vue.ref(0);
        //优势是否hover
        let isMouseover=Vue.ref(false);
        //优势鼠标移入事件
        let showHover=(indexA)=>{
            advantageActive.value=indexA;
            isMouseover.value=true;
            if(InformationData.data && InformationData.data.length>0){
                InformationData.data.map(item=>{
                    if(item.type=='advantage'){
                        advantageImg.value=item.dataSecond[indexA].img
                    }
                })
            }
        }
        //优势鼠标移出事件
        let hideHover=()=>{
            advantageActive.value=0;
            isMouseover.value=false;
            setAdvantage();
        }
        //页签点击跳转到对应的目标
        let goItemType=(type)=>{
            let top=$("[data-type='"+type+"']").offset().top;
            let total=top-100;
            let distance = document.documentElement.scrollTop || document.body.scrollTop
            //计算每一小段的距离
            let step=total/6;
            (function smoothDown (){
                if(distance < total){
                    distance += step;
                    //移动一小段
                    document.body.scrollTop =distance;
                    document.documentElement.scrollTop = distance;
                    //设定每一次跳到的时间间隔为10ms
                    setTimeout(smoothDown,10)
                }else{
                    //限制股东停止的距离
                    document.body.scrollTop = total;
                    document.documentElement.scrollTop = total;
                }
            })()
        }
        // 挂载完
        Vue.onMounted(() => {

        })

        return {
            InformationData,
            tabActive,
            advantageImg,
            advantageActive,
            isMouseover,
            showHover,
            hideHover,
            setAdvantage,
            goItemType
        }
    }

}