index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. $(function() {
  2. $.ajax({
  3. url: ApiUrl + "/index.php?act=index",
  4. type: 'get',
  5. dataType: 'json',
  6. success: function(result) {
  7. var data = result.datas;
  8. var html = '';
  9. $.each(data, function(k, v) {
  10. $.each(v, function(kk, vv) {
  11. switch (kk) {
  12. case 'adv_list':
  13. case 'home3':
  14. $.each(vv.item, function(k3, v3) {
  15. vv.item[k3].url = buildUrl(v3.type, v3.data);
  16. });
  17. break;
  18. case 'home1':
  19. vv.url = buildUrl(vv.type, vv.data);
  20. break;
  21. case 'home2':
  22. case 'home4':
  23. vv.square_url = buildUrl(vv.square_type, vv.square_data);
  24. vv.rectangle1_url = buildUrl(vv.rectangle1_type, vv.rectangle1_data);
  25. vv.rectangle2_url = buildUrl(vv.rectangle2_type, vv.rectangle2_data);
  26. break;
  27. }
  28. html += template.render(kk, vv);
  29. return false;
  30. });
  31. });
  32. $("#main-container").html(html);
  33. $('.adv_list').each(function() {
  34. if ($(this).find('.item').length < 2) {
  35. return;
  36. }
  37. Swipe(this, {
  38. startSlide: 2,
  39. speed: 400,
  40. auto: 3000,
  41. continuous: true,
  42. disableScroll: false,
  43. stopPropagation: false,
  44. callback: function(index, elem) {},
  45. transitionEnd: function(index, elem) {}
  46. });
  47. });
  48. }
  49. });
  50. $('.search-btn').click(function(){
  51. var keyword = encodeURIComponent($('#keyword').val());
  52. location.href = WapSiteUrl+'/tmpl/product_list.html?keyword='+keyword;
  53. });
  54. });