$(function () {
  // 加载弹窗
  console.log('load popups.js');
  // 设备参数值
  const _device = $('.device').val();
  // 场景校验值
  const _scene_val = $('.index_identity').text();
  $.ajax({
    url: '/index.php?m=other&c=tools&a=popups',
    method: 'GET',
    data: {
      // scene: 1,
      device: _device ? _device : 1,
      scene_parasm: _scene_val ? _scene_val : 2
    },
    success: function({ code, msg, data }) {
      if (code == 20000) {
        $(document.body).append(`
          <!-- 首页弹窗开始 -->
          <div class="shade">
            <div class="popups">
              <i class="close_btn"></i>
                <a href="${data.url}">
                  <img src="${data.thumb}" alt="${data.title}">
                </a>
            </div>
          </div>
          <!-- 首页弹窗结束 -->  
        `);
        // 点击隐藏
        $('.close_btn').on('click', function () {
          $(this).parents('.shade').addClass('hide');
          window.setTimeout(function () {
            $('.shade').removeClass('hide');
          }, data.sleep);
        });
      }
    }
  });
});
