<template>
<div>
    <div class="sele">
   <Candode v-on:childByValue="childByValue" style="width:30%"></Candode>
   <el-input v-model="idcard" style="width:30%" size="mini" clearable placeholder="请输入身份证号"></el-input>
   
    <div class="s"  style="width:30%">
  <el-select size="mini" @change="torz" clearable  v-model="state" placeholder="所有状态">
    <el-option
      v-for="item3 in stateList"
      :key="item3.value"
      :label="item3.label"
      :value="item3.value">
    </el-option>
  </el-select>
</div>
<el-button type="primary" size="mini" style="background:#148A9B;margin-left:10px" icon="el-icon-search" @click="serch">搜索</el-button>
   </div>
  <el-table
    :data="tableData"
    style="width: 100%"
    stripe>
    <el-table-column
      prop="idNumber"
      label="身份证号"
     >
    </el-table-column>
    <el-table-column
      prop="userName"
      label="姓名"
      >
    </el-table-column>
    
    <el-table-column
      prop="match_stateStr"
      label="认证状态"
      >
    </el-table-column>
    
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          v-if="scope.row.match_stateStr=='已认证'"
          size="mini"
          disabled
         
          >去认证</el-button>
             <el-button
          v-else
          size="mini"
         type="success"
          @click="toc(scope.$index, scope.row)"
          >去认证</el-button>
       
      </template>
    </el-table-column>
     
     
    
  </el-table>
  <div style="width:100%;height:80px;overflow:scroll;margin-bottom:20px">
  <el-pagination
  	class="pone"
      :page-size='10'
      layout="total, prev, pager, next"
      :total="totals"
      :current-page.sync="Page"
      @current-change="current_change"
      small
>

    </el-pagination>
    </div>
  </div>
</template>

<style scoped>
.op{
  display: flex;
  align-items: center;
 
}
  .idc{
  
    width: 200px
  }
  .nam{
    margin-right: 20px
  }
  .ywtyoe{
    width: 200px;
    margin-left: 20px
  }
  .el-table .warning-row {
    background: oldlace;
  }

  .el-table .success-row {
    background: #f0f9eb;
  }
  .pone{
    margin-top: 40px
  }
  .el-timeline{
    padding-left: 20px
  }
  
  .sele{
      display: flex;
      margin-top: 10px
  }
</style>

<script>
import Axios from "axios"
import Cookies from "js-cookie";
 import CryptoJS from 'crypto-js'
 import { Loading } from 'element-ui';
 import {listtown} from '../../utils/address'
import {baseUrl2} from "../../utils/global"
import defaultImg from "../../assets/defaultPicture.jpg"
import Candode from "../Core/candode"
  export default {
       components:{
	Candode
	},
       data() {
        
      return {
        townList:'',
        list:[],
         name:"",
         town:"",
         village:"",
         defaultImg: defaultImg,
        cit:"",
        Page:1,
        totals:0,
        idcard:"",
        ywtype:"",
        info:'',
        ywtype:'',
        tableData: [],
        list2:[],
        //认证状态
        state:"",
        stateList:[{
          value:"0",
          label:"认证成功",
        },{
          value:"2",
          label:"认证失败",
        },{
          value:"3",
          label:"未认证",
        }],
        //时间
        time:"",
        //年龄
        age:"",
        ageList:[{
          value:"0",
          label:"所有年龄段",
        },{
          value:"1",
          label:"55岁以下",
        },{
          value:"2",
          label:"55-59岁",
        },{
          value:"3",
          label:"60岁以上",
        },{
          value:"4",
          label:"90岁以上",
        },{
          value:"5",
          label:"100岁以上",
        }],
        //年龄计算方式
        agemeth:"1",
        agemethList:[{
          value:"1",
          label:"按年计算",
        },{
          value:"2",
          label:"按月计算",
        }],
        //参保类型
        cblx:"",
        cblxList:[{
          value:"0",
          label:"城镇居民",
        },{
          value:"1",
          label:"机关事业",
        },{
          value:"2",
          label:"企业员工",
        }]
      }
    },
    methods: {
      //去认证
      toc(s,d){
        console.log(d)
        window.location.replace("../own/auth/lib/nocrentry.html?idcard="+d.idNumber+"&&name="+encodeURI(d.userName))
      },
         childByValue(val){
       this.townList=val
      },
      //搜索
      serch(){
        Loading.service();
        this.serchs(1)
      },
      serchs(p){
        
        var start=""
        var end=""
        if(this.time){
        var d=this.time[0]
        var s=this.time[1]
        console.log(d)
         var mon=(parseInt(d.getMonth()) + 1)
         var emon=(parseInt(s.getMonth()) + 1)
         start = d.getFullYear()+"-"+mon+"-"+d.getDate()
        
         end=s.getFullYear()+"-"+emon+"-"+s.getDate()
        
        }
        console.log(this.townList)
     var data={
       province_name:"四川省",
       city_name:"南充市",
       county_name:"西充县",
       pageSize:10,
       page:p,
       town_name:this.townList[0],
       village_name:this.townList[1],
       iDCard:this.idcard,
       match_state:this.state,
       begin_time:start,
       end_time:end,
       siType:this.cblx,
       personName:this.name,
       address:this.agemeth,
       birthday:this.age
     }   
     Axios.get(baseUrl2+'/search/authentication.do',{
      params:data
})
.then(res => {
   let loadingInstance = Loading.service();
              this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
              loadingInstance.close();
            });
  this.tableData=res.data.obj
  this.totals=res.data.page.total_count
})
.catch(err => {
   let loadingInstance = Loading.service();
              this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
              loadingInstance.close();
            });
});
       
      },
      //流程
      progress(d,s){
       
      },
      
      current_change(ss){
        Loading.service();
        this.serchs(ss)
      },
      //
      handleChange(){
        Axios.get(baseUrl2+'/show/getVillageList.do?town_id='+this.town.split(",")[0],{
 
})
.then(res => {
  this.list2=res.data
})
.catch(err => {
  console.log(err);
});
      },
      torz(){

      },
      //查看
       handle(s,d){
        
        },
        handleDelete(g,h){
            console.log(g)
            console.log(h)
        },
        Encrypt(word) { //aes加密
				var key = CryptoJS.enc.Utf8.parse("KkweInfo23255625");
				let srcs = CryptoJS.enc.Utf8.parse(word);
				let encrypted = CryptoJS.AES.encrypt(srcs, key, {
					mode: CryptoJS.mode.ECB,
					padding: CryptoJS.pad.Pkcs7
				});
				return encrypted.toString();
			},
         decrypt(word){
			    var key = CryptoJS.enc.Utf8.parse("KkweInfo23255625");
			    var decrypt = CryptoJS.AES.decrypt(word, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
			    return CryptoJS.enc.Utf8.stringify(decrypt).toString();
      },
      decryptByDES(ciphertext) {
                var keyHex = CryptoJS.enc.Utf8.parse("KkweFace95271124");
                var decrypted = CryptoJS.DES.decrypt({
                    ciphertext: CryptoJS.enc.Base64.parse(ciphertext)
                }, keyHex, {
                    mode: CryptoJS.mode.ECB,
                    padding: CryptoJS.pad.Pkcs7
                });
                return decrypted.toString(CryptoJS.enc.Utf8);
            }
    },
   
    created(){
       Loading.service();
      this.serchs(1)
//       for(var i in listtown){
//     this.list.push({
//         value:listtown[i].town_name,
//         label:listtown[i].town_name,
//         children:[]
//     })
//     for(var j in listtown[i].chirld){
//         this.list[i].children.push({
//             value: listtown[i].chirld[j].village_name,
//             label: listtown[i].chirld[j].village_name
//         })
//     }
// }
// console.log(this.list)

// Axios.get(baseUrl2+'/show/getTownList.do?county_id=511325000000',{
 
// })
// .then(res => {
//  this.list=res.data
// })
// .catch(err => {
//   console.log(err);
// });
  
      
    }
  }
</script>
