<template>
  <div class="main">
    <div
      class="newContent"
      v-if="detailObj.content"
      v-html="detailObj.content"
    ></div>
    <!-- <div class="pageTitle">{{ detailObj.NOTICEINFO_TITLE || "" }}</div>
    <div class="time">{{ detailObj.START_DATE || "-" }}</div>
    <div
      class="navList"
      v-if="detailObj.ImageList && detailObj.ImageList.length > 0"
    >
      <image
        class="img"
        :src="detailObj.ImageList[0].ImageUrl"
        @click="handleShowPreview(detailObj.ImageList[0].ImageUrl)"
      />
    </div>
    <text class="content">{{ detailObj.NOTICEINFO_CONTENT || "" }}</text> -->
  </div>
</template>
<script>
export default {
  data() {
    return {
      detailObj: {
        // NOTICEINFO_TITLE: "",
        // START_DATE: "",
        // NOTICEINFO_CONTENT: "",
      },
    };
  },
  onLoad(query) {
    console.log("query", query);
    if (query.id) {
      // this.hanldeGetDetail(query.id);
      this.handleGetNewDetail(query.id);
    }
    this.$utils.addUserBehaviorNew();
  },
  methods: {
    // 找到id一样的
    async handleGetNewDetail(id) {
      let start = `${this.$moment
        .now()
        .set("month", -1)
        .format("YYYY-MM-DD")} 00:00:00`;
      let end = `${this.$moment.now().format("YYYY-MM-DD")} 23:59:59`;
      let params = {
        startQueryTime: start, // 开始时间
        endQueryTime: end, // 结束时间
      };
      let time = Math.ceil(new Date().getTime() / 1000);

      let req = {
        app_id: "530000301",
        biz_content: JSON.stringify(params),
        charset: "UTF-8",
        pid: "530000301",
        service: "trawe.eats.etc",
        utc_timestamp: time,
        version: "1.0",
        sign_type: "RSA2",
      };
      let signText = `app_id=${req.app_id}&biz_content=${req.biz_content}&charset=UTF-8&pid=${req.app_id}&service=trawe.eats.etc&utc_timestamp=${req.utc_timestamp}&version=1.0`;
      console.log("handleGetHighwayHeadlines", req);
      console.log("signText", signText);

      // 签名
      const sign = await new Promise((resolve, reject) => {
        uni.request({
          url: "http://10.104.1.159:8080/RSA/sign",
          method: "POST",
          data: {
            originalText: signText,
            privateKey:
              "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSi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mOINqWB3NPXgPzm1X0EgA+rDZ8K3tZUxOMGeccDSnSWipLne5QTNyExThOzZVJG0qNEombVOeu2zyq/aECunoktnzWllim96CrdcsJPZAk+Z7rNOcdu6sfa7teph4HZs9pT00VOK4jZ0a+GV71uUDHEkplhNhxAoGAMDOi5BxFe/595KIR7C/xboMUaQh/iDuPn2dzxmcUx0LLPUfkFPhEBV1mhAIzFFDI/JJYK6HR5m/fe7Q7DritRbaddCTtlB4NVK5k1gOJ3oN4s9ZD3Jxt5p/GuQ1sP7F9Zs3QP4KSkL34MwgGx9zdbPFofACnV4TWdN+KrJGjYMsCgYAE0CMM7rYHGY3Vt3/WZZJ+DPlKE6Q+uvFDomtsB1IavCeEJyjBP9+GhBHat86aA3mCFjf4emj1or7OEgPc0gCMtKBG6m10CrzLjzdWnOTveqWVUW/FS2gf17cIO5/FK/4KmAjH/QN24KXm395Qu8C0UFfgA66yysakJFkvXVBiPg==",
          },
          header: {
            "content-type": "application/json",
          },
          success(res) {
            console.log("resresresresresresres", res);
            resolve(res.data.data);
          },
        });
      });
      console.log("sign", sign);

      req.sign = sign;

      // 推文数据
      const tweetsData = await new Promise((resolve, reject) => {
        uni.request({
          url: `https://sxgzh.etclife.cn/etc/api/v1/wx/point/tweets`,
          method: "POST",
          data: req,
          header: {
            "content-type": "application/x-www-form-urlencoded",
          },
          success(res) {
            console.log(
              "resresresresresresresresres",
              res.data.response.data.data.tweets
            );
            resolve(res.data.response.data.data.tweets);
          },
        });
      });

      console.log("tweetsData", tweetsData);
      if (tweetsData && tweetsData.length > 0) {
        tweetsData.forEach((item) => {
          if (Number(item.id) === Number(id)) {
            this.detailObj = item;
          }
        });
      }
      console.log("this.detailObj", this.detailObj);
    },
    // 预览查看
    handleShowPreview(url) {
      uni.previewImage({
        current: url, // 当前显示图片的http链接
        urls: [url], // 需要预览的图片http链接列表
      });
    },
    async hanldeGetDetail(id) {
      const req = {
        NOTICEINFOId: id,
      };
      const data = await this.$api.$get(
        "/EShangApiMain/Notice/GetNOTICEINFODetail",
        req
      );
      console.log("detail", data);
      const formattedText =
        data.Result_Data.NOTICEINFO_CONTENT.split("\n").join("\n\n");
      this.detailObj = data.Result_Data;
      this.detailObj.NOTICEINFO_CONTENT = formattedText;
    },
  },
};
</script>

<style scoped lang="less">
.main {
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
  padding: 16rpx 32rpx;
  background: #fff;
  overflow-y: scroll;

  .pageTitle {
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 40rpx;
    color: #130f05;
    line-height: 56rpx;
    text-align: left;
    font-style: normal;
  }

  .time {
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 24rpx;
    color: #716f69;
    line-height: 36rpx;
    text-align: left;
    font-style: normal;
    margin-top: 8rpx;
  }

  .navList {
    width: 100%;
    height: 100%;
    border-radius: 6rpx;
    overflow: hidden;
    margin: 40rpx 0;

    .img {
      width: 100%;
      height: 100%;
    }
  }

  .content {
    display: block;
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 30rpx;
    color: #130f05;
    line-height: 52rpx;
    text-align: justify;
    font-style: normal;
    overflow-y: auto;
  }
}
.main::-webkit-scrollbar {
  display: none;
}
</style>
