{
    template:'${tmpl}',
    data:function(){
      var validateMobile = (rule, value, callback) =>{
        if(value==""){
          callback(new Error('请输入手机号码'));
        }else{
          var x=(/^1(3|4|5|7|8)\d{9}$/.test(value));
          if(!x){
            callback(new Error('手机号码格式有误'));
          }else{
            callback();
          }
        }
      };
        return {
          input:'',
          state2: '',
          meihuaStyle: '',
          summerTabs: 2,
          restaurants: [],
          listArr:[],
          show2: false,
          checkBoxArr: [
            "政策查询",
            "政策推荐"
           
          ],
          activeClass: 0, 
          type: "政策查询"
        }
    },
    mounted:function(){
      $("#footer").hide();
        this.$root.rsData = [
            {
                label: '首页',
                codePath: '/'
            },
            {
                label: '政策图谱',
                codePath: '/'
            },
            {
                label: '政策资讯',
                codePath: '/'
            }
        ]
    },
    created:function(){

      $('#header_row').hide();
      $('#header').hover(function() {
        $('#header_row').show();
      }, function() {
        $('#header_row').hide();
      });
      var taht = this;
      taht.meihuaStyle = 'height:' + document.documentElement.clientHeight + 'px;width:' + document.documentElement.clientWidth + 'px';  
      window.addEventListener("resize",function(){
        taht.meihuaStyle = 'height:' + document.documentElement.clientHeight + 'px;width:' + document.documentElement.clientWidth + 'px';  
      });
    },
    methods:{
      createFilter(queryString) {
        return (restaurant) => {
          return (restaurant.value != '');
        };
      },
      handleIconClick(ev) {
        this.$root.loadingHome = true;
        setTimeout(()=>{
          this.$root.loadingHome = false;
        },3000);
        this.$root.pushx({
          title:"企业画像",
          name:"/entdrawing",
          params:{"obj": ev,"shouji": this.isNumber(this.state2) ? this.state2 : ''}
        });
      },
      querySearch(queryString, cb) {
        this.input = queryString;
        var obj = {
            name: queryString
        };
        var that = this;
        
        if (this.isNumber(queryString)) {
          function strlen(str){
              var len = 0;
              for (var i=0; i<str.length; i++) { 
              var c = str.charCodeAt(i); 
              if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) { 
                len++; 
              } 
              else { 
                len+=2; 
              } 
              } 
              return len;
          };
          if (strlen(queryString) == 11) {
            this.$root.postReq("/web/companyportraitCtl/phonequery",obj).then(d=>{
                if(d && d.status==0){
                  if (d.data.rows.length != 0) {
                    this.restaurants = d.data.rows;
                    var restaurants = d.data.rows;
                    var results = queryString ? restaurants.filter(that.createFilter(queryString)) : restaurants;
                    cb(results);
                  }
                }
            }).catch(e=>{
            });
          }else {
            console.log('不符合长度');
          };
        }else {
          this.$root.postReq("/web/companyportraitCtl/phonequery",obj).then(d=>{
              if(d && d.status==0){
                if (d.data.rows.length != 0) {
                  this.restaurants = d.data.rows;
                  var restaurants = d.data.rows;
                  var results = queryString ? restaurants.filter(that.createFilter(queryString)) : restaurants;
                  cb(results);
                }
              }
          }).catch(e=>{
          });
        }
      },
      isNumber(val) {
        var regPos = /^\d+(\.\d+)?$/;
        var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/;
        if(regPos.test(val) || regNeg.test(val)) {
            return true;
            } else {
            return false;
            }
        },
      searchResult () {
        if(this.state2!=""){
          if(this.type == "政策推荐"){
            this.$root.pushx({
                title: "政策推荐", 
                name: "/recommen",
                params: {
                  tminput: this.state2
                }
            });
          }else if(this.type == "政策查询"){
            this.$root.pushx({
                title: "政策查询", 
                name: "/policyquery",
                params: {
                  tminput: this.state2
                }
            });
          }
        }
        if (this.state2 != '') {          
          var obj = {
              name: this.state2
          };
          this.$root.postReq("/web/companyportraitCtl/phonequery",obj).then(d=>{
              if(d && d.status==0){
                console.log(d.data.rows.length);
                if (d.data.rows.length > 0) {
                  this.show2 = true;
                  this.listArr = d.data.rows;
                }else {
                  /*this.$message({
                    message: '无搜索结果',
                    type: 'warning'
                  });*/
                }
              }
          }).catch(e=>{
          });
        }else {
          this.$message({
            message: '请按提示输入',
            type: 'warning'
          });
        }
        
        /*if(this.summerTabs==2 && this.state2 != ''){
            this.input = this.state2;
            if (this.restaurants && this.restaurants.length == 1) {
              this.$root.loadingHome = true;
              setTimeout(()=>{
                this.$root.loadingHome = false;
              },3000);
              this.$root.pushx({
                title:"企业画像",
                name:"/entdrawing",
                params:{"obj": this.restaurants[0],"shouji": this.isNumber(this.state2) ? this.state2 : ''}
              });
            }else {
              this.$message({
                message: '请选择一个公司',
                type: 'warning'
              });
            }
          return ;
        }else {
          this.$message({
            message: '请按提示输入',
            type: 'warning'
          });
          return ;
        }*/
      },
      getItme(index) {
        this.activeClass = index; 
        if(index == 0 ){
          this.type = "政策查询"
        }else{
          this.type = "政策推荐"
        }
      },
    },
    computed:{
    },
    vname:"gsb-moreservice"
}
