common-top.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. $(function (){
  2. var headTitle = document.title;
  3. var tmpl = '<div class="header-wrap">'
  4. +'<a href="javascript:history.back();" class="header-back"><span>返回</span></a>'
  5. +'<h2>'+headTitle+'</h2>'
  6. +'<a href="javascript:void(0)" id="btn-opera" class="i-main-opera">'
  7. +'<span></span>'
  8. +'</a>'
  9. +'</div>'
  10. +'<div class="main-opera-pannel">'
  11. +'<div class="main-op-table main-op-warp">'
  12. +'<a href="'+WapSiteUrl+'/index.html" class="quarter">'
  13. +'<span class="i-home"></span>'
  14. +'<p>首页</p>'
  15. +'</a>'
  16. +'<a href="'+WapSiteUrl+'/tmpl/product_first_categroy.html" class="quarter">'
  17. +'<span class="i-categroy"></span>'
  18. +'<p>分类</p>'
  19. +'</a>'
  20. +'<a href="'+WapSiteUrl+'/tmpl/cart_list.html" class="quarter">'
  21. +'<span class="i-cart"></span>'
  22. +'<p>购物车</p>'
  23. +'</a>'
  24. +'<a href="'+WapSiteUrl+'/tmpl/member/member.html?act=member" class="quarter">'
  25. +'<span class="i-mine"></span>'
  26. +'<p>我的商城</p>'
  27. +'</a>'
  28. +'</div>'
  29. +'</div>';
  30. //渲染页面
  31. var html = template.compile(tmpl);
  32. $("#header").html(html);
  33. $("#btn-opera").click(function (){
  34. $(".main-opera-pannel").toggle();
  35. });
  36. //当前页面
  37. if(headTitle == "商品分类"){
  38. $(".i-categroy").parent().addClass("current");
  39. }else if(headTitle == "购物车列表"){
  40. $(".i-cart").parent().addClass("current");
  41. }else if(headTitle == "我的商城"){
  42. $(".i-mine").parent().addClass("current");
  43. }
  44. });