var hangYe = '';
var ziLi = '';
window.onload = function () {
initData();
document.getElementById('btn').addEventListener('click', function() {
    if(hangYe==""||ziLi==""){
          alert('请先选择行业类别和租赁资历');
      }else{
        window.sessionStorage.setItem('hangYe',hangYe);
        window.sessionStorage.setItem('ziLi',ziLi);
        window.open('./jiaMeng3.html','_self');
      }
  });
  document.getElementById('hang-ye').addEventListener('click', function() {
    openHangYeModel();
    setHangYeOption();
  });
  document.getElementById('zi-li').addEventListener('click', function() {
      openZiLiModel();
      setZiLiOption();
  });

}; 
function initData(){
  hangYe = '行业内人士';
  document.getElementById('hang-ye').innerHTML = '行业内人士';
  ziLi = '有相关租赁经验';
  document.getElementById('zi-li').innerHTML = '有相关租赁经验';
}
function resetQu(){
  document.getElementById('qu').innerHTML ='<div class="model-item" data-value="0">请选择</div>';
}
function openHangYeModel(){
  document.getElementById('hang-ye-model').style = 'display: flex;';
}
function closeHangYeModel(){
  document.getElementById('hang-ye-model').style = 'display: none;';
}
function setHangYeOption(){
   let listHtml = '';
  for (let index = 0; index < hangYeList.length; index++) {
    const element = hangYeList[index];
    listHtml += `<div class="model-item" data-value="`+element.name+`">`+element.name+`</div>`
  }
  if(listHtml==""){
    listHtml = ` <div class="model-item" data-value="0">请选择</div>`
  }
  document.getElementById('hang-ye-content').innerHTML = listHtml;
  document.getElementById('hang-ye-content').addEventListener('click', function(e) {
    hangye = e.target.dataset.value;
    document.getElementById('hang-ye').innerHTML = e.target.dataset.value;
    closeHangYeModel();
  });
  
}
function openZiLiModel(){
  document.getElementById('zi-li-model').style = 'display: flex;';
}
function closeZiLiModel(){
  document.getElementById('zi-li-model').style = 'display: none;';
}

function setZiLiOption(){
  let listHtml = '';
  for (let index = 0; index < ziLiList.length; index++) {
    const element = ziLiList[index];
    listHtml += `<div class="model-item" data-value="`+element.name+`">`+element.name+`</div>`
  }
  if(listHtml==""){
    listHtml = ` <div class="model-item" data-value="0">请选择</div>`
  }
  document.getElementById('zi-li-content').innerHTML = listHtml;
  document.getElementById('zi-li-content').addEventListener('click', function(e) {
    ziLi = e.target.dataset.value;
    document.getElementById('zi-li').innerHTML = e.target.dataset.value;
    closeZiLiModel();
  });
}
var hangYeList = [
  {
      name:'行业内人士'
  },
  {
      name:'非行业内人士'
  },
];
var ziLiList = [
  {
      name:'有相关租赁经验'
  },
  {
      name:'无相关租赁经验'
  },
];
