<template>
  <view>
    <uni-card>
      <uni-search-bar :radius="100" @confirm="search" placeholder="请输入证件号或手机号搜索" v-model="form.lrZjhm"></uni-search-bar>
      <uni-list>
        <uni-list-item v-for="(item,index) in dataList" :key="index" :title="item.lrXm"
          :thumb="item.lrTx?config.baseUrl+item.lrTx:config.baseUrl + config.head" :note="item.sqyy" thumbSize="lg" :showArrow="false">
          <template v-slot:footer>
            <view v-if="item.spjg == '0'" class="item-right">
              <text>{{item.sqsj.substring(0,8) }}</text>
              <image class="item-img" src="@/static/images/tongguo.png" mode=""></image>
            </view>
            <view v-else-if="item.spjg == '1'" class="item-right">
              <text>{{item.sqsj.substring(0,8) }}</text>
              <image class="item-img" src="@/static/images/jujue.png" mode=""></image>
            </view>
            <view v-else class="item-right">
              <text>{{item.sqsj.substring(0,8) }}</text>
              <image class="item-img" src="@/static/images/daishenhe.png" mode=""></image>
            </view>
          </template>
        </uni-list-item>
      </uni-list>
      <uni-load-more status="status" @clickLoadMore="clickLoadMore"></uni-load-more>
    </uni-card>
  </view>
</template>

<script>
  import {
    getToken,
    getUser
  } from '@/common/auth.js'
  import {
    ListKhjbxx,
    ListKhShxx
  } from '@/api/kh.js'
  import {
    decryptRowData_ECB
  } from '@/common/sm4.js'
  export default {
    components: {},
    data() {
      return {
        status: 'more',
        form: {
          pageNum: 1,
          pageSize: 10,
          lrId: ''
        },
        dataList: [],
        total: 0,
      }
    },
    mounted() {
      this.userInfo = getUser()
      // if (this.userInfo.userType == '07') {
      //   this.info(this.userInfo.userId)
      // } else {
      //   this.form.createUserId = this.userInfo.userId
      // }
			if(this.userInfo.userType !== '00'){
				this.form.createUserId = this.userInfo.userId
			}
      this.getList()
    },
    created() {},
    onLoad: function(options) {
      this.form.lrId = options.lrId
    },
    onPullDownRefresh() {
      this.dataList = []
      this.form.pageNum = 1
      this.form.pageSize = 10
      this.getList()
    },
    onReachBottom() {
      if (this.dataList.length < this.total) {
        this.form.pageNum += 1
        this.getList()
      }
    },
    methods: {
      search() {
        this.dataList = []
        this.form.pageNum = 1
        this.form.pageSize = 10
        this.getList()
      },
      clickLoadMore(e) {
        this.status = 'loading'
        if (this.dataList.length < this.total) {
          this.form.pageNum += 1
          this.getList()
        } else {
          this.status = 'no-more'
        }
      },
      getList() {
        ListKhShxx(this.form).then(res => {
          if (res.code == 200) {
            this.total = res.total
            // let list = decryptRowData_ECB(res.rows, ["lrZjhm", "lrXm", "lrHjbcxx", "lrXjdzBcxx",
            // 	"lrCydh", "lrPoxm", "lrPoZjmh", "jhrXm", "jhrSjhm", "zlrXm", "zlrDh", "cjzh",
            // 	"yhzh", "khmc"
            // ], [2, 1, 4, 4, 3, 1, 2, 1, 2, 1, 3, 5, 5, 5])
            let list = res.rows
            this.dataList.push(...list)
            uni.stopPullDownRefresh();
            if (this.dataList.length < this.total) {
              this.status = 'more'
            } else if (this.dataList.length == this.total) {
              this.status = 'no-more'
            }
          }
        })
      }
    },
    watch: {},
  }
</script>

<style lang="scss" scoped>
  .item-right {
    width: 60px;
    display: flex;
    flex-direction: column;
    background-position: left;
    background-size: 58px 58px;
    background-repeat: no-repeat;
    position: relative;
    font-size: 14px;

    .item-img {
      position: absolute;
      right: -5px;
      bottom: -10px;
      height: 40px;
      width: 40px;
    }
  }
</style>