<!--
 * @Description  : 案例组件
 * @Author       : 熊伟
 * @Date         : 2020-06-16 16:33:46
 * @LastEditTime: 2020-10-10 14:45:02
 * @LastEditors: 李璕
 * @FilePath     : \see-tp-case.vue
 -->

<template>
    <div class="see-tp-case" v-if="isShow">
        <div
            v-if="componentData.caselist.length"
            class="case-list clearfix"
            :class="[{ m: componentData.commonVariable.isMobile }]"
        >
            <div
                v-for="(item, index) in componentData.caselist"
                :key="index"
                class="case-item"
                :style="
                    componentData.commonVariable.isMobile == 1
                        ? 'margin-left:0'
                        : ''
                "
                @click="goCaseInfo(item)"
            >
                <base-image
                    class="image"
                    :src="item.case_cover"
                    :tips="item.tips"
                ></base-image>
                <div class="case-info">
                    <div class="case-info__top">
                        <div class="case-item__title">
                            {{ item.case_title }}
                        </div>
                        <div class="case-item__industry">
                            {{ item.customer_trade }}
                        </div>
                    </div>
                    <div class="case-item__app">
                        <span v-if="item.customer_app">{{
                            "应用：" + item.customer_app
                        }}</span>
                    </div>
                    <div class="case-item__rate">
                        <div>
                            <img
                                src="./assets/iconchakanshu.svg"
                                class="icon-watch"
                            />
                            {{ item.clicks | quantityIntoTenThousands }}
                        </div>
                        <div>
                            <span class="rate-num">{{ item.avg_star }}</span
                            >分
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div
            v-if="
                componentData.commonVariable.pageType == 'design' &&
                !componentData.caselist.length
            "
            class="cont-empty"
        >
            案例组件
        </div>
    </div>
</template>
<script>
import btnMixin from "./button-mixin";
import BaseImage from "./components/base-image";
import permissionMixin from "./permission-mixin";
export default {
    name: "see-tp-case",
    mixins: [btnMixin,permissionMixin],
    components: { BaseImage },
    // inject: ['isPC'],
    props: {
        componentData: {
            required: false,
        },
    },
    data() {
        return {};
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {
    },
    methods: {
        goCaseInfo(item) {
            if (this.componentData.commonVariable.pageType == "design") return;

            let jumpUrl = "";
            if (this.componentData.commonVariable.isMobile) {
                jumpUrl = "/m/case-detail/" + item.case_id;
            } else {
                jumpUrl = "/rest/cases/jump?case_id=" + item.case_id;
            }
            this._mixJumpClick(
                !this.componentData.commonVariable.isMobile,
                jumpUrl
            );
        },
    },
    filters: {
        quantityIntoTenThousands(value = 0) {
            if (Number(value) >= 100000) {
                let thousandNum = (value / 10000).toFixed(2);
                return thousandNum + "万";
            }
            return value;
        },
    },
    destroyed() {},
};
</script>

<style lang="scss" scoped>
.clearfix:before,
.clearfix:after {
    content: " ";
    display: table;
}
.clearfix:after {
    clear: both;
}
.see-tp-case {
    width: 100%;
    min-height: 40px;
    .case-item {
        position: relative;
        float: left;
        text-align: left;
        width: calc((100% - 40px) / 3);
        height: 270px;
        border-radius: 4px;
        background-color: #fff;
        transition: all 0.2s;
        border: 1px solid #ececec;
        cursor: pointer;
        overflow: hidden;
        z-index: 2;
        &:nth-child(3n-1) {
            margin: 0 16px;
        }
        &:nth-of-type(n + 4) {
            margin-top: 20px;
        }
        &:hover {
            box-shadow: 0 10px 25px 0 #e1e5ed;
        }
        .image {
            width: 100%;
            height: 150px;
        }
        .case-info {
            padding: 10px 16px 16px;
            font-size: 12px;
            color: #999;
        }
        .case-item__title {
            font-size: 16px;
            color: #333;
            width: 100%;
            margin-bottom: 3px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .case-item__industry,
        .case-item__app {
            height: 18px;
            margin-bottom: 5px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .case-item__rate {
            display: flex;
            justify-content: space-between;
            align-items: center;
            .icon-watch {
                height: 16px;
                vertical-align: text-bottom;
            }
            .rate-num {
                color: #333;
            }
        }
    }
}
.case-list.m {
    width: 100%;
    .case-item {
        width: 100%;
        margin-right: 0%;
        margin-bottom: 10px;
        .image {
            height: 160px;
        }
        .case-info__top {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .case-item__app {
            height: auto;
        }
        .case-item__title {
            width: 70%;
        }
    }
}
.cont-empty {
    height: 100px;
    line-height: 100px;
    background: rgba(204, 204, 204, 0.15);
    text-align: center;
}
</style>

