<template>
    <div class="top">
        <img src="../assets/1-6.png" alt="图标">
    </div>

    <div class="banner-search">
        <div class="wrap">
            <div class="search-box">
                <div class="search">
                    <form action="/market" class="form">
                        <el-icon class="icon"><Search /></el-icon>
                        <input type="text" name="keywords" class="input" placeholder="搜索算法">
                        <span class="icon-text">
                            <input type="submit" value="搜索" class="button-search">
                        </span>
                    </form>
                </div>
                <div class="hot-box">
                    <span class="changecolor">热门搜索：</span>
                    <span class="changecolor">热门搜索</span>
                    <span class="changecolor">热门搜索</span>
                    <span class="changecolor">热门搜索</span>
                    <span class="changecolor">热门搜索</span>
                    <span class="changecolor">热门搜索</span>
                    <span class="changecolor">热门搜索</span>
                    <span class="changecolor">热门搜索</span>
                    <span class="changecolor">热门搜索</span>
                </div>
            </div>
        </div>
    </div>

    <div class="introduce">
        <div class="auto-banner">
            <div class="intr-box">
                <div class="cont" v-for="item, id in allMes.list" :key="id">
                    <el-breadcrumb :separator-icon="ArrowRight">
                        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                        <el-breadcrumb-item :to="{ name: 'algorithm', params:{need:item.fieldList[0] } }">
                            {{ item.fieldList[0] }}
                        </el-breadcrumb-item>
                        <el-breadcrumb-item>{{ clName }}</el-breadcrumb-item>
                    </el-breadcrumb>
                    <div class="detail">
                        <div class="cont-text">
                            <h2>{{ clName }}</h2>
                            <div class="text-a">
                                {{ item.algorithm_description }}
                            </div>
                            <div class="tags-more">
                                <a href="" v-for="i in 3">{{ item.fieldList[i-1] }} <i class="line"></i></a>
                            </div>
                            <div class="btn-box">
                                <div class="btn1">
                                    <a href="" class="btn-box1">
                                        申请使用
                                    </a>
                                </div>
                                <div class="btn1">
                                    <a href="" class="btn-box1">
                                        申请使用
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="cont-img">
                            <img src="../assets/image/yanwu.jpg" width="570">
                            <el-icon class="videoplay"><VideoPlay /></el-icon>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="app-banner" v-for="item, id in allMes.list" :key="id">
        <div class="app-box">
            <div class="app-title">
                <h1>应用场景</h1>
            </div>
            <ul class="ul">
                <li class="li" v-for="i in useListlength" :key="id">
                    <h5>
                        <el-icon class="h5-icon"><Expand /></el-icon>
                        {{ item.useList[i-1] }}
                    </h5>
                </li>
            </ul>
        </div>
    </div>
</template>

<script setup lang="ts">
import { computed,reactive,ref } from 'vue'
import { useRoute } from 'vue-router';
import { getAllAlgorithm, login } from '@/api/uesr';
import { MyClass } from '@/api/interface';
import type { alList } from '@/api/interface';
import { ArrowRight } from '@element-plus/icons-vue'

const route = useRoute();

// 使用计算属性从route.params获取参数
const clName = computed(() => route.params.algorithm_name);
console.log("name", clName.value);

//登录用户名密码
const data = {
  username:"admin",
  password:"123456"
}

const allMes = reactive(new MyClass())
const useListlength = ref()

//显示所有算法
// login(data).then(() => {
getAllAlgorithm().then(res => {
    console.log("结果1");
    console.log(res);
    allMes.list = res.data.filter((item: alList) => item.algorithm_name === clName.value)
    console.log("final", allMes.list)
    useListlength.value = allMes.list[0].useList.length
    console.log('uselistlength',useListlength.value)
})
// })

</script>

<style scoped>

.top {
    background-color: #66666611;
}

.banner-search {
    background-color: #2B33A8;
}

.wrap {
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
}

.search-box {
    display: flex;
    flex-wrap: wrap;
    width: 1000px;
    margin-left: auto;
    margin-right: auto;
    padding-top: 20px;
    padding-bottom: 20px;
}

.form {
    background-color: rgba(255, 255, 255, 0.2);
    display: flex;
    box-shadow: 0px 0px 4px 0px rgb(43 51 168 / 20%)
}

.search {
    display: flex;
    flex-wrap: wrap;
    width: 1000px;
    height: 42px;
    justify-content: center;
}

.input {
    width: 720px;
    background: none;
    border: none;
    outline: none;
    /* height: 30px; */
}

input {
    color: white;
    font-size: 18px;
}

input::placeholder {
    color: white;
    font-size: large;
    position: relative;
    /* top: 24%; */
}

.icon-text {
    display: flex;
}
.icon {
    height: 100%;
    color: #ffffff;
    padding-left: 10px;
    padding-right: 10px;
}

.button-search {
    height: 100%;
    background: none;
    border: none;
    outline: none;
    background-color: #777DC8;
}

.hot-box {
    display: flex;
    margin-left: auto;
    margin-right: auto;
    margin-top: 20px;
}

.changecolor {
    color: white;
    padding-right: 20px;
}

.introduce {
    background-image: url('../assets/bg.jpg');
    width: 100%;
    height: 380px;
    background-size: cover;
}
.auto-banner {
    display: flex;
}
.intr-box {
    padding-top: 20px;
    padding-bottom: 20px;
    width: 100%;
    display: flex;
}
.cont {
    margin-left: auto;
    margin-right: auto;
    width: 1400px;
    max-width: 100%;
}
.map {
    width: 100%;
}
.map a{
    text-decoration: none;
    color: gray;
}

.detail {
    display: flex;
}
.cont-text {
    width: 50%;
}
.text-a {
    color: gray;
}
.tags-more {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 20px;
}
.tags-more a{
    text-decoration: none;
    color: gray;
}
.line{
    margin: 0 0.4em;
    height: 0.8em;
    width: 2px;
    background-color: #000000
}
.btn-box {
    display: flex;
}
.btn1 {
    border: 1px solid #2B33A8;
    width: 100px;
    text-align: center;
    margin-top: 50px;
    margin-right: 40px;
}
.btn-box1{
    color: gray;
    text-decoration: none;
}
.cont-img {
    margin-left: auto;
    margin-right: auto;
}
.videoplay {
    position: relative;
    bottom:40%;
    right: 50%;
    z-index: 2;
    color: white;
    font-size: 70px;
}
.app-banner {
    display: flex;
}
.app-box {
    width: 1400px;
    margin-left: auto;
    margin-right: auto;
}
.app-title {
    padding-top: 56px;
    padding-bottom: 32px;
}
.app-title h1{
    margin: 0px;
    font-size: 36px;
    display: flex;
    flex-wrap: wrap;
}
.ul {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding-left: 0px;
    gap:50px
}
.li {
    width: 28%;
}
.li h5 {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    font-size: 24px;
}
.h5-icon {
    width: 40px;
    margin-top: 5px;
    color: #2B33A8;
}

</style>