<template>
  <div class="app-container">
    <van-nav-bar
      :title="title"
      fixed
      placeholder
      left-arrow
      @click-left="onClickLeft"
    />
    <div class="listBox">

      <p class="title">{{detail.title}}</p>
      <p class="wordForm">{{detail.createBy}}<span>{{detail.newsTime}} 发布</span></p>

      <div id="content"></div>

    </div>
  </div>
</template>
<script>
import { newsDetail } from "@/api/lawEnforcement/index";
import law from "@/components/common/law_footer";
export default {
  name: "index",
  components: {
    law
  },
  data() {
    return {
      //是否显示加载
      loading: false,
      //是否滚动到底部
      finished: false,
      //查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 5,
        deptId:100,
        number:2
      },
      //新闻集合
      newList:[],
      //轮播图集合
      bannerList:'',
      title:'',
      detail:[]
    };
  },
  created() {
    var type = this.$route.query.type ;
    if (type == 'work'){
      this.queryParams.number = '003'
      this.title = '工作动态'
      this.goDetail();
    }
    if (type == 'notice'){
      this.queryParams.number = '001'
      this.title = '通知公告'
      this.goDetail();
    }
    if (type == 'enforcement'){
      this.queryParams.number = '002'
      this.title = '执法依据'
      this.goDetail();
    }
  },
  methods: {
    goDetail(){
      newsDetail(this.$route.query.id).then(response => {
        console.log(response)
        this.detail = response.data
        document.getElementById('content').innerHTML = response.data.content;
        var imgs=document.getElementsByTagName('img');
        console.log(imgs)
        for(var i=0;i<imgs.length;i++){
          imgs[i].setAttribute('width','100%');
        }
      });
    }
  },
};
</script>

<style scoped lang="scss">
@font-face {
  font-family: SourceHanSansCNBold;
  src: url("../../../assets/fonts/SourceHanSansCN-Bold.otf");
}
.wid100{
  width: 100%;
}
.app-container {
  padding: 10PX ;
}
/deep/ .van-nav-bar--fixed{
  background: url("../../../../static/images/lawEnforcement/head_bg.png") 100%;
}
/deep/ .van-nav-bar .van-icon{
  color: #ffffff;
}
/deep/ .van-nav-bar__title{
  color: #ffffff;
}
.title{
  font-size: 22PX;
  font-family: SourceHanSansCNBold;
  text-align: center;
}
.wordForm{
  text-align: center;
  margin: 15PX 0 20PX;
  span{
    color: #C9C9C9;
    margin-left: 10PX;
  }
}
.listBox{
  border-radius: 8Px;
  overflow: hidden;
  box-shadow: 0PX 5PX 5PX #cccccc;
  background: #ffffff;
  padding: 30PX 10PX;
}
</style>
