<template>
  <div>
    <van-nav-bar title="详情" left-text="返回" @click-left="$route_back" left-arrow>

    </van-nav-bar>

    <div class="body_com has_header" style="background:#fff;">
      <scroller>
        <div class="content">
          <div class="html-content" v-html="info.content"></div>
        </div>
        <div style="height:2rem;"></div>
      </scroller>
    </div>


  </div>
</template>

<script>
  export default {
    name: 'help_detail',
    data(){
      return {
        info:{
          name:'',
          content:''
        }
      }
    },
    watch: {
      '$route.query.name': function (val, old) {
        if(!window.plus){
          this.get_info()
        }
      }
    },
    created(){
      this.get_info()
      let self = this
      document.body.addEventListener('click', function (e) {
        let name = e.target.getAttribute('rel-go') || e.target.parentNode.getAttribute('rel-go') || e.target.parentNode.parentNode.getAttribute('rel-go')
        if(name){
          self.$router.push({name:'help_detail', query: {name: name}})
        }
      })
    },
    methods:{
      get_info(){
        let name = this.$route.query.name
        let content = localStorage.getItem('help_detail'+name)
        let all_doc_name = JSON.parse(localStorage.getItem('all_doc_name'))
        for(let i in all_doc_name){
          let reg = new RegExp('href\=\"'+all_doc_name[i]+'\"', "g")
          if(content != null){
            content = content.replace(reg, 'href="javascript:void(0);" rel-go="'+all_doc_name[i]+'"');
          }
        }
        if(content){
          this.info.content = content.replace(/\/uploads\//g, 'http://doc.js.dg263.net:8181/uploads/');
        }

      }
    }
  }
</script>


<style scoped>
  .submit_btn_box{padding:0.32rem;}
  .body_com{height: calc(100% - 1rem); position: relative;}
  .content{padding:0 0.32rem;}
  .html-content{width:100%;}
  .html-content img{max-width:100% !important; height: auto !important; width:100%;}
  .content .markdown-toc.editormd-markdown-toc{display: none;}
</style>
