human.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. $(function(){
  2. var humanList;
  3. $('.human-list').height($('html').height());
  4. //页面初始化
  5. pInt();
  6. function pInt(){
  7. var wh=($(window).height()/468).toFixed(2);
  8. var wleft=($(window).width()-$('.wrapper').width()*wh)/2;
  9. $('.wrapper').css({'-webkit-transform':'scale('+wh+')','transform':'scale('+wh+')','margin-left':wleft});
  10. }
  11. $(window).on("load resize", function () {
  12. setTimeout(pInt(), 500);
  13. });
  14. $(window).on("load", function() {
  15. TouchSlide({
  16. slideCell:"#slider-scroll",
  17. titCell:".hd ul",
  18. autoPage:true,
  19. pnLoop:"false",
  20. switchLoad:"_src"
  21. });
  22. sexualitySelect();
  23. $('.gender-menu>ul>li>div').on('click',function(){
  24. var $el=$(this),
  25. index = $el.parent().index();
  26. $("#sex").val($(this).attr("sex"));
  27. $el.addClass('curr').parent().siblings().find('div').removeClass('curr');
  28. $('.human-box').eq(index).addClass('curr').siblings().removeClass('curr');
  29. onoffswitch(index,true);
  30. $('.sexuality-text').text($el.text());
  31. });
  32. $('.gender-switch-box').on('click',function(){
  33. var index=$('.gender-menu>ul>li>div.curr').parent().index();
  34. if($(this).is('.curr')){
  35. onoffswitch(index,true);
  36. }else{
  37. onoffswitch(index,false);
  38. }
  39. });
  40. humanList=new IScroll('.human-list',{'click':true});
  41. });
  42. $('.human-anchor').on('touchstart',function(){
  43. $(this).addClass('show');
  44. }).on('touchend',function(){
  45. $(this).removeClass('show');
  46. });
  47. function onoffswitch(index,b){
  48. if(b){
  49. $('.gender-switch-box').removeClass('curr');
  50. $('.human-box').eq(index).children('.human-elem').eq(0).addClass('curr').siblings().removeClass('curr');
  51. }else{
  52. $('.gender-switch-box').addClass('curr');
  53. $('.human-box').eq(index).children('.human-elem').eq(1).addClass('curr').siblings().removeClass('curr');
  54. }
  55. }
  56. function sexualitySelect(){
  57. var $text=$('.sexuality-text'),
  58. $box=$('.sexuality-box'),
  59. $div=$box.children('div'),
  60. $scroller=$('.human-list-scroller');
  61. $text.on('click',function(){
  62. $text.hide();
  63. $box.show();
  64. });
  65. $div.on('click',function(){
  66. var i=$(this).index();
  67. $text.show().text($(this).text());
  68. $("#sex").val($(this).attr("sex"));
  69. $('.human-box').eq(parseInt($(this).attr("sex")) - 1).addClass('curr').siblings().removeClass('curr');
  70. $('.gender-menu>ul>li>div').eq(parseInt($(this).attr("sex")) - 1).addClass('curr').parent().siblings().find('div').removeClass('curr');
  71. $box.hide();
  72. $scroller.eq(i).addClass('curr').siblings().removeClass('curr');
  73. humanList.refresh();
  74. });
  75. };
  76. })