<template>
  <view class="container-report-page">
    <view class="content-list">
      <block v-if="reportPageData.ListHzResource.length">
        <view class="resource">
          <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/zybico.jpg"></image>
          <text>弘则资源包</text>
        </view>
        <text style="height: 1rpx; background: #ececec"></text>
        <view class="list-ui" v-for="item in reportPageData.ListHzResource" :key="item.IndustrialManagementId" @click="themeDetails(item)">
          <view class="item-title">
            <text>
              {{ item.IndustryName }}
            </text>
            <view class="publish">
              {{ item.PublishDate }}更新
              <u-icon name="arrow-right" color="#BDBDBD" size="34"></u-icon>
            </view>
          </view>
          <view class="read-more" v-if="item.IndustrialSubjectList">
            <text class="text-box text_oneLine" v-for="val in item.IndustrialSubjectList" :key="val.IndustrialSubjectId">
              {{ val.SubjectName }}
            </text>
          </view>
        </view>
      </block>
      <block v-if="reportPageData.ListYxResource.length">
        <view class="resource">
          <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/zybico.jpg"></image>
          <text>买方研选主题</text>
        </view>
        <text style="height: 1rpx; background: #ececec"></text>
        <view class="list-ui" v-for="item in reportPageData.ListYxResource" :key="item.IndustrialManagementId" @click="themeDetails(item)">
          <view class="item-title">
            <text>
              {{ item.IndustryName }}
            </text>
            <view class="publish">
              {{ item.PublishDate }}更新
              <u-icon name="arrow-right" color="#BDBDBD" size="34"></u-icon>
            </view>
          </view>
          <view class="read-more" @click="themeDetails(item)" v-if="item.IndustrialSubjectList">
            <text class="text-box text_oneLine" v-for="val in item.IndustrialSubjectList" :key="val.IndustrialSubjectId">
              {{ val.SubjectName }}
            </text>
          </view>
        </view>
      </block>
    </view>
    <view class="content-report">
      <block v-if="reportPageData.ListYxReport.length">
        <view class="resource">
          <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/report_Yx.png"></image>
          <text>买方研选报告</text>
        </view>
        <text style="height: 1rpx; background: #ececec"></text>
        <view class="content-item" v-for="item in reportPageData.ListYxReport" :key="item.ArticleId">
          <view class="item-user">
            <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/user_report.png"></image>
            <text> {{ item.NickName }}</text>
          </view>
          <view class="item-title">
            <text style="display: inline" @click="goDetailReport(item)">
              {{ item.Title }}
            </text>
            <text class="item-industry" v-if="item.IndustryName" @click="themeDetails(item)">&nbsp;&nbsp;&nbsp;#{{ item.IndustryName }}</text>
          </view>
          <view class="item-more">
            <text>{{ item.PublishDate }}</text>
            <view class="pv-ollect">
              <view>
                <image class="pv" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/examine_icon.png"></image>
                {{ item.Pv }}
              </view>
              <view @click="collectClick(item)">
                <image v-if="item.IsCollect" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/collect_act.png"></image>
                <image v-else src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/collect_ico.png"></image>
                {{ item.CollectNum }}人收藏
              </view>
            </view>
          </view>
        </view>
      </block>
      <block v-if="reportPageData.ListHzReport.length">
        <view class="resource">
          <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/report_Hz.png"></image>
          <text>弘则报告</text>
        </view>
        <text style="height: 1rpx; background: #ececec"></text>
        <view class="content-item" v-for="item in reportPageData.ListHzReport" :key="item.ArticleId">
          <view class="item-title">
            <text style="display: inline" @click="goDetailReport(item)">
              {{ item.Title }}
            </text>
            <text class="item-industry" @click="themeDetails(item)" v-if="item.IndustryName">&nbsp;&nbsp;&nbsp;#{{ item.IndustryName }}</text>
          </view>
          <view class="item-more">
            <text>{{ item.PublishDate }}</text>
          </view>
        </view>
      </block>
    </view>
    <u-modal
      v-model="goFollowShow"
      :content-style="{ fontSize: '32rpx' }"
      @confirm="goFollowShowBtn"
      :show-cancel-button="isCancelBtn"
      :confirm-text="confirmText"
      @cancel="isCancelBtn = false"
      :show-title="false"
      :cancel-style="{ borderRight: '1rpx solid #EBEBEB' }"
      :confirm-style="{ fontWeight: '700' }"
    >
      <view class="slot-content">
        <rich-text :nodes="accounts"></rich-text>
      </view>
    </u-modal>
  </view>
</template>

<script>
import {Report } from "@/config/api"
export default {
  components: {},
  props: {
    reportPageData: {
      type: Object,
    },
  },
  data() {
    return {
      goFollowShow: false,
      confirmText: "知道了",
      isCancelBtn: false,
      accounts: "",
    };
  },
  watch: {},
  methods: {
    //去往文章详情页面
    goDetailReport(item) {
      this.$store.dispatch("checkHandle", "/pages-my/reportDetail/reportDetail?id=" + item.ArticleId);
    },
    /* 进入详情 校验是否有该品种权限 */
    goDetail(item) {
      uni.navigateTo({
        url: "/pages-report/IndustryReport/IndustryReport?id=" + item.IndustrialManagementId,
      });
    },
    //去往主题详情
    themeDetails(item) {
      if (item.Source === 1) {
        //非严选
        this.$store.dispatch("checkHandle", "/pages-report/IndustryReport/IndustryReport?id=" + item.IndustrialManagementId);
      } else {
        //严选
        this.$store.dispatch("checkHandle", "/pages-report/researchTheme/researchTheme?id=" + item.IndustrialManagementId);
      }
    },
    //收藏
    async collectClick(item) {
      const res = await Report.collectRpt({ ArticleId: item.ArticleId });
      if (res.Ret === 200) {
        item.IsCollect = !item.IsCollect;
        item.IsCollect
          ? (item.CollectNum += 1) &&
            uni.showToast({
              title: "收藏成功",
              icon: "none",
              duration: 2000,
            })
          : (item.CollectNum -= 1);
        !item.IsCollect &&
          uni.showToast({
            title: "已取消收藏",
            icon: "none",
            duration: 2000,
          });
      }
    },
    //点击了去关注
    goFollowShowBtn() {
      if (this.confirmText == "去关注") {
        uni.navigateTo({
          url: "/pages-activity/accountsOfficial/accountsOfficial",
        });
      }
      this.goFollowShow = false;
    },
  },
};
</script>
<style scoped lang="scss">
.container-report-page {
  background-color: #f5f6fa;
  .content-list {
    .list-ui {
      background-color: #fff;
      margin-top: 2rpx;
    }
    .item-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 100rpx;
      border-bottom: 1px solid #f6f6f6;
      padding: 0 30rpx;
      background-color: #fff;
      .publish {
        display: flex;
        align-items: center;
        color: #999999;
        font-style: 26rpx;
      }
    }
    .read-more {
      margin-top: 20rpx;
      display: flex;
      flex-wrap: wrap;
      margin-left: 30rpx;
      .text-box {
        margin-bottom: 27rpx;
        margin-right: 15rpx;
        padding: 0;
        font-size: 24rpx;
        color: #408fff;
        width: 216rpx;
        height: 46rpx;
        line-height: 46rpx;
        text-align: center !important;
        background: url(~@/static/img/report_bg.png) no-repeat;
        background-size: 100% 100%;
        text-indent: 0em;
      }
    }
  }
  .resource {
    padding: 0 30rpx;
    background-color: #fff;
    margin-top: 4rpx;
    height: 91rpx;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333333;
    font-size: 30rpx;
    margin-top: 20rpx;
    image {
      width: 34rpx;
      height: 36rpx;
      margin-right: 10rpx;
    }
  }
  .content-report {
    .content-item {
      background-color: #fff;
      padding: 35rpx 20rpx 0;
      .item-title {
        font-weight: 500;
        .item-industry {
          margin-left: 10rpx;
          color: #3385ff;
          display: inline-block;
        }
      }
      .item-user {
        display: flex;
        align-items: center;
        color: #999999;
        font-size: 28rpx;
        margin-bottom: 20rpx;
        image {
          width: 23rpx;
          height: 26rpx;
          margin-right: 20rpx;
        }
      }
      .item-more {
        display: flex;
        justify-content: space-between;
        color: #cecece;
        margin: 20rpx 0 0;
        padding-bottom: 30rpx;
        border-bottom: 1rpx solid #ececec;
        .pv-ollect {
          display: flex;
          align-items: center;
          width: 40%;
          justify-content: space-between;
          image {
            width: 22rpx;
            height: 21rpx;
            margin-right: 10rpx;
          }
          .pv {
            height: 16rpx;
          }
        }
      }
    }
  }
}
</style>
