<template>
  <div class="mainPage">
    <div class="top">
      <topCaseInfo :data="topCaseInfoData" :userName="userInfo.customer.RealName ? userInfo.customer.RealName : userInfo.customer.CustomerName"></topCaseInfo>
    </div>
    <div class="info" v-if="list.length > 0">
      <span><em>姓名</em>：{{list[0].CustomerName}}</span>
      <span><em>手机号</em>：{{list[0].Phone}}</span>
    </div>
    <div class="list-content" v-if="list.length > 0">
      <div class="list-year">备注记录</div>
      <div style="background:#fff">
        <div class="list-card" v-for="(item,index) in list" :key="index">
          <div class="point-top"></div>
          <div class="point-bottom"></div>
          <div class="card-time">{{toolClass.dateFormat(item.CreateDate,'MM-dd')}}</div>
          <div class="card-content">{{item.Remark}}</div>
        </div>
      </div>
    </div>
    <noMore v-if="list.length <= 0"></noMore>
  </div>
</template>

<script>
import topCaseInfo from '../../../components/topCaseInfo/index'
import noMore from '../../../components/noMore/noMore'
import { mapState, createNamespacedHelpers } from 'vuex'
const { mapActions: actions } = createNamespacedHelpers('app')
const { mapState: mapRemarkState, mapActions: mapRemarkActions } = createNamespacedHelpers('remark')
export default {
  name: '',
  data () {
    return {
      topCaseInfoData: {
        caseName: '',
        caseId: '',
        ShowSelect: false,
      },
    }
  },
  components: {
    topCaseInfo,
    noMore
  },
  computed: {
    ...mapState({
      userInfo: x => x.userCenter.userInfo,
      CaseList: x => x.app.CaseList,
    }),
    ...mapRemarkState({
      list: x => x.remarkList
    }),
  },
  created () {
    this.getCaseList().then((res) => {
      this.topCaseInfoData.caseId = this.userInfo.customer.BelongCaseId
      for (let i = 0; i < this.CaseList.length; i++) {
        if (this.CaseList[i].CaseId === this.topCaseInfoData.caseId) {
          this.topCaseInfoData.caseName = this.CaseList[i].CaseName
        }
      }
      this.getRemark({ salesId: this.userInfo.customer.MapUser, customerId: this.$route.query.customerId }).then(() => {
        console.log(this.list)
      })
    })
  },
  methods: {
    ...actions([
      'getCaseList',
    ]),
    ...mapRemarkActions([
      'getRemark',
    ])
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
@import 'page.scss';
</style>
