<template>
<section>
    <YqyLecturerOrder groupTitle="全部讲师" :groupNum="groupNum" :showTitle="showTitle" :showOrder="showOrder" @order="orderAction"/>
    <div class="font-style">
        <div class="teach-opt">
            <div class="teach-list">
                <div :class="index % 2 == 1 ? 'list-item mr0' : 'list-item'" 
                    v-for="(item, index) in cParamData" :key="index"
                    @click="goToPage(item)">
                    <div class="tea-img" :style="'background:'+ item.bgColor">
                        <img :src="item.doctorAvatarImg">
                        <span class="learn-p">{{item.totalNum}}人已学</span>
                        <span class="learn-p-cnum">课程：共{{item.resourceNum}}门</span>
                        <!-- <span class="learn-p">{{item.joinNum | yLocalString}}人已学</span> -->
                    </div>
                    <div class="tea-txt">
                        <div class="tea-name">
                            <span>{{item.doctorName}}</span>
                            <span class="tea-department">{{item.department}}</span>
                        </div>
                        <div class="tea-position">
                            {{item.doctorHospital}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
</template>

<script>
import { mapGetters } from 'vuex'
import { jumpWebPageUrl } from '@/utils/index'

// import GroupTitle from '@/componentsn/business/group-title';
import YqyLecturerOrder from '@/componentsn/business/yqy-lecturer-order';
export default {
    data() {
        return {
            topTitle: '讲师集',
            token: '',
            // list: [],
            isShowCount: true,
            followCount: 0,
            studyCount: 0,
            col: 1, //0综合，1人气，2资源数，3姓名首字母
            dir: 2, //1:正序 2：逆序,
            list: [],
        }
    },
    components: {
        YqyLecturerOrder
    },
    props: {
        parmData: {
            type: Array,
            default: () => []
        },
        groupNum: {
            type: String,
            default: '0'
        },
        showTitle: {
            type: Boolean,
            default: false
        },
        showOrder: {
            type: Boolean,
            default: true
        }
    },
    mounted() {
        // window.__refresh = function (parm) {
        //     _this.getData();
        // }
        window.addEventListener('scroll', this.handleScroll)

    },
    computed: {
        ...mapGetters({
            cSearchText: 'cSearchText',
            userInfo: 'userInfo',
            orderNum: 'orderNum'
        }),
        cParamData() {
            if (this.parmData && this.parmData.length) {
                return this.randomBg(this.parmData)
            } else {
                return this.randomBg(this.list)
            }
        }
    },
    watch: {
        orderNum(val) {
            if (this.showOrder) {
                this.orderAction(1, true)
            }
        }
    },
    methods: {
        //跳转
        goToPage(item){
            let _this = this,
                url = jumpWebPageUrl+'appl/#/teachersDetail?id='+item.doctorId+"&from=appHome&userToken="+ _this.userToken

            let itemData = {
                "title":"",
                "imageUrl":"",
                "appModuleInfo":{
                    "code":"M300",
                    "type":4,
                    "name":"wwww",
                    "paramFlag":1,
                    "paramList":[
                        {
                            "key":"pageUrl",
                            "value": url,
                            "type":4,
                            "seqNo":1
                        },{
                            "key":"showTitle",
                            "value": false,
                            "type":1,
                            "seqNo":2
                        },{
                            "key":"title",
                            "value": '',
                            "type":1,
                            "seqNo":3
                        }
                    ]
                }
            };

            rocNative.dispatchEventByModuleCode({
                modeCode: itemData.appModuleInfo.code,
                jsonString: itemData.appModuleInfo.paramList
            })
        },

        randomBg(d) {
            for (let i = 0; i < d.length; i++) {
                if (i % 4 == 0) {
                    d[i].bgColor = '#EBF6F1'
                } else if (i % 4 == 1) {
                    d[i].bgColor = '#EDF3FA'
                } else if (i % 4 == 2) {
                    d[i].bgColor = '#F0F0FA'
                } else if (i % 4 == 3) {
                    d[i].bgColor = '#F6EFE6'
                }
            }
            return d
        },

        orderAction(orderIndex, notBP) {
            // if(!notBP) {
            //     this.pageBurialPoin({
            //         ...m_search_result_lecturer_order,
            //         labelValue: orderIndex,
            //         createdTime: new Date().getTime(),
            //     })
            // }
            // this.searchForOrder('3', this.cSearchText, orderIndex, this.groupNum, this.parmData).then( param => {
            //     this.list = param
            // })
        }

    }
}
</script>

<style>
body {
    background: #fff
}
</style>
<style lang="scss" scoped>
body {
    background: #fff
}

@import '../../style/mixin';

.mint-header {
    background-color: rgba($color: #000000, $alpha: 0)
}

.font-style {
    width: 100%;
    overflow: hidden;
    @include sc(0.6rem, #666);
}

.teach-opt {
    padding: 0 px2rem(15px) px2rem(15px) px2rem(15px);

    .teach-title {
        font-size: px2rem(18px);
        // padding-bottom: px2rem(0px);
        color: #333;
    }

    .teach-list {
        margin-top: px2rem(-14px);
        overflow: hidden;
    }

    .opt-span {
        span {
            color: #449284;
            font-size: px2rem(13px);
            display: inline-block;
            vertical-align: middle;
            height: px2rem(10px);
            line-height: px2rem(10px);

            img {
                display: inline-block;
                width: px2rem(15px);
                height: px2rem(15px);
                vertical-align: middle;
            }
        }
    }

    .list-item {
        width: px2rem(170px);
        margin-right: px2rem(5px);
        margin-top: px2rem(15px);
        border: 1px solid rgba(0, 0, 0, 0.02);
        border-radius: 0 0 px2rem(3px) px2rem(3px);
        float: left;
        box-shadow: 0 px2rem(4px) px2rem(6px) RGBA(0, 0, 0, 0.06);
    }

    .mr0 {
        margin-right: 0
    }

    .tea-txt {
        padding: px2rem(5px) px2rem(7px);
    }

    .tea-img {
        width: px2rem(170px);
        height: px2rem(83px);
        position: relative;
        border-radius: px2rem(3px) px2rem(3px) 0 0;

        img {
            width: 100%;
            height: 100%;
            display: block;
            border-radius: px2rem(3px) px2rem(3px) 0 0;
        }

        .learn-p {
            padding-left: px2rem(5px);
            position: absolute;
            width: 100%;
            left: 0;
            bottom: 0;
            background: #333;
            background: linear-gradient(to right, RGBA(0, 0, 0, 0.2), RGBA(0, 0, 0, 0));
            // background: linear-gradient(180deg,rgba(0,0,0,0) 0%,rgba(0,0,0,0.34) 100%);
            color: #fff;
            font-size: px2rem(11px);
            height: px2rem(20px);
            line-height: px2rem(22px);
            &-cnum {
                position: absolute;
                right: px2rem(10px);
                bottom: 0;
                color: #fff;
                font-size: px2rem(11px);
                height: px2rem(20px);
                line-height: px2rem(22px);
            }
        }
    }

    .tea-name {
        padding: 0;
        color: #333;
        font-size: px2rem(14px);
        font-weight: 500;
    }

    .tea-department {
        padding: 0;
        color: #333;
        font-size: px2rem(12px);
        font-weight: 400;
    }
    .tea-position {
        height: px2rem(30px);
        font-size: px2rem(12px);
        line-height: px2rem(15px);
        color: #666;
        font-weight: 400;
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-line-clamp: 2;
    }
}

.home-header {
    height: px2rem(185px);
    @include bis('../../images/headerTop.png');

    .logo_img {
        height: px2rem(85px);
        width: px2rem(345px);
        text-align: center;
    }
}
.ellipsis-1 {
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
}
.ellipsis-2 {
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
}
</style>
