<script setup lang="ts">
import CpmdHeader from '@/components/CpmdHeader.vue';

import { onMounted, onUnmounted, ref } from 'vue'

import pdf3 from '../assets/cognize/goNogo.pdf'
import pdf4 from '../assets/cognize/dtc.pdf'

import { useRoute, useRouter } from 'vue-router';
import { queryCognizeDetailApi } from '@/api/plan';
import { userInfoStore } from '@/stores';


const router = useRouter()
const route = useRoute()



const flag = ref<string>('')
const planName = ref<string>('')
const planId = ref<string>('')
const type = ref<string>('')

const cognizeDetail = ref<any>({})
const isPass = ref<boolean>(false)
// 查看PDF
//刚进入页面就将高度设置为页面需要的
onMounted(() => {

    //获取参数传过来的ID

    //获取参数传过来的planId

    flag.value = route.params.flag as string;
    planId.value = route.params.planId as string
    planName.value = route.params.planName as string
    type.value = route.params.type as string
    if (flag.value == 'ETB01') {
        isPass.value = userInfoStore().isPassETB01
    }
    if (flag.value == 'FDOT') {
        isPass.value = userInfoStore().isPassDot
    }
    if (flag.value == 'EMOTION_STROOP') {
        isPass.value = userInfoStore().isStroop
    }
    //根据flag 查询认知任务详情

    //进到界面开始轮询
    if (type.value == '1') {
        queryScaleDetail()
    }
})
const queryScaleDetail = async () => {
    //根据flag查询量表详情
    let res: any = await queryCognizeDetailApi(flag.value)
    cognizeDetail.value = res.data

}
const centerDialogVisible = ref<boolean>(false)
const viewPDF = () => {
    centerDialogVisible.value = true
}
// vue3+vite   实现动态加载图片
const requireImg = (name: string) => {
    // return new URL(`${path}`, import.meta.url).href
    // ../assets/cognize/goNogo.pdf
    return new URL(`../assets/cognize/${name}.pdf`, import.meta.url).href
}

const startCog = (val: number) => {
    // router.push(
    //     {
    //         name: 'shapeIntuitionRandom',
    //         params: { planId: planId.value, planName: planName.value, flag: flag.value, flagName: cognizeDetail.value.name, formalTest: val }
    //     })

    //更改到 跳转到人脸表情这里的认知任务
    if (flag.value == 'ETB01') {
        router.push(
            {
                name: 'ETBexperimentNew',
                params: { planId: planId.value, planName: planName.value, flag: flag.value, flagName: cognizeDetail.value.name, formalTest: val }
            })
    }
    if (flag.value == 'FDOT') {
        router.push(
            {
                name: 'cognizeFaceDot',
                params: { planId: planId.value, planName: planName.value, flag: flag.value, flagName: cognizeDetail.value.name, formalTest: val }
            })
    }

    if (flag.value == 'EMOTION_STROOP') {
        router.push(
            {
                name: 'Stroop',
                params: { planId: planId.value, planName: planName.value, flag: flag.value, flagName: cognizeDetail.value.name, formalTest: val }
            })
    }



    // if (num.value == '3') {
    //     router.push({ name: 'cognizeGoNoGo', params: { currentType: val } })
    // } else if (num.value == '4') {
    //     router.push({ name: 'cognizeFaceDot', params: { currentType: val } })
    // }

}

//界面销毁函数


//轮旋切换页面的方法



//退出页面销毁 方法
onUnmounted(() => {

})




</script>

<template>
    <div class="home_header_out" ref="homeHeaderOut">
        <div class=" home_header_inner">
            <CpmdHeader />
            <div style="text-align: center;">
                <!-- <img class="xlts_img" style="margin-top:20px" src="../assets/home/other_text.png" /> -->
            </div>
        </div>
        <div class="kply">
            <div class="kply_inner">
                <div style="padding :20px 40px">
                    <div class="cognize_title">
                        {{ cognizeDetail.name }}
                    </div>
                    <div class="cognize_img_out">
                        <!-- <img src="../assets/kepu/czscz_default.png" width=" 100px" style="margin-right: 20px;" /> -->
                        <!-- <img src="../assets/cognize/c2.png" v-show="num == '4'" width="100px"
                            style="margin-right: 20px;" /> -->
                        <div class="cognize_des">
                            <span class="cpjs">测评介绍：</span>
                            <span class="cpjs_detail">{{ cognizeDetail.testExplain }}</span>
                        </div>

                    </div>
                    <div class="cpll">
                        <span class="cpll_title">理论：</span>
                        <span class="cpll_detail">{{ cognizeDetail.theory }}</span>
                    </div>
                    <div class="czsm">
                        <span class="czsm_title">操作说明：</span>
                        <span class="czsm_detail">
                            {{ cognizeDetail.description }}
                            {{ cognizeDetail.testDescription }}
                        </span>
                    </div>

                    <div class="cognize_title2"> {{ cognizeDetail.name }}演示视频：</div>

                    <div class="cognize_video">
                        <!-- poster="../assets/cognize/bg_ty.png" -->
                        <video width="60%" height="100%" controls style="border-radius: 40px;">
                            <source src="../assets/cognize/yd.mp4" type="video/mp4">
                            <!-- <source src="movie.ogg" type="video/ogg"> -->
                            您的浏览器不支持 video 标签。
                        </video>
                    </div>
                    <div class="scale_button">

                        <div class="scale_button_inner" v-show="!isPass">
                            <div class="scale_button_self" @click="startCog(0)">练习测试
                            </div>
                        </div>
                        <div :span="12" class="scale_button_inner" v-show="isPass">
                            <div class="scale_button_self" @click="startCog(1)">开始测试</div>
                        </div>

                    </div>


                    <div class="pdf_op">
                        <div class="pdf_sc">
                            <img @click="viewPDF" src="../assets/cognize/pdf.png" width="30px"
                                style="margin-right:10px" />
                            <div @click="viewPDF">测试手册</div>
                        </div>
                        <div class="pdf_sc">
                            <!-- <img @click="viewPDF" width="40px" src="../assets/cognize/yan.png">
                            <div @click="viewPDF" class="view">预览</div> -->
                        </div>
                    </div>
                    <div class="reference_cla" v-if="cognizeDetail.reference">
                        <div class="reference_title">参考文献:</div>
                        <div class="reference_detail" v-for="item, index in cognizeDetail.reference.split('//')"
                            :key="item">
                            <div>[{{ index + 1 }}] </div>
                            <div> {{ item }}</div>
                        </div>
                    </div>


                </div>
            </div>
        </div>
        <el-dialog v-model="centerDialogVisible" title="预览" width="90%" top="2vh" center>
            <span>
                <!-- :src="requireImg('../assets/cognize/goNogo.pdf')" -->
                <!-- <embed width="100%" height=500px v-show="num == '3'" src='../assets/cognize/goNogo.pdf'>

                </embed> -->

                <!-- <embed width="100%" height=500px v-show="num == '3'" :src="pdf3">
                </embed> -->
                <embed width="100%" height=700px :src="requireImg('yd')">
                </embed>
                <!-- <embed width="100%" height=500px v-show="num == '4'" :src="pdf4">
                </embed> -->
            </span>
        </el-dialog>

    </div>

    <!-- <div class="cognize_real_out">

        我是认知任务
    </div> -->
</template>
<style lang="scss" scoped>
.cognize_real_out {
    background-color: #b64d4d;
    color: #41348a;
    position: fixed;
    z-index: 100;
    top: 0;
    width: 100vw;
    height: 100vh;
}

.home_header_out {
    padding-bottom: 60px;
    width: 100%;
    min-width: 1200px;
    background-image: url('../assets/home/bg_ty.png');
    background-repeat: no-repeat;
    background-size: contain;
    background-color: #B3F1DA; //估计是需要动态

    .home_header_inner {
        min-height: 1;
        left: 0;
        right: 0;
        margin: auto;
        width: 1200px;

        .xlts_img {
            height: 40px;
        }
    }

    .kply {
        width: 100%;
        margin-top: 20px;

        .kply_inner {
            min-height: 500px;
            left: 0;
            right: 0;
            margin: auto;
            width: 860px;
            // padding: 20px 20px;
            background-color: #ffffff;
            border-radius: 40px;

            .reference_cla {
                margin-top: 10px;

                .reference_title {
                    font-size: 14px;
                    color: #a9a9a9;
                    line-height: 24px;
                }

                .reference_detail {
                    font-size: 14px;
                    color: #a9a9a9;
                    line-height: 24px;
                    letter-spacing: 3px;
                    display: flex;

                }
            }

            .cpll {
                margin-top: 10px;

                .cpll_title {
                    font-size: 14px;
                    color: #48D68E;
                    font-weight: 700;
                }

                .cpll_detail {
                    font-size: 14px;
                    letter-spacing: 3px;
                    line-height: 24px;
                }
            }

            .czsm {
                margin-top: 10px;

                .czsm_title {
                    color: #48D68E;
                    font-weight: 700;
                    line-height: 24px;
                    font-size: 14px;
                }

                .czsm_detail {
                    line-height: 24px;
                    font-size: 14px;
                    letter-spacing: 3px;
                }
            }

            .cognize_title {

                font-size: 20px;
                letter-spacing: 3px;
                font-weight: 700;
                margin-bottom: 10px;
            }

            .cognize_title2 {
                font-size: 20px;
                letter-spacing: 3px;
                // font-weight: 700;
                margin-top: 10px;
                margin-bottom: 20px;
            }

            .cognize_img_out {
                display: flex;
                justify-content: center;

                .cognize_des {
                    letter-spacing: 2px;
                    line-height: 20px;
                    font-size: 16px;

                    .cpjs {
                        color: #48D68E;
                        font-weight: 700;
                        font-size: 14px;
                        line-height: 24px;
                    }

                    .cpjs_detail {
                        line-height: 24px;
                        letter-spacing: 3px;
                        font-size: 14px;
                    }
                }
            }

            .cognize_video {
                display: flex;
                justify-content: center;
            }

            .pdf_op {
                margin-top: 20px;
                display: flex;
                justify-content: space-between;
                align-items: center;

                .pdf_sc {
                    display: flex;
                    // justify-content: space-between;
                    align-items: center;
                    cursor: pointer;

                    .view {
                        margin-left: 10px;
                        color: #3E43FF;
                    }
                }
            }

            .scale_button {
                margin-top: 30px;
                margin-bottom: 20px;
                display: flex;
                justify-content: space-around;

                .scale_button_inner {
                    text-align: center;
                    display: flex;
                    justify-content: center;

                    .scale_button_self {

                        border-radius: 12px;
                        border: 3px solid #48D68E;
                        color: #ffffff;
                        background-color: #000000;
                        margin-right: 20px;
                        padding: 10px 40px;
                        cursor: pointer;
                        display: flex;
                        align-items: center;
                        font-size: 16px;
                    }
                }
            }
        }
    }


}



.home_mid {
    // background-color: blanchedalmond;
    width: 1200px;
    left: 0;
    right: 0;
    margin: auto;
    margin-top: 40px;
    // position: relative;




    .kepu_title {
        text-align: center;

        font-size: 50px;
        color: #111111;
        line-height: 95px;

        // width: 100%;
        // left: 0;
        // right: 0;
        // margin: auto
    }

    .kepu_title_sub {
        margin-top: 30px;
        text-align: center;
        font-size: 28px;
        color: #48D68E;
        line-height: 26px;
    }

    .man1_group {
        margin-top: 60px;
        height: 100%;
        display: flex;

        .man1 {
            position: relative;
            width: 327px;
            // height: 100%;

            // height: 100%
            .man1_img {
                position: absolute;
                bottom: 0;
                /* bottom: 0px; */
                /* height: auto; */
                width: 100%;
                left: 100px
            }

        }

        .des {
            border: #48D68E solid 5px;
            border-radius: 40px;
            padding: 20px;
            letter-spacing: 6px;
            flex: 1;

            .des_inner {
                border: 1px dashed #48D68E;
                border-radius: 40px;
                padding-bottom: 40px;
                padding-top: 30px;
                padding-left: 100px;
                padding-right: 20px;
                letter-spacing: 6px;
                font-weight: normal;
                font-size: 24px;
                color: #333333;
                line-height: 40px;
            }
        }
    }

    .man2_group {
        margin-top: 60px;
        height: 100%;
        display: flex;

        .man2 {
            position: relative;
            width: 327px;
            // height: 100%;

            // height: 100%
            .man2_img {
                position: absolute;
                bottom: 0;
                /* bottom: 0px; */
                /* height: auto; */
                width: 100%;
                left: -100px
            }

        }

        .des2 {
            border: #48D68E solid 5px;
            border-radius: 40px;
            padding: 20px;
            letter-spacing: 6px;
            flex: 1;

            .des2_inner {
                border: 1px dashed #48D68E;
                border-radius: 40px;
                padding-bottom: 40px;
                padding-top: 30px;
                padding-left: 20px;
                padding-right: 100px;
                letter-spacing: 6px;
                font-weight: normal;
                font-size: 24px;
                color: #333333;
                line-height: 40px;
            }
        }
    }

    .get_more {
        text-align: center;

        img {
            width: 300px;
            margin-top: 60px;
            margin-bottom: 60px;
        }
    }
}

// .home_footer_out {
//     width: 100%;
//     background-color: #000000;
// }</style>
