<template>
  <view v-if="textData.ButtonText" class="container container-templateMsg">
    <view>
      {{ textData.Content }}
    </view>
    <view class="ButtonText" @click="routerHandler">
      {{ textData.ButtonText }}
    </view>
    <Loading />
  </view>
</template>

<script>
import { MsgTemplate } from "@/config/api.js";
export default {
  data() {
    return {
      textData: {},
    };
  },
  methods: {
    // 获取数据
    async getData(options) {
      const res = await MsgTemplate.microRoadshowDetail({
        SourceId: options.SourceId,
        SourceType: options.SourceType,
      });
      if (res.Ret === 200) {
        this.textData = res.Data;
        this.textData.ButtonText = options.SourceType == 1 ? "查看报告详情" : options.SourceType == 2 ? "查看活动详情" : "查看音视频详情";
      }
    },
    // 跳转页面
    routerHandler() {
      if (this.textData.RedirectType == 1) {
        uni.navigateTo({ url: "/pageMy/reportDetail/reportDetail?id=" + this.textData.SourceId });
      } else if (this.textData.RedirectType == 2) {
        uni.navigateTo({ url: "/activityPages/activityDetail/activityDetail?id=" + this.textData.SourceId });
      } else {
        uni.navigateTo({ url: "/reportPages/IndustryReport/IndustryReport?id=" + this.textData.SourceId });
      }
    },
  },
  onLoad(options) {
    wx.setNavigationBarTitle({
      title: options.SourceType == 2 ? "问题详情" : "留言详情",
    });
    this.getData(options);
  },
};
</script>

<style scoped lang="scss">
.container-templateMsg {
  padding: 50rpx;
  font-size: 34rpx;
  line-height: 48rpx;
  color: #333;
  .ButtonText {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 304rpx;
    height: 78rpx;
    margin: 360rpx auto 0;
    background: #376cbb;
    border-radius: 4rpx;
    color: #fff;
    font-size: 32rpx;
  }
}
</style>
