function escapeSetS (el, types, val) {
  if (!el) return
  switch (types) {
    case 'img':
      el.src = val
      break
    case 'bgImg':
      el.style.backgroundImage = 'url(' + val +')'
      break
    case 'bgC':
      el.style.background = val
      break
    case 'bdC':
      el.style.borderColor = val
      break
    case 'text':
      el.innerHTML = val
      break
    case 'color':
      el.style.color = val
      break
  }
}

window.setStyle = function (Data) {
  Data = Data === '' ? {} : JSON.parse(Data)
  console.log(Data)
  for (var key in Data.data) {
    Data.data[key].forEach( function (item){
      if (item.index) {
        escapeSetS($(item.query)[item.index], item.editType, item[item.editType])
      } else {
        for (var i = 0, els = $(item.query); i < els.length; i++) {
          var $el = els[i];
          escapeSetS($el, item.editType, item[item.editType])
        }
      }
    })
  }
}
