<template>
<view style="background-color: #FFFFFF;height: 100vh;">
<view class="nav_section" v-if="list.length>0">
  <view>
    <view v-for="(item, index) in list" :key="index" class="nav_section_items">
      <view class="section_cont" data-aid="undefined">
        <view class="section_cont_tel">
          <text>访客类型：</text>
          <text class="fr classify" v-if="item.accessUserType==0">朋友</text>
          <text class="fr classify" v-else-if="item.accessUserType==1">外卖</text>
          <text class="fr classify" v-else-if="item.accessUserType==2">快递</text>
          <text class="fr classify" v-else-if="item.accessUserType==3">其他</text>
          <text class="fr classify" v-else>其他</text>
        </view>
       <view class="section_cont_tel">
          <text>开门密码：</text>
           <text class="fr">{{item.accessCardNo}}</text>
        </view>
        <view class="section_cont_tel"> <text>开门时间：</text> <text class="fr">{{item.accessDate}}</text></view>
        
      </view>
    </view>
  </view>
</view>
<view class="default" v-if="list==null || list.length==0">
    <image src="/static/empty.png" mode="heightFix"></image>
  <view>
    <text>没有获取到访客记录</text>
  </view>
</view>
</view>
</template>

<script>
//获取app实例
var app = getApp();
var util = require("../../utils/util.js");

export default {
  data() {
    return {
      list: null
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getPwdOpenRecord();
  },
  methods: {
    //获取访客记录
    getPwdOpenRecord: function () {
      let that = this;
      let params = {};
      params['member_id'] = app.globalData.member.id;
      let operation = 'accessRecords/getListByMemberId';
      app.globalData.postRequest(params, operation, function (res) {
        console.info("获取结果:" + res.data.result_msg); //获取成功

        if (res.data.result_code == 1) {
          let list = res.data.list;

          for (let i in list) {
            list[i].accessDate = util.formatTime(list[i].accessDate);
          }

          that.setData({
            list: list
          });
        }
      });
    }
  }
};
</script>
<style>
/* pages/myHome/myHome.wxss */
page{
  overflow-y: scroll;
}
.nav_section {
  width: 100%;
  overflow-y: scroll;
}

.nav_section_items {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding: 30rpx;
  border-bottom: 2rpx solid #ddd;
  position: relative;
  background: #fff;
  margin: 30rpx;
  border-radius: 10rpx;
}


.nav_section_items .section_image {
  width: 170rpx;
  height: 158rpx;
  position: relative;
}

.nav_section_items .identity {
  padding: 4rpx;
  top: 0;
  right: 0;
  background: #29afec;
  color: #fff;
  font-size: 24rpx;
  position: absolute;
}

.nav_section_items .section_image image {
  width: 100%;
  height: 100%;
}

.nav_section_items .section_cont {
  width: 100%;
  font-size: 26rpx;
  color: #a9a9a9;
}

.nav_section_items .section_cont view {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.nav_section_items .section_cont .section_cont_intro {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.nav_section_items .section_cont .section_cont_tel {
  font-size: 28rpx;
  color: #666;
  line-height: 80rpx;
  margin-bottom: 10rpx;
  width: 100%;
  border-bottom: 1px dashed #a9a9a9;
}
.nav_section_items .section_cont .section_cont_tel .classify{
  color: #d24a58;
}

.section_cont_tel .fr {
  float: right;
}
.default {
  text-align: center;
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
}
.default text{
	color: #AAAAAA;
}

.default image {
  height: 250rpx;
  display: inline-block;
}
</style>