h5_goods_class.html 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. {include file="public/header" /}
  2. <div class="data-class">
  3. <div data-parent_id="0" class="active"></div>
  4. </div>
  5. <script>
  6. $(function(){
  7. getClass(0)
  8. })
  9. var ac_list={}
  10. function getClass(parent_id){
  11. $.getJSON(ADMINSITEURL+'/Dashboard/h5_goods_class?ajax=1&parent_id='+parent_id,function(res){
  12. ac_list['i_'+parent_id]=res.result
  13. if(res.code==10000 && res.result.length){
  14. $('.data-class [data-parent_id='+parent_id+'] > .data-class-item .iconfont').html('&#xe6db;').attr('onclick','setClass('+parent_id+')')
  15. var html='<div class="data-class-children">'
  16. for(var i in res.result){
  17. getClass(res.result[i].gc_id)
  18. html+='<div data-parent_id="'+res.result[i].gc_id+'">'
  19. html+='<div class="data-class-item">'
  20. html+='<span class="iconfont"></span>'
  21. html+='<span onclick="setLink(\'/home/goodslist?cate_id='+res.result[i].gc_id+'\')">'+res.result[i].gc_name+'</span>'
  22. html+='</div>'
  23. html+='</div>'
  24. }
  25. html+='</div>'
  26. $('.data-class [data-parent_id='+parent_id+']').append(html)
  27. }
  28. })
  29. }
  30. function setClass(parent_id){
  31. if(ac_list['i_'+parent_id] && ac_list['i_'+parent_id].length){
  32. if($('.data-class [data-parent_id='+parent_id+']').hasClass('active')){
  33. $('.data-class [data-parent_id='+parent_id+']').removeClass('active')
  34. $('.data-class [data-parent_id='+parent_id+'] > .data-class-item .iconfont').html('&#xe6db;')
  35. }else{
  36. $('.data-class [data-parent_id='+parent_id+']').addClass('active')
  37. $('.data-class [data-parent_id='+parent_id+'] > .data-class-item .iconfont').html('&#xe6dc;')
  38. }
  39. }
  40. }
  41. </script>