<template>
<div class='container'>
<navigator class='reply-item' v-for='(v,i) in replyList' :key='i' :url="'../questiondetail/main?sysNewsId=0&cwxid='+v.cwxid" hover-class='hover'>
  <div class='head'>
    <img v-if='imgLoaded' :src='avatar' @error='imgLoaded=false'>
    <img v-else src='/static/imgs/avatar.png'>
    <div>
      <span class='name'>{{nickName}}</span>
      <span class='time'>{{v.replay_Date}}</span>
    </div>
  </div>
  <div class='reply'>{{v.consultant_Reply}}</div>
  <div class='question'>
    <div class='title'>{{v.consultant_Title}}</div>
    <div class='time'>{{v.consultant_Date}}</div>
    <div class='content'><span>{{v.wx_Name}}：</span>{{v.consultant_Content}}</div>
  </div>
</navigator>
<NoData v-if='loaded && replyList.length==0' paddingTop=0 />
</div>
</template>
<script>
import NoData from '@/components/NoData'
export default {
  components:{NoData},
  data() {
    return {
      replyList: [],
      imgLoaded: true,
      avatar: '/static/imgs/avatar.png',
      nickName: '',
      loaded: false
    }
  },
  methods: {
    loadReply() {
      this.loaded = false
      wx.showLoading({ title: '正在加载' })
      wx.request({
        url: this.rootUrl + '/qa/lawyerreply',
        data: { sessionID: wx.getStorageSync('sessionID') },
        success: res => {
          if (res.statusCode == '500') {
            this.service.getUnionId(this.rootAvatar, this.rootUrl).then(res => this.loadReply())
          } else {
            console.log(res.data)
            this.replyList = []
            this.replyList = res.data
            this.replyList.forEach(v => {
              v.replay_Date = this.service.correctTime(v.replay_Date,'full')
              v.consultant_Date = this.service.correctTime(v.consultant_Date,'full')
            })
            this.loaded = true
            wx.hideLoading()
          }
        },
        fail: res => {
          wx.hideLoading()
          wx.showToast({ title: '加载失败', icon: 'none' })
        }
      })
    }
  },
  onLoad() {
    const userInfo = wx.getStorageSync('userInfo')
    this.avatar = userInfo.avatarUrl
    this.nickName = userInfo.nickName
    this.loadReply()
  }
}
</script>
<style lang="stylus" scoped>
.container
  position absolute
  min-height 100%
  width 100%
  Background()
.reply-item
  padding 25rpx
  margin-bottom 20rpx
  background white
.head
  Flex(flex, , center)
  img
    Height_Width(80rpx)
    border-radius 50%
    margin-right 20rpx
  div
    Flex(flex, center, , column)
    .name
      Font(30rpx)
      margin-bottom 15rpx
    .time
      Font(26rpx)
      color #777
.reply
  Font(30rpx,45rpx)
  margin 20rpx 0
  text-align justify
.question
  padding 25rpx
  background #f6f6f6
  border 1rpx solid #eee
  Font(28rpx)
  .title
    Font(30rpx, 35rpx, bold)
  .time
    Font(26rpx)
    color #888
    margin 20rpx 0
  .content
    text-overflow ellipsis
    line-height 32rpx
    text-align justify
    span
      color #777
</style>

