<template>
    <My_listbox ref="List" @getlist="getList" :isShowEmpty="false" :bottomHeight="70">
        <slideshow ref="slideshow" empty />
        <view class="box">
            <view class="head" />
            <navigator class="nav-box" v-for="item in list" :key="item.sat_courseware_classid"
                :url="'/packageA/course/index?id=' + item.sat_courseware_classid + '&classname=' + item.classname"
                hover-class="navigator-hover">
                <view class="classname u-line-1">
                    {{ item.classname }}
                </view>
                <view class="remarks u-line-1">
                    {{ item.remarks }}
                </view>
                <view class="line" :style="{ background: item.color }" />
            </navigator>
            <navigator class="nav-box" v-for="item in appList" :key="item.name" :url="item.path"
                hover-class="navigator-hover">
                <view class="classname u-line-1">
                    {{ item.classname }}
                </view>
                <view class="remarks u-line-1">
                    {{ item.remarks }}
                </view>
                <view class="line" :style="{ background: item.color }" />
            </navigator>
        </view>
    </My_listbox>
</template>

<script>
export default {
    data() {
        return {
            updatePage: true,
            list: [],
            appList: [],
            colors: ['#FFE6E7', '#EAEAFF', '#DDF3FD'],
            "content": {
                "parentid": 0,
                "where": {
                    "isenable": 1
                }
            }
        }
    },
    methods: {
        init(callBack) {
            try {
                this.appList = this.dye(this.getApps('商学院').map(v => {
                    v.classname = v.remark;
                    switch (v.name) {
                        case "exam":
                            v.remarks = 'TEST'
                            break;
                    }
                    return v
                }), this.colors)
            } catch (error) {
                console.log("未获取到授权信息")
            }

            Promise.all([this.getList(true), this.$refs.slideshow.getBanners(['courseTop'])]).then(res => {
                callBack()
                this.updatePage = false;
            })
        },
        getList(init = false) {
            return new Promise((resolve, reject) => {
                if (this.paging(this.content, init)) return resolve();
                this.$Http.basic({
                    "id": "20221102143302",
                    content: this.content
                }).then(res => {
                    console.log("课程分类", res)
                    this.$refs.List.RefreshToComplete()
                    resolve()
                    if (this.cutoff(res.msg)) return;
                    this.list = this.dye(res.pageNumber == 1 ? res.data : this.list.concat(res.data), this.colors);
                    this.content = this.$refs.List.paging(this.content, res)
                })
            })
        }
    },
}
</script>

<style lang="scss">
.box {
    position: relative;
    padding: 0 10px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;

    .head {
        position: absolute;
        height: 10px;
        width: 100vw;
        border-radius: 8px 8px 0 0;
        background: #F7F7F7;
        top: -10px;
        left: 0;
        z-index: 1;
    }

    .nav-box {
        width: 172.5px;
        height: 92px;
        flex-shrink: 0;
        margin-bottom: 10px;
        background: #fff;
        padding: 15px;
        border-radius: 8px;
        box-sizing: border-box;

        .classname {
            line-height: 24px;
            font-family: Source Han Sans SC, Source Han Sans SC;
            font-weight: bold;
            font-size: 16px;
            color: #333333;
        }

        .remarks {
            line-height: 15px;
            font-family: Source Han Sans SC, Source Han Sans SC;
            font-size: 10px;
            color: #999999;
            margin-top: 10px;
        }

        .line {
            width: 32px;
            height: 3px;
            margin-top: 10px;
        }
    }
}
</style>