<style lang="scss" scoped>
	@import url("@/asset/css/flex.css");
    .schedule{
        height: 100vh;
    }
    .scheduleHeaderBox{
        background: linear-gradient(-30deg, #4FA9FF, #4779FF);
        box-shadow: 0rpx 5rpx 35rpx 0rpx #4C97FF;
    }
    .scheduleTitle{
        // position: relative;
        z-index: 3
    }
    .scheduleTitle.fixed{
        position: fixed;
        left: 0;
        top: 0;
        right: 0;
        z-index: 2;
        background: linear-gradient(-30deg, #4FA9FF, #4779FF);
    }
    .scheduleTitle.fixed .scheduleTsBox{
        top: 22rpx;
    }
    
    .schedule-Touxiang{
        width: 65rpx;
        height: 65rpx;
        background: #fff;
        border-radius: 50%;
        overflow: hidden;
    }
    .schedule-title{
        word-break: break-all;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
    }
    .triangle {
        width: 0;
        height: 0;
        border-left: 8rpx solid transparent;
        border-right: 8rpx solid transparent;
        border-top: 8rpx solid #fff;
    }
</style>
<template>
    <view style="height: 100vh;">
        <scroll-view class="scheduleBox" scroll-y="true"
        :enable-back-to-top="true" :enable-flex="true"
        @scroll="scroll" style="height: 100vh;">
            <view class="scheduleHeaderBox">
                <view class="scheduleTitle">
                    <headers textAlign="left" :title="pageTitle" color="#fff"></headers>
                    <view v-if="BaseInfo&&BaseInfo.length>1" class="PT10 row justify-center items-center colorFFF" 
                    @click="BaseInfo.length>1?optionVisible=true:''">
                        <text class="fz36">{{ BaseInfo[currentIndex].TCNUMS }}</text>
                        <view class="triangle ML10" v-if="BaseInfo.length>1"></view>
                    </view>
                    <view class="PX40 PY20">
                        <view class="column" style="border-radius: 8rpx;overflow: hidden;">
                            <view class="colorFFF relative column" 
                            style="height: 386rpx;background:url('https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638868977886703780.png') no-repeat;background-size: 100% 100%;">
                                <img class="absolute" style="width: 100%;height: 386rpx;" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638875686175608095.png"/>
                                <view class="absolute column" style="left: 0;right: 0;top: 0;bottom: 0;z-index: 2;">
                                    <view class="row items-center PX30 PT30">
                                        <view class="row items-center">
                                            <view class="schedule-Touxiang">
                                                <img src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638748795455095258.png" style="width: 65rpx;height: 65rpx;display: inline-block;"/>
                                            </view>
                                            <view class="schedule-name ML20">
                                                <view class="fz28">{{ BaseInfo&&BaseInfo[currentIndex].LeaderName?BaseInfo[currentIndex].LeaderName:'' }}</view>
                                                <view class="fz24">(领队)</view>
                                            </view>
                                        </view>
                                        <view class="row items-center ML50">
                                            <view class="schedule-Touxiang">
                                                <img src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638748795455095258.png" style="width: 65rpx;height: 65rpx;display: inline-block;"/>
                                            </view>
                                            <view class="schedule-name ML20">
                                                <view class="fz28">{{ BaseInfo&&BaseInfo[currentIndex].GuideName?BaseInfo[currentIndex].GuideName:'' }}</view>
                                                <view class="fz24">(导游)</view>
                                            </view>
                                        </view>
                                    </view>
                                    <view class="flex1"></view>
                                    <view class="schedule-title fz28 MB30 PX30">{{ BaseInfo&&BaseInfo[currentIndex].Titles?BaseInfo[currentIndex].Titles:'' }}</view>
                                    <view class="row PX30 justify-between items-center fz24 PB20">
                                        <view class="row items-center">
                                            <img style="width: 24rpx;height: 32rpx;display: inline-block;" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638875688769461022.png"/>
                                            <text class="ML20">{{ BaseInfo&&BaseInfo[currentIndex].StartCityNames?BaseInfo[currentIndex].StartCityNames:'' }}</text>
                                        </view>
                                        <view class="row items-center">
                                            <img style="width: 22rpx;height: 32rpx;display: inline-block;" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638875688811834355.png"/>
                                            <text class="ML20">{{ BaseInfo&&BaseInfo[currentIndex].TotalSeat?BaseInfo[currentIndex].TotalSeat:'' }}</text>
                                        </view>
                                    </view>
                                </view>
                            </view>
                            <view class="bgFFF PA30">
                                <view class="PB20 row justify-between items-center">
                                    <view class="color666">集合时间</view>
                                    <view class="color333">{{ BaseInfo&&BaseInfo[currentIndex].GatherTime?BaseInfo[currentIndex].GatherTime:'' }}</view>
                                </view>
                                <view class="PB20 row justify-between items-center">
                                    <view class="color666">出发时间</view>
                                    <view class="color333">{{ BaseInfo&&BaseInfo[currentIndex].FlightList?BaseInfo[currentIndex].FlightList[0].Departure_time:'' }}</view>
                                </view>
                                <view class="row justify-between items-center">
                                    <view class="color666">进出点</view>
                                    <view class="color333">{{ BaseInfo&&BaseInfo[currentIndex].InOut?BaseInfo[currentIndex].InOut:'' }}</view>
                                </view>
                            </view>
                        </view>
                    </view>
                    <scheduleHeader :titles="titles" :params="params" @change="getType"></scheduleHeader>
                </view>
                <view class="scheduleTitle fixed"
                :style="{ opacity: boxOption + '%' ,'display':boxOption<=0?'none':'show'}">
                    <headers textAlign="left" :title="pageTitle" color="#fff"></headers>
                    <scheduleHeader v-if="boxOption>0" :titles="titles" :params="params" @change="getType"></scheduleHeader>
                </view>
            </view>
            <infor1 v-if="params.type==1" :data="inforData1"></infor1>
            <infor2 v-if="params.type==2" :data="BaseInfo[currentIndex]"></infor2>
            <infor3 v-if="params.type==3" :data="BaseInfo[currentIndex].CommonReport"></infor3>
            <infor4 v-if="params.type==4" :data="BaseInfo[currentIndex].CommonReport"></infor4>
            <infor5 v-if="params.type==5" :data="BaseInfo[currentIndex].CommonReport"></infor5>
            <infor6 v-if="params.type==6" :data="BaseInfo[currentIndex].CommonReport"></infor6>
            <infor7 v-if="params.type==7" :data="shopList"></infor7>
            <infor8 v-if="params.type==8" :data="guestList"></infor8>
            <infor9 v-if="params.type==9" :data="JourneyTitle"></infor9>
        </scroll-view>
        <singleChoice v-if="optionVisible" 
       :current="optionObj.id"
       :list="optionList"
       @close="close" @change="popupCurrent"></singleChoice>
    </view>
</template>
<script>
import headers from "@/components/header/header";
import singleChoice from "./components/singleChoice";
import infor1 from "./components/schedule/infor1";
import infor2 from "./components/schedule/infor2";
import infor3 from "./components/schedule/infor3";
import infor4 from "./components/schedule/infor4";
import infor5 from "./components/schedule/infor5";
import infor6 from "./components/schedule/infor6";
import infor7 from "./components/schedule/infor7";
import infor8 from "./components/schedule/infor8";
import infor9 from "./components/schedule/infor9";
import scheduleHeader from "./components/schedule/header";
export default {
    components: {
        headers,
        singleChoice,
        infor1,
        infor2,
        infor3,
        infor4,
        infor5,
        infor6,
        infor7,
        infor8,
        infor9,
        scheduleHeader,
    },
    data() {
        return {
            pageTitle: '领队导游运行计划表',
            boxOption: 0,
            titleStyle: {
                opacity: 0,
            },
            scrollTop: 100,
            old: {
                scrollTop: 0
            },
            titles:[
                {
                    name:'相关信息',
                    id: 1,
                    val: 'refs1',
                    left: 0,
                },
                {
                    name:'航班信息',
                    id: 2,
                    val: 'refs2',
                    left: 0,
                },
                {
                    name:'车辆使用',
                    id: 3,
                    val: 'refs3',
                    left: 0,
                },
                {
                    name:'酒店使用',
                    id: 4,
                    val: 'refs4',
                    left: 0,
                },
                {
                    name:'餐食使用',
                    id: 5,
                    val: 'refs5',
                    left: 0,
                },
                {
                    name:'门票使用',
                    id: 6,
                    val: 'refs6',
                    left: 0,
                },
                {
                    name:'购物店',
                    id: 7,
                    val: 'refs7',
                    left: 0,
                },
                {
                    name:'旅客名单',
                    id: 8,
                    val: 'refs8',
                    left: 0,
                },
                {
                    name:'行程内容',
                    id: 9,
                    val: 'refs9',
                    left: 0,
                },
            ],
            msg:{
                TCIDs: '',
                NewCombinationNum: ''
            },
            datas: {},
            params:{
                type: 1,
            },
            scrollLeft: 0,
            currencyList: [],
            shopTypeList: [],
            BaseInfo:[],
            DMCStaticsCommon:{},
            JourneyTitle: [],
            PrincipalList: [],
            guestList: [],
            shopList: [],
            inforData1:{
                PrincipalList: [],
                DMCStaticsCommon: {}
            },
            datas: {},
            currentIndex: 0,
            optionVisible: false,
            optionObj:{},
            optionList: [],
        }
    },
    onLoad(option){
        if(option.TCIDs){
            this.msg.TCIDs = option.TCIDs
            this.init()
        }
    },
    created() {
        this.contentHeight = this.$utils.calcContentHeight(-40) + "px";
        this.mainColor = this.$uiConfig.mainColor;
    },
    mounted() {
        const that = this
        uni.getSystemInfo({
          success(res) {
            that.titleStyle = {
              paddingTop: `${res.statusBarHeight}px`
            };
          },
        });
        
    },
    methods: {
        close(){
            this.optionVisible = false
        },
        popupCurrent(value){
            this.optionVisible = false
            let findIndex = this.optionList.findIndex(x=>x.id==value)
            this.currentIndex = findIndex
            this.optionObj = this.optionList[findIndex]
        },
        getType(item){
            this.params = {
                type: item.id,
            }
        },
        init() {
            uni.showLoading()
            this.apipost("dmcstatistics_post_GetExtendLeaderAllStatics", this.msg, (res) => {
                if (res.resultCode == 1) {
                    this.datas = res.data;
                    this.BaseInfo = res.data.BaseInfo
                    this.DMCStaticsCommon = res.data.DMCStaticsCommon
                    this.JourneyTitle = res.data.JourneyTitle
                    this.PrincipalList = res.data.PrincipalList
                    this.guestList = res.data.guestList
                    this.shopList = res.data.shopList
                    this.optionList = []
                    this.BaseInfo.forEach((x,index) => {
                        this.optionList.push({
                            name: x.TCNUMS,
                            id: index+1
                        })
                    });
                    this.optionObj = this.optionList[0]
                    this.inforData1 = {
                        PrincipalList: [JSON.parse(JSON.stringify(this.PrincipalList[0]))],
                        DMCStaticsCommon: this.DMCStaticsCommon
                    }
                    let arrList = function(list){
                        list.forEach(x=>{
                            x.CreateByNameList=[]
                            x.HConfirmNameList=[]
                            x.BConfirmNameList=[]
                            x.DConfirmNameList=[]
                            x.TConfirmNameList=[]
                        })
                    }
                    arrList(this.inforData1.PrincipalList)
                    this.PrincipalList.forEach((item,index)=> {
                            let data = this.inforData1.PrincipalList[0]
                            let findIndex1 = data.CreateByNameList.findIndex(x=>x.name==item.CreateByName)
                            if(findIndex1==-1){
                                data.CreateByNameList.push({
                                    name: item.CreateByName,
                                    tel: item.CreateByMobile
                                })
                            }
                            
                            let findIndex2 = data.HConfirmNameList.findIndex(x=>x.name==item.HConfirmName)
                            if(findIndex2==-1){
                                data.HConfirmNameList.push({
                                    name:item.HConfirmName,
                                    tel:item.HConfirmMobile
                                })
                            }
                            
                            let findIndex3 = data.BConfirmNameList.findIndex(x=>x.name==item.BConfirmName)
                            if(findIndex3==-1){
                                data.BConfirmNameList.push({
                                    name:item.BConfirmName,
                                    tel:item.BConfirmMobile
                                })
                            }

                            let findIndex4 = data.DConfirmNameList.findIndex(x=>x.name==item.DConfirmName)
                            if(findIndex4==-1){
                                data.DConfirmNameList.push({
                                    name:item.DConfirmName,
                                    tel:item.DConfirmMobile
                                })
                            }

                            let findIndex5 = data.TConfirmNameList.findIndex(x=>x.name==item.TConfirmName)
                            if(findIndex5==-1){
                                data.TConfirmNameList.push({
                                    name:item.TConfirmName,
                                    tel:item.TConfirmMobile
                                })
                            }
                    })
                    uni.hideLoading()
                }
            }, (failed) => {
                uni.hideLoading()
                uni.showToast({
                    title: failed.message,
                    icon: "none",
                });
            }, (error) => {
                uni.hideLoading()
            })
        },
        scrollHandler(e){
            // console.log(e.detail.scrollLeft,'-----------')
            // this.scrollLeft = e.detail.scrollLeft
        },
        scroll(e) {
            this.old.scrollTop = e.detail.scrollTop
            this.boxOption = Math.floor((e.detail.scrollTop - 450) / 1.5);
            this.titleStyle.opacity =
                e.detail.scrollTop - 450 < 0 ?
                0 :
                Math.floor(e.detail.scrollTop - 450) / 100 > 1 ?
                1 :
                Math.floor(e.detail.scrollTop - 450) / 100;
                
        },
    }
}
</script>