<template>
  <view>
    <artical-deatil :model="model"></artical-deatil>
  </view>
</template>

<script>
import md5 from "@/common/md5.js";
import ArticalDeatil from "../../components/artical-deatil/index";
export default {
  data() {
    return {
      model: {},
      id: "",
    };
  },
  components: {
    ArticalDeatil,
  },
  onLoad(op) {
    this.id = op.id;
    // console.log(this.id);
    this.getNotice()
  },
  methods: {
    getNotice() {
      let md5Sign = md5(
        "method=" +
          "common" +
          "&timestamp=" +
          getApp().globalData.globalTimestamp +
          "&secret=" +
          getApp().globalData.secret
      );
      let url =
        getApp().globalData.shareUrl +
        "api/api.php" +
        "?method=common&source=notice&action=info_by_id&timestamp=" +
        getApp().globalData.globalTimestamp +
        "&sign=" +
        md5Sign;
      let postData = {
        id: this.id,
      };

      //获取文章
      uni.request({
        url: url,
        method: "POST",
        header: {
          "content-type": "application/x-www-form-urlencoded",
        },
        data: postData,
        success: (res) => {
          if (res.data.code === 200) {
            let data = res.data.data;
            this.$set(this.model, "title", data.title);
            this.$set(this.model, "way", data.title);
            let time = this.$options.filters["globalTime"](data.publish_time);
            let timeSecond = this.$options.filters["globalTimeSecond"](
              data.publish_time
            );
            this.$set(this.model, "time", time + " " + timeSecond);
            this.getRich();
            // console.log("ddd");
            // console.log(timeSecond);
            // console.log(new Date(data.addtime));
            //mode title way  time artical
            // console.log(res.data.data.list);
            // this.noticeList = res.data.data.list;
            // console.log(res.data);
          }
        },
        fail: () => {
          console.log("连接失败");
        },
      });
    },
    getRich() {
      uni.request({
        url: `https://kiq.xazhima.com/content/notice/${Math.floor(
          this.id / 1000
        )}/${this.id}.html`,
        method: "GET",
        header: {
          "content-type": "application/x-www-form-urlencoded",
        },

        success: (res) => {
          console.log(res);
          if (res.statusCode === 200) {
            this.$set(this.model, "artical", res.data);
          }
        },
        fail: () => {
          console.log("连接失败");
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>