<template>
  <view class="container-chart-item" @click="goDetail(list)">
    <text class="chart-title text_twoLine">{{ list.Title }}</text>
    <view class="item-content-img">
      <image :src="list.BodyHtml" mode=""></image>
    </view>
    <view class="chart-tag">
      <text class="tag-item" v-if="list.PtagName">{{ list.PtagName }}</text>
      <text class="tag-item" v-if="list.CtagName">{{ list.CtagName }}</text>
    </view>
    <view class="chart-collect" v-if="isMyChartCollection">
      <text class="cancel" @click.stop="myChartIsTop(list.ChartId)">{{ list.IsTop ? "取消置顶" : "置顶" }}</text>
      <text class="remove" @click.stop="myChartCollect(list.ChartId)">移除</text>
    </view>
    <view class="my-chart-collect" v-if="isMyChartCollection && list.IsTop"></view>
  </view>
</template>

<script>
export default {
  name: "",
  components: {},
  props: {
    list: {
      type: Object,
      default: {},
      required: true,
    },
    isMyChartCollection: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {};
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    goDetail(item) {
      if (item.HomeType !== 1) {
        /* 无需授权且已绑定 检验是或否有权限 */
        this.$store.dispatch("checkHandle", "/pageMy/chartPage/chartPage?id=" + item.ChartId);
      }
    },
    myChartIsTop(id){
      console.log('子组件');
      this.$emit("myChartIsTop", id)
    },
    myChartCollect(id){
      this.$emit("myChartCollect", id)
    }
  },
};
</script>
<style scoped lang="scss">
.container-chart-item {
  position: relative;
  width: 100%;
  padding: 20rpx 20rpx 0;
  background: #ffffff;
  box-shadow: 0rpx 3rpx 8rpx 0rpx rgba(0, 0, 0, 0.16);
  border-radius: 8rpx;
  margin-bottom: 20rpx;
  .chart-title {
    height: 90rpx;
    font-size: 32rpx;
    font-weight: 500;
    color: #333333;
    line-height: 42rpx;
    border-bottom: 1rpx solid #dcdfe6;
  }
  .item-content-img {
    width: 330rpx;
    height: 286rpx;
    image {
      width: 100%;
      height: 100%;
    }
  }
  .chart-collect {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20rpx;
    .cancel {
      background: #3385ff;
      margin-right: 20rpx;
      color: #ffffff;
    }
    .remove {
      border: 1px solid #3385ff;
      color: #3385ff;
    }
    text {
      width: 150rpx;
      height: 46rpx;
      line-height: 46rpx;
      border-radius: 4rpx;
      text-align: center;
      font-size: 24rpx;
    }
  }
  .my-chart-collect {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-top: 60rpx solid #3385ff;
    border-right: 60rpx solid transparent;
  }
  .chart-tag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 78rpx;
    border-top: 1rpx solid #dcdfe6;
    .tag-item {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 150rpx;
      height: 38rpx;
      border-radius: 28rpx;
      border: 2rpx solid #3189ff;
      color: #3385ff;
      font-size: 24rpx;
    }
  }
}
</style>
