<template>
  <div class='container'>
    <div class="row">
      <span class="title">代班人</span>
      <span class="cont">{{name}}</span>
    </div>
    <div class="row">
      <span class="title">代班社区</span>
      <span class="cont">{{commName}}</span>
    </div>
    <div class="row">
      <span class="title">代班时间</span>
      <span class="cont">{{createDate}}</span>
    </div>
    <div class="row">
      <span class="title">代班事由</span>
      <span class="cont">{{cause}}</span>
    </div>
   <!-- <div class="row">
      <span class="title">审批人</span>
      <span class="cont">{{substitute.name}}</span>
    </div>
    <div class="row">
      <span class="title">审批状态</span>
      <span class="cont">
        <span class="status ongoing" v-if="substitute.status ==0">申请中</span>
        <span class="status finish" v-else>已审批</span>
      </span>
    </div>-->
  </div>
</template>

<script>
  export default {
    data() {
      return {
        substitute: null,
        id: null,
        sysNewsId: '',
        createDate: null,
        loaded: false,
        name: '',
        commName: '',
        cause: ''
      }
    },
    methods: {
      loadArticles () {
        this.getList()
      },
      getList(){
        wx.showLoading({ title: '正在加载' })
        wx.request({
          url: this.rootUrl + 'lawSubstitute/getSubstitute',
          method: 'get',
          header: {'content-type': 'application/x-www-form-urlencoded'},
          data:{
            id: this.id,
            sysNewsId: this.sysNewsId,
            sessionID: wx.getStorageSync('sessionID')
          },
          success: res=> {
            if(res.statusCode=='500'){
              this.service.getUnionId(this.rootAvatar,this.rootUrl).then(res=>{
                console.log(res)
                this.loadArticles()
              })
            }else{
              console.log(res.data)
              this.createDate = this.service.correctTime(res.data.schedule_Date , 'full')
              this.substitute = res.data
              this.cause = res.data.cause
              this.name = res.data.name
              this.commName = res.data.comm_Name
              // this.createDate = util.formatTime(res.data.createDate)
              wx.hideLoading()
            }
          },
          fail: res=> {
            console.log(res)
          }
        })
      },
    },
    onLoad(){
      this.id = this.$root.$mp.query.id
      this.sysNewsId = this.$root.$mp.query.sysNewsId
      this.getList()
    },
    onShow() {
      this.loadArticles()
    },
    onUnload(){
      this.substitute = null
      this.id = null
      this.sysNewsId = ''
      this.loaded = false
    }
  }
</script>
<style lang="stylus" scoped>
.container
  position absolute
  Height_Width(100%)
  Background()
.row
  width 100%
  box-sizing border-box
  padding 25rpx
  background-color #fff
  border-bottom 1rpx solid #eee
  line-height 40rpx
.title
  color #888
.cont
  float right
  color #333
.status
  display inline-block
  padding 5rpx 10rpx
  border-radius 6rpx
  color #fff
  font-size 26rpx
.ongoing
  background-color #f6b35a
.finish
  background-color #00D49D
</style>

