<template>
    <My_listbox ref="List" @getlist="getList" :isShowEmpty="false" :bottomHeight="70">
        <slideshow ref="slideshow" />

        <view class="box">
            <view class="head" />
            <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="remark u-line-3">
                    {{ item.remarks || '' }}
                </view>
                <view class="line" :style="{ background: item.color }" />
            </navigator>
            <navigator class="nav-box" v-for="item  in  list"
                :url="'/packageA/resourceLibrary/index?id=' + item.sat_sharematerial_classid + '&name=' + item.classname"
                :key="item.sat_sharematerial_classid" hover-class="navigator-hover">
                <view class="classname u-line-1">
                    {{ item.classname || '' }}
                </view>
                <view class="remark u-line-3">
                    {{ item.remarks || '' }}
                </view>
                <view class="line" :style="{ background: item.color }" />
            </navigator>
        </view>
    </My_listbox>
</template>

<script>
export default {
    data() {
        return {
            updatePage: true,
            appList: [],
            list: [],
            "content": {
                "parentid": 0,
                "where": {
                    "isenable": 1
                }
            },
            colors: ['#F9E3FF', "#FFE6E8", "#DDF3FD"],
        }
    },
    methods: {
        init(callBack) {
            try {
                this.appList = this.dye(this.getApps('资料库').map(v => {
                    v.classname = v.remark;
                    switch (v.name) {
                        case "affiche":
                            v.remarks = '新品上市 / 停产 / 变更类 / 事件类'
                            break;
                        case "dailyYttendance":
                            v.remarks = '效果图 / 实景图 / 产品图\n励志海报等'
                            break;
                    }
                    return v
                }), this.colors, 1)
            } catch (error) {
                console.log("未获取到授权")
            }
            Promise.all([this.getList(true), this.$refs.slideshow.getBanners(['databaseTop'])]).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": "20221102143202",
                    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, 1);
                    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 {
        position: relative;
        padding: 15px;
        padding-right: 3px;
        width: 172.5px;
        height: 104px;
        flex-shrink: 0;
        margin-bottom: 10px;
        box-sizing: border-box;
        background: #fff;
        border-radius: 8px;
        overflow: hidden;

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

        .remark {
            margin-top: 10px;
            line-height: 17px;
            font-family: Source Han Sans SC, Source Han Sans SC;
            font-size: 10px;
            color: #999999;
            white-space: pre-wrap;
        }

        .line {
            position: absolute;
            left: 0;
            top: 0;
            width: 4px;
            height: 100%;
        }
    }
}
</style>