<template>
  <view class="container my-message">
    <view v-if="haveData">
      <view class="collect-item" v-for="(item, index) in messageList" :key="index" @click="goDetail(item)">
        <view class="item-row">
          <text class="item-content-title">留言内容:</text>
          <text>{{ item.Content }}</text>
        </view>
        <view class="item-title">
          <view class="item-row">
            <text class="item-content-title">留言对象:</text>
            <text class="item-content-text">{{ item.Title }}</text>
          </view>
        </view>
        <text class="time">{{ dateFormatterHandler(item.CreateTime) }}</text>
      </view>
    </view>
    <view class="nodata" v-else>
      <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/act_search.png" mode="" class="nodata_ico"></image>
      <text>暂时没有留言的内容</text>
    </view>
  </view>
</template>

<script>
import { User } from "@/config/api.js";
import { dateFormatter } from "@/config/util.js";
export default {
  data() {
    return {
      messageList: [],
      haveData: true,
    };
  },
  methods: {
    // 获取数据
    async getList() {
      const res = await User.commentListMessage();
      if (res.Ret === 200) {
        this.messageList = res.Data.List || [];
        this.haveData = this.messageList.length ? true : false;
      }
    },

    // 去往详情
    goDetail(item) {
      if (item.RedirectType == 1) {
        uni.navigateTo({
          url: "/pageMy/reportDetail/reportDetail?id=" + item.ArticleId,
        });
      } else if (item.RedirectType == 2) {
        uni.navigateTo({
          url: "/activityPages/activityDetail/activityDetail?id=" + item.ActivityId,
        });
      } else {
        uni.navigateTo({
          url: "/reportPages/IndustryReport/IndustryReport?id=" + item.IndustryId,
        });
      }
    },

    // 处理时间
    dateFormatterHandler(val) {
      return dateFormatter(val, true);
    },
  },
  onLoad() {
    this.$store.commit("setRouterActivity", "我的留言");
    this.$store.commit("setRouterReport", "我的留言");
    this.getList();
  },
};
</script>

<style lang="scss" scoped>
.my-message {
  background: #f7f7f7;
  padding: 20rpx 30rpx;
  .collect-item {
    padding: 30rpx 30rpx;
    color: #333333;
    font-size: 28rpx;
    background: #fff;
    margin-bottom: 20rpx;
  }
  .item-row {
    font-size: 28rpx;
    color: #333;
    margin-bottom: 20rpx;
    border-radius: 4rpx;
    .item-content-title {
      font-size: 24rpx;
      color: #999;
    }
    .item-content-text {
      color: #3385ff;
    }
  }
  .item-title {
    padding-top: 20rpx;
    border-top: 2px dashed #dcdfe6;
  }
  .time {
    text-align: right;
    font-size: 22rpx;
    color: #999;
  }
}
</style>
