<template>
    <div>
        <NavBar :showIcon="true" backgroundBox="#ffffff" :showTitle="true" title="文章详情"></NavBar>
        <div class="page">
            <div class="top">
                <video :src="evn.APP_IMAGE_BASE_API + data.videoPath" v-if="data.infoType === 2"></video>
                <div class="title">{{ data.title }}</div>
                <div class="flex-between">
                    <div class="publisher">{{ data.publisher }}</div>
                    <div class="date">{{ dayjs(data.publishDate).format("YYYY/MM/DD hh:mm") }}</div>
                </div>
                <div class="watch flex-align-center">
                    <img src="@/static/image/icon/eye.png" alt="" />
                    {{ data.views }}
                </div>
            </div>
            <view class="title-bottom">
                <text>相关介绍</text>
                <img class="title-photo" src="@/static/image/article/relevant.png" alt="" />
            </view>
            <div class="content" v-html="data.content"></div>
        </div>
        <view class="btn-box" v-if="data.type === 3">
            <button class="btn" @tap="viewJobPositions">查看岗位</button>
        </view>
    </div>
</template>

<script setup>
import { getArticleDetailApi } from "@/api/article.js";
import evn from "@/utils/config.js";
import { ref } from "vue";
import dayjs from "dayjs";
const data = ref({});
onLoad(({ id }) => {
    getArticleDetailApi(id).then(res => {
        console.log(res);
        data.value = res.data;
    });
});

const viewJobPositions = () => {
    uni.navigateTo({
        url: `/pages/user/matchingTwo/index?id=${data.value.id}`
    });
}
</script>

<style lang="scss" scoped>
.page {
    padding: 32rpx;
    padding-bottom:calc(112rpx + env(safe-area-inset-bottom)) ;
    .top {
        padding-bottom: 32rpx;
        margin-bottom: 32rpx;
        border-bottom: 2rpx solid #f3f4f8;
        video {
            width: 100%;
        }
        .title {
            font-size: 32rpx;
            font-weight: 600;
            line-height: 48rpx;
            color: #1b2026;
        }
        .flex-between {
            margin: 16rpx 0;
            font-size: 24rpx;
            font-weight: 500;
            line-height: 28rpx;
            color: #77818f;
            letter-spacing: 0rpx;
        }
        .watch {
            font-size: 24rpx;
            font-weight: 500;
            line-height: 28rpx;
            color: #77818f;
            img {
                width: 25.34rpx;
                height: 16rpx;
                margin-right: 8rpx;
            }
        }
    }
    .title-bottom {
        position: relative;
        width: 150rpx;
        margin-bottom: 16rpx;
        text {
            font-size: 36rpx;
            font-weight: 600;
        }
        .title-photo {
            position: absolute;
            right: 0;
            bottom: 0;
            width: 122rpx;
            height: 16rpx;
        }
    }
}
.btn-box{
    position: fixed;
    bottom: 0;
    height: 112rpx;
    width: 100%;
    background: #ffffff;
    display: flex;
    align-items: center;
    padding-bottom:env(safe-area-inset-bottom) ;
    .btn{
        background: #1F86FF; 
        width: 622rpx;
        height: 80rpx;  
        line-height: 80rpx;  
        color: white;
        font-size: 28rpx;
    }
}
</style>
