<template>
  <view class="pc_all">
    <PageTop></PageTop>

    <view class="content" :style="{ filter: Session.get('token') ? '' : 'blur(5px)' }">
      <view class="top" @click="goBack">
        <image src="@/assets/zixun/icon_fanhui.png" class="icon_back" />
        <text>返回列表</text>
      </view>

      <view class="line"></view>

      <view class="title">
        {{ infoData?.title }}
      </view>

      <view class="sub_title">
        <text class="srouse"> {{ infoData?.tag }}</text>
        <text class="time"> {{ infoData?.publishTime }}</text>
      </view>

      <view class="abstract" v-if="infoData?.summary">
        {{ infoData?.summary }}
      </view>

      <!-- 两个标签 start -->
      <view class="r_tag_two">
        <view style="display: flex" v-if="infoData?.industryLabels && infoData?.industryLabels.length > 0">
          <text class="tag_title">行业分类：</text>
          <view class="r_tags">
            <view class="tag" style="background-color: #fff9ec; color: #ffb100"
              v-for="(item, index) in infoData?.industryLabels" :key="index">{{
                item
              }}</view>
          </view>
        </view>

        <view style="display: flex" v-if="infoData?.conceptLabels && infoData?.conceptLabels.length > 0">
          <text class="tag_title">概念标签：</text>
          <view class="r_tags">
            <view class="tag" style="background-color: #f5f8fe; color: #007aff"
              v-for="(item, index) in infoData?.conceptLabels" :key="index">{{
                item
              }}</view>
          </view>
        </view>
      </view>
      <!-- 两个标签 end -->

      <view class="text" v-html="infoData.content" style="white-space: pre-wrap"> </view>
      <!-- <view class="text">
        <text >{{ infoData.content }}</text>
      </view> -->
    </view>

    <LoginPopup :show="LoginShow" mode="center" @handlePopupClose="handlePopupClose"
      @handlePopupSuccessCallback="handlePopupSuccessCallback" @handlePopupErrorCallback="handlePopupErrorCallback" />
  </view>
</template>

<script setup lang="ts">
import { onLoad } from "@dcloudio/uni-app";
import { ref } from "vue";
import { fetchArticleDetail } from "@/api/detail";
import LoginPopup from "@/components/loginPopup/index.vue";
import { Session } from "@/utils/storage";

function goBack() {
  // uni.navigateBack();

  uni.navigateTo({
    url: "/pages/realtimeInfo/pc/index?type=" + type.value,
  });
}

const type = ref(0);
const infoData = ref({});
onLoad(async (e) => {
  if (e?.type) {
    type.value = e.type;
  }

  uni.showLoading();
  const res = await fetchArticleDetail({
    id: e?.id,
  });
  uni.hideLoading();
  if (res.code === 200) {
    infoData.value = res.data;
  }

  if (!Session.get("token")) {
    LoginShow.value = true;
  }
});

const LoginShow = ref(false);
const isLoginStatus = ref();
// 关闭弹框
const handlePopupClose = () => {
  LoginShow.value = false;
};

// 登录成功之后的回调
const handlePopupSuccessCallback = () => {
  isLoginStatus.value = true;
  window.location.reload();
  // uni.navigateTo({
  //   url: "/pages/realtimeInfo/rankDetail?type=" + type,
  // });
};

// 登录失败之后的回调
const handlePopupErrorCallback = () => {
  console.log("登录失败");
};
</script>

<style lang="scss" scoped>
@import url("./index.css");

.page_top {
  width: 100vw;
  height: 120rpx;
  background-color: white;
  margin-bottom: 30rpx;
  box-shadow: 0 5rpx 2rpx rgba($color: #6d6d6d, $alpha: 0.1);
  display: flex;
  justify-content: center;
  align-items: center;

  .logo {
    width: 190rpx;
    height: 50rpx;
    margin-right: 50rpx;
  }

  .r_menu {
    width: 55vw;
    min-width: 1250px;
    height: 100%;
    display: flex;
    align-items: center;
  }

  .r_menu_item {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    justify-content: center;
    align-items: center;
  }

  .menu_item {
    font-family: PingFangSC, PingFang SC;
    font-weight: bold;
    font-size: 32rpx;
    color: #1a1a1a;
  }

  .line {
    width: 64px;
    height: 4px;
    background: #007aff;
    position: absolute;
    bottom: 0;
  }
}

.top {
  width: 100%;
  height: 120rpx;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  padding-left: 30rpx;

  .icon_back {
    width: 34rpx;
    height: 38rpx;
  }

  text {
    font-family: PingFangSC, PingFang SC;
    font-weight: normal;
    font-size: 38rpx;
    color: #919191;
    text-align: left;
    font-style: normal;
    margin-left: 10rpx;
  }
}

.line {
  width: 100%;
  height: 12rpx;
  background: #f0f0f0;
}

.title {
  font-family: PingFangSC, PingFang SC;
  font-weight: bold;
  font-size: 48rpx;
  color: #1a1a1a;
  margin-top: 50rpx;
}

.sub_title {
  display: flex;
  justify-content: space-between;
  margin-top: 10rpx;

  .srouse {
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 32rpx;
    color: #919191;
  }

  .time {
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 32rpx;
    color: #919191;
  }
}

.abstract {
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  font-size: 32rpx;
  color: #666666;
  line-height: 26px;
  text-align: left;
  font-style: normal;

  background: #f5f8fe;
  border: 1px solid #e3ecfd;

  padding: 30rpx;
  border-radius: 20rpx;

  margin-top: 50rpx;
}

.r_tag_two {
  display: flex;
  margin-top: 40rpx;
  justify-content: space-between;
}

.r_tags {
  display: flex;
  gap: 20rpx;

  .tag {
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 26rpx;
    color: #ffb100;
    line-height: 18px;
    text-align: left;
    font-style: normal;

    padding: 5rpx 20rpx;
    border-radius: 10rpx;

    white-space: nowrap;
  }
}

.tag_title {
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  font-size: 28rpx;
  color: #999999;
  line-height: 20px;
  text-align: left;
  font-style: normal;

  white-space: nowrap;
}

.text {
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  font-size: 32rpx;
  color: #1a1a1a;
  line-height: 28px;
  text-align: left;
  font-style: normal;
  margin-top: 70rpx;
}
</style>
