<template>
    <div class="goods_topic">
        <Header></Header>
        <section class="section">
            <div class="section__header">
                <div class="container">
                    <el-breadcrumb separator="/">
                        <el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
                        <el-breadcrumb-item>商品专题</el-breadcrumb-item>
                    </el-breadcrumb>
                </div>
            </div>
            <div class="course_btns">
                <div class="meun_btns">
                    <div class="btns" @click="changeCouMeun()">
                        课程导航
                    </div>
                    <div class="slide-list">
                        <div
                            class="slide-list__item"
                            v-for="(type, typeItem) in typeList"
                            :key="'type' + typeItem"
                        >
                        <div class="title" @click="goCourse(type)">
                            {{ type.educationName }}
                        </div>
                        <ul class="nav">
                            <li
                                v-for="(slideItem, slideIndex) in slideList[typeItem]"
                                :key="'item' + slideIndex"
                                @click="goCourse(slideItem)"
                            >
                            <div class="text">
                                {{ slideItem.aliasName }}
                            </div>
                            </li>
                        </ul>
                        </div>
                    </div>
                </div>
                
            </div>
            <div class="mains">
                <div class="content_up">
                    <div class="banner_one"></div>
                    <div class="banner_two">
                        <catalogue :goodsId='goodsId' :topicId="topicId"></catalogue>
                    </div> 
                </div>
                <div class="topic_detail">
                    <div class="titles">
                        <img src="@/assets/topic/icon_left.png" alt="" />
                        <span class="scheme">通关方案</span>
                        <img src="@/assets/topic/icon_right.png" alt="" />
                    </div>
                    <div class="min_title">2023年二级建造师考前培训</div>
                    <div class="details">
                        <div class="detail_one">
                            <div class="deatil_titles">黄金基础班</div>
                            <div class="detail_mid">
                                <div class="mid_item">
                                    <div class="lefts">全科</div>
                                    <div class="rights">
                                        <span class="price">￥980</span>
                                        <div class="right_buy"  @click="togoBuy(1, 1)">立即购买</div>
                                    </div>
                                </div>
                                <div class="mid_item">
                                    <div class="lefts">公共单科</div>
                                    <div class="rights">
                                        <span class="price">￥350</span>
                                        <div class="right_buy"  @click="togoBuy(2, 1)">立即购买</div>
                                    </div>
                                </div>
                                <div class="mid_item">
                                    <div class="lefts">实务单科</div>
                                    <div class="rights">
                                        <span class="price">￥500</span>
                                        <div class="right_buy"  @click="togoBuy(3, 1)">立即购买</div>
                                    </div>
                                </div>
                            </div>
                            <div class="down_img">
                                <img class="l_img" src="@/assets/topic/detail_one.png" alt="" />
                            </div>
                        </div>
                        <div class="detail_one">
                            <div class="deatil_titles two">钻石强化班</div>
                            <div class="detail_mid">
                                <div class="mid_item">
                                    <div class="lefts">全科</div>
                                    <div class="rights">
                                        <span class="price">￥1280</span>
                                        <div class="right_buy"  @click="togoBuy(1, 2)">立即购买</div>
                                    </div>
                                </div>
                                <div class="mid_item">
                                    <div class="lefts">公共单科</div>
                                    <div class="rights">
                                        <span class="price">￥450</span>
                                        <div class="right_buy"  @click="togoBuy(2, 2)">立即购买</div>
                                    </div>
                                </div>
                                <div class="mid_item">
                                    <div class="lefts">实务单科</div>
                                    <div class="rights">
                                        <span class="price">￥700</span>
                                        <div class="right_buy"  @click="togoBuy(3, 2)">立即购买</div>
                                    </div>
                                </div>
                            </div>
                            <div class="down_img">
                                <img class="l_img" src="@/assets/topic/detail_two.png" alt="" />
                            </div>
                        </div>

                        <div class="detail_one">
                            <div class="deatil_titles three">至尊私塾班</div>
                            <div class="detail_mid">
                                <div class="mid_item">
                                    <div class="lefts">全科</div>
                                    <div class="rights">
                                        <span class="price">￥1980</span>
                                        <div class="right_buy"  @click="togoBuy(1, 3)">立即购买</div>
                                    </div>
                                </div>
                                <div class="mid_item">
                                    <div class="lefts">公共单科</div>
                                    <div class="rights">
                                        <span class="price">￥700</span>
                                        <div class="right_buy"  @click="togoBuy(2, 3)">立即购买</div>
                                    </div>
                                </div>
                                <div class="mid_item">
                                    <div class="lefts">实务单科</div>
                                    <div class="rights">
                                        <span class="price">￥900</span>
                                        <div class="right_buy"  @click="togoBuy(3, 3)">立即购买</div>
                                    </div>
                                </div>
                            </div>
                            <div class="down_img">
                                <img class="l_img" src="@/assets/topic/detail_three.png" alt="" />
                            </div>
                        </div>
                        
                    </div>
                </div>
            </div>

        </section>

        <!-- 弹窗 -->
        <buy-dialog :buyModal.sync="buyModal" :topicId="topicId" :subjectType="subjectType" :type="type"></buy-dialog>
        <ToolBar></ToolBar>
        <Footer></Footer>
    </div>
</template>

<script>
import Header from "@/components/header/index.vue";
import Footer from "@/components/footer/index.vue";
import ToolBar from "@/components/toolbar/index.vue";
import buyDialog from './components/buyDialog.vue'
import catalogue from './components/catalogue.vue'
export default {
    name: '',
    components: { Header, Footer, ToolBar, buyDialog, catalogue },
    data() {
        return {
            buyModal: false,
            topicId: '',
            subjectType: 0,
            type: 0,
            goodsInfo: {},
            // goodsData: {},
            vid: '',
            vidzb: '',
            vodPlayerJs: "https://player.polyv.net/script/player.js",
            playerJs: "https://player.polyv.net/resp/live-h5-player/latest/liveplayer.min.js",
            uidzb: "egsxlptzdq",
            menuTab: [
                {
                    name: "1",
                    label: "章节目录",
                }
            ],
            courseTabIndex: "1",
            courseId: "",
            goodsId: "",
            gradeId: "",
            orderGoodsId: "",
            needOpen: true, //是否需要一进来展开第一章节
            menuIndex: [], //需要展开的章节索引值
            courseList: [],
            s_courseList: [],
            goodsAuditionConfigIdList: [],
            listenConfigList: [],
            courserIndex: 0,
            goodsDetail: {},
            goodsExamConfig: [],
            subList: [],
            subIndex: 0,
            typeList: [],
            slideList: [],
            showMeun: false,
        }
    },
    created() {
        this.topicId = this.$route.query.topicId || 1
        this.getgoodsInfo()
        this.educationTypeList()
    },
    methods: {
        educationTypeList() {
            this.$request.educationTypeList().then((res) => {
                this.typeList = res.rows.slice(0, 5);
                this.typeList.forEach((typeItem, index) => {
                    this.businessList(typeItem.id, index);
                });
            });
        },

        businessList(educationId, index) {
            this.$request
                .businessList({ educationId })
                .then((res) => {
                    let rows = res.rows.filter((item) => item.aliasName)
                    this.$set(this.slideList, index, rows);
                    if (rows.length >= 2) {
                        let newRows = rows.slice(0, 2);
                        let length = 0;
                        newRows.forEach((row) => {
                        let str = row.projectName + "-" + row.businessName;
                        length = length + str.length;
                        });

                        if (length >= 17) {
                            this.$set(this.typeList[index], "list", rows.slice(0, 1));
                        } else {
                            this.$set(this.typeList[index], "list", rows.slice(0, 2));
                        }
                    } else {
                        this.$set(this.typeList[index], "list", rows);
                    }
                    console.log('this.typeList:',this.slideList, this.typeList)
                })
                .catch((err) => {
                console.log(err, "err");
            });
        },
        changeCouMeun() {
            this.showMeun = !this.showMeun
        },
        goCourse(item) {
            if (item.topicId) {
                this.topicId = item.topicId
                return
            }
            this.$router.push({
                path: "/course-list",
                query: {
                    educationId: item.educationId ? item.educationId : item.id || "",
                    projectId: item.projectId || "",
                    businessId: item.educationId ? item.id : "",
                },
            });
        },
        getgoodsInfo() {
            this.$axios({
                url: `/app/common/get/goodsInfo/${this.topicId}`,
                method: 'get',
                noToken: true
            }).then(async(res) => {
                if (res.code == 200) {
                    this.goodsInfo = res.data
                    // this.goodsId = res.data.goodsId
                    this.goodsId = 823
                    console.log('goodsInfo: ', this.goodsInfo)
                    
                }
            })
        },
        
        togoBuy(subjectType, type) {
            this.subjectType = subjectType
            this.type = type
            this.buyModal = true
        },
        
    }
}
</script>

<style lang="scss" scoped>
.goods_topic {
    width: 100%;
    .section {
        &__header {
            height: 40px;
            display: flex;
            align-items: center;
            padding: 0 20px;
        }
    }
    .course_btns {
        padding: 10px 10px 10px 115px;
        .meun_btns {
            width: 100%;
            .btns {
                width: 96px;
                height: 32px;
                line-height: 32px;
                text-align: center;
                background: #3F8DFD;
                border-radius: 4px;
                color: #fff;
                font-size: 14px;
                cursor: pointer;
                
            }
            &:hover {
                .slide-list {
                    display: block;
                }
            }
            .slide-list {
                display: none;
                transition: all 0.3s;
                width: 672px;
                background: #F8F8F8;
                position: absolute;
                top: 163px;
                left: 115px;
                padding-left: 24px;
                z-index: 10;
                border-radius: 4px;
                &__item {
                    min-height: 80px;
                    display: flex;
                    align-items: center;
                    border-bottom: 1px solid #ddd;

                    &:nth-last-of-type(1) {
                        border: 0;
                    }
                    .title {
                        cursor: pointer;
                        color: #fff;
                        width: 120px;
                        height: 28px;
                        border: 1px solid #ffffff;
                        border-radius: 14px;
                        background: #3f8dfd;
                        line-height: 26px;
                        text-align: center;
                        border-radius: 15px;
                        margin-right: 10px;
                    }

                    .nav {
                        flex: 1;
                        display: flex;
                        flex-wrap: wrap;
                        li {
                            margin: 9px 24px 9px 0;
                            display: flex;

                            .text {
                            cursor: pointer;
                            font-size: 14px;
                            font-family: Microsoft YaHei;
                            font-weight: 400;
                            color: #666;
                            }
                        }
                    }
                }
            }
        }
    }
    .mains {
        // width: 100%;
        padding: 0px 116px;
        .content_up {
            width: 100%;
            height: 808px;
            .banner_one {
                width: 100%;
                height: 280px;
                background: url('../../assets/topic/banner_one.png') center center no-repeat;
                background-size: 100% 100%;
                display: flex;
                align-items: center;
                justify-content: center;
            }
            .banner_two {
                width: 100%;
                height: 528px;
                background: url('../../assets/topic/banner_bg.png') center center no-repeat;
                background-size: 100% 100%;
                .con_header {
                    width: 1120px;
                    height: 44px;
                    background: #3F4449;
                    display: flex;
                    .con_item {
                        padding: 12px 20px;
                        font-size: 16px;
                        font-weight: 500;
                        color: #FFFFFF;
                        &.nactive {
                            background: #3F8DFD;
                        }
                    }
                }
                .course_info {
                    display: flex;
                    align-items: center;
                    justify-items: center;
                }
                .left_box {
                    width: 700px;
                    height: 528px;
                    .video {
                        width: 100%;
                        height: 100%;
                    }
                }
                .right-box {
                    width: 420px;
                    height: 528px;
                    background: #3f4449;
                    border-radius: 0px;
                    &__header {
                        .tabs {
                            /deep/.el-tabs__nav-wrap::after {
                                background-color: #999;
                            }

                            /deep/ .el-tabs__header {
                                margin: 0;
                            }

                            .label {
                                color: #fff;
                                height: 40px;
                                line-height: 40px;
                                padding: 0 20px;
                            }

                            .item {
                                &__title {
                                    padding-left: 12px;
                                    height: 40px;
                                    line-height: 40px;
                                    cursor: pointer;
                                    font-size: 14px;
                                    font-family: Microsoft YaHei;
                                    font-weight: bold;
                                    color: #fff;

                                    .el-icon-caret-right,
                                    .el-icon-caret-bottom {
                                    color: #999;
                                    }
                                }

                                &__content {
                                    .bank-chapter {
                                        &__item {
                                            color: #fff;
                                            font-size: 14px;

                                            &__text {
                                            padding: 8px 8px 8px 24px;
                                            cursor: pointer;
                                            flex: 1;

                                            .el-icon-caret-right,
                                            .el-icon-caret-bottom {
                                                color: #999;
                                            }
                                            }
                                        }
                                    }

                                    .bank-section {
                                        &__item {
                                            user-select: none;
                                            color: #fff;
                                            font-size: 14px;
                                            display: flex;
                                            align-items: center;

                                            &.active {
                                            background: #132b4d;
                                            font-size: 14px;
                                            font-family: Microsoft YaHei;
                                            font-weight: bold;
                                            color: #3f8dfd;
                                            }

                                            &__text {
                                            flex: 1;
                                            padding: 8px 8px 8px 12px;
                                            height: 40px;
                                            display: flex;
                                            flex-direction: column;
                                            justify-content: center;
                                            cursor: pointer;

                                            .el-icon-caret-right,
                                            .el-icon-caret-bottom {
                                                color: #999;
                                            }
                                            }

                                            .test-btn {
                                            margin-left: 10px;
                                            width: 32px;
                                            height: 20px;
                                            background: #007aff;
                                            border-radius: 4px;
                                            line-height: 18px;
                                            color: #fff;
                                            text-align: center;
                                            }

                                            .note {
                                            margin-left: 10px;
                                            width: 32px;
                                            height: 20px;
                                            border: 1px solid #ff3b30;
                                            border-radius: 4px;
                                            line-height: 18px;
                                            color: #ff3b30;
                                            text-align: center;

                                            &--yellow {
                                                border-color: #ff9500;
                                                color: #ff9500;
                                            }

                                            &--blue {
                                                border-color: #3f8dfd;
                                                color: #3f8dfd;
                                            }
                                            }

                                            .during {
                                            color: #999;
                                            margin-right: 10px;
                                            }

                                            .btn {
                                            margin-right: 12px;
                                            width: 48px;
                                            height: 20px;
                                            border: 1px solid #ff3b30;
                                            background: #ff3b30;
                                            border-radius: 4px;
                                            line-height: 18px;
                                            color: #fff;
                                            text-align: center;

                                            &--green {
                                                border: 1px solid #34c759;
                                                background: #34c759;
                                            }
                                            }

                                            .live-btn {
                                            margin-left: 20px;
                                            width: 60px;
                                            height: 20px;
                                            border-radius: 4px;
                                            background: #eeeeee;
                                            line-height: 18px;
                                            color: #666666;
                                            text-align: center;

                                            &--yellow {
                                                background: #fff7eb;
                                                color: #ff9500;
                                            }

                                            &--blue {
                                                border-color: #ebf4ff;
                                                color: #007aff;
                                            }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        .title {
                            height: 40px;
                            border-bottom: 1px solid #999;
                            color: #fff;

                            .select {
                            width: 100%;
                            }

                            /deep/ .el-input__icon {
                            width: 20px;
                            height: 20px;
                            border: 1px solid #fff;
                            border-radius: 4px;
                            margin-top: 10px;
                            line-height: 20px;
                            }

                            /deep/ .el-input__inner {
                            color: #fff;
                            font-size: 16px;
                            background: none;
                            border: 0;
                            }
                        }
                    }
                    &__body {
                        height: 374px;
                        overflow-y: scroll;
                        &::-webkit-scrollbar {
                            // width: 6px;
                            display: none;
                        }
                        &::-webkit-scrollbar-track {
                            background-color: #060e1a;
                            -webkit-border-radius: 2em;
                            -moz-border-radius: 2em;
                            border-radius: 2em;
                        }
                        &::-webkit-scrollbar-thumb {
                            background-color: #eeeeee;
                            -webkit-border-radius: 2em;
                            -moz-border-radius: 2em;
                            border-radius: 2em;
                        }
                    }
                }
            }
            
        }
        .topic_detail {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100%;
            // height: 3444px;
            height: 3100px;
            background: url('../../assets/topic/topic_bg.png') center center no-repeat;
            background-size: 100% 100%;
            
            .titles {
                margin-top: 109px;
                >img {
                    width: 32px;
                    height: 20px;
                }
                .scheme {
                    font-size: 48px;
                    font-weight: bold;
                    color: #363543;
                    margin: 0px 40px;
                }
            }
            .min_title {
                margin: 13px 0px 50px;
                font-size: 28px;
                font-weight: 500;
                color: #363543;
            }
            
        }
        .details {
            display: flex;
            justify-content: center;
            align-items: center;
            .detail_one {
                width: 358px;
                height: 2753px;
                background-color: #fff;
                border-radius: 8px;
                margin-right: 20px;
                @media screen and (max-width: 1370px){
                    width: 300px;
                }
            }
            .deatil_titles {
                width: 100%;
                height: 110px;
                line-height: 110px;
                text-align: center;
                border-radius: 8px 8px 0px 0px;
                background: linear-gradient(45deg, #71A9F6 0%, #1658DA 100%);
                font-size: 32px;
                font-weight: bold;
                color: #FFFFFF;
                &.two {
                    background: linear-gradient(45deg, #FE8D6D 0%, #ED3531 100%);
                }
                &.three {
                    background: linear-gradient(45deg, #E3BC79 0%, #BF7D2E 100%);
                }
            }
            .detail_mid {
                width: 100%;
                padding: 0px 24px;
                
                .mid_item {
                    width: 100%;
                    height: 74px;
                    border-bottom: 1px solid #EAEAEA;
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                }
                .lefts {
                    font-size: 18px;
                    font-weight: bold;
                    color: #363543;
                }
                .rights {
                    display: flex;
                }
                .price {
                    font-size: 18px;
                    font-weight: 500;
                    color: #FC3F3F;
                    margin-right: 20px;
                }
                .right_buy {
                    width: 76px;
                    height: 28px;
                    line-height: 28px;
                    text-align: center;
                    background: #FC3F3F;
                    border-radius: 50px;
                    font-size: 13px;
                    font-weight: 500;
                    color: #FFFFFF;
                    cursor: pointer;
                }
            }

            .down_img {
                width: 100%;
                height: 2369px;
                >.l_img {
                    width: 100%;
                    height: 100%;
                    display: block;
                }
            }
        }
    }
}
</style>