common.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. $(function(){
  2. //自适应窗口
  3. document.documentElement.style.fontSize=24*( (document.documentElement.clientWidth)/360 )+"px";
  4. window.onorientationchange=function(){document.documentElement.style.fontSize=24*( (document.documentElement.clientWidth)/360 )+"px";}
  5. $(".appBar div:eq(1)").click(function () {
  6. $.cookie("new_app_guide_cookie","true",{expires:1,path:"/"});
  7. $(".fixBox.app").hide();
  8. });
  9. //条件点击选中
  10. $(".term span").click(function(){
  11. $(this).parent().find("span").removeClass("on");
  12. $(this).addClass("on")
  13. })
  14. //条件展开
  15. $(".searchRow div").click(function(){
  16. if($(this).parent().attr("class")=="searchRow ar"){
  17. $(this).parent().css({"height":"auto"});
  18. $(this).parent().removeClass("ar").addClass("br");
  19. }else{
  20. $(this).parent().css({"height":"1.82rem"});
  21. $(this).parent().removeClass("br").addClass("ar");
  22. }
  23. })
  24. //城市点击
  25. $("#cityList").click(function(){
  26. // window.location.href = "/city/cityList";
  27. shadeLayer()
  28. $(".popCity").css("display","block");
  29. })
  30. $(".cancelRow").click(function(){
  31. $(".popCity").css("display","none");
  32. $(".shadeLayer").remove();
  33. })
  34. //输入框
  35. $(".searchInput").focus(function(){
  36. if($(this).val()=="输入小区/地址" || $(this).val()=="输入内容"){
  37. $(this).val("")
  38. $(this).css("color","#000");
  39. }
  40. })
  41. //点击搜索
  42. // $(".searchBar input").click(function(){
  43. // if( $(".popSearch").css("display")=="none" ){
  44. //
  45. // $(".popSearch").css("display","block");
  46. // shadeLayer(this.name)
  47. // }
  48. //
  49. // })
  50. $(".popSearch").click(function(){
  51. $(".popBox").css("display","none")
  52. $(".shadeLayer").remove();
  53. if(!$(".searchInput").val()){
  54. $(".searchInput").val("输入小区/地址")
  55. $(".searchInput").css("color","#999");
  56. }
  57. })
  58. $(".popSearch li").click(function(event){
  59. $(".searchBar input").val($(this).text())
  60. $(".searchBar input").css("color","#000")
  61. //event.stopPropagation();
  62. //$(".popBox").css("display","none")
  63. // $(".shadeLayer").remove();
  64. })
  65. //输入框清除按钮
  66. // $(".deleteBtn").click(function(){
  67. // $(this).next().val("");
  68. // })
  69. //点击选中
  70. $(".term span").click(function(){
  71. $(this).parent().find("span").removeClass("on");
  72. $(this).addClass("on")
  73. })
  74. //分享弹层
  75. $(".share").click(function(){
  76. shadeLayer();
  77. $(".shares").css("display","block");
  78. $(".shareBox").removeClass("bdshare-button-style0-16");
  79. })
  80. $(".cancelRow").click(function(){
  81. $(".shadeLayer").remove();
  82. $(".popBox").css("display","none");
  83. })
  84. //详情页描述文字点击展开
  85. $(".description #expand").toggle(function(){
  86. $(".description #dBox").removeClass("cBox");
  87. $(".description #dBox").addClass("openBox");
  88. $(this).html("[收起]");
  89. $(this).animate({ scrollTop: 0 }, 300);
  90. }, function() {
  91. $(".description #dBox").removeClass("openBox");
  92. $(".description #dBox").addClass("cBox");
  93. $(this).html("[展开]");
  94. $(this).animate({ scrollTop: 0 }, 300);
  95. })
  96. //滚动图片
  97. if(document.body.className=="photo" || document.body.className=="sale"){
  98. var oUl=document.getElementById("photoUl");
  99. var aLi=oUl.getElementsByTagName("li");
  100. function photoMove(){
  101. $(".photoTab ul:eq(0)").animate({"left":-$(".photoTab ul:eq(0) li").width()*(photoIndex-1)},200);
  102. $(".photoDot p span").removeClass("on");
  103. $(".photoDot p span").eq(photoIndex-1).addClass("on");
  104. }
  105. var photoIndex=1;
  106. /*setInterval(function(){
  107. if(photoIndex<$(".photoTab ul:eq(0) li").length){ photoIndex++; }
  108. else{ photoIndex=1 }
  109. photoMove();
  110. },4000)*/
  111. oUl.ontouchstart=function(ev){
  112. var oldLeft=oUl.offsetLeft;
  113. var ev=ev||window.event;
  114. var disX=ev.changedTouches[0].clientX-oUl.offsetLeft;
  115. document.ontouchmove=function(ev){
  116. var ev=ev||window.event;
  117. oUl.style.left=ev.changedTouches[0].clientX-disX+"px";
  118. if(oUl.offsetLeft>0) oUl.style.left=0+"px";
  119. if(oUl.offsetLeft<-(aLi[0].offsetWidth*(aLi.length-1))) {
  120. oUl.style.left=-(aLi[0].offsetWidth*(aLi.length-1))+"px";
  121. }
  122. return false;
  123. }
  124. document.ontouchend=function(){
  125. var distance=oldLeft-oUl.offsetLeft
  126. if(distance>0){
  127. photoIndex++;
  128. photoMove();
  129. }else if(distance<0){
  130. photoIndex--;
  131. photoMove();
  132. }
  133. document.ontouchmove=null;
  134. document.ontouchend=null;
  135. }
  136. }
  137. }
  138. //返回顶部
  139. $(".gotoTop").click(function(){
  140. $('body,html').animate({ scrollTop: 0 }, 300)
  141. })
  142. $(window).scroll(function(){
  143. if($(window).scrollTop()>300){
  144. $(".gotoTop").css("display","block");
  145. }
  146. else if($(window).scrollTop()<300){
  147. $(".gotoTop").css("display","none");
  148. }
  149. })
  150. })
  151. //半透明弹层
  152. function shadeLayer(top){
  153. var oShade=$("<div>")
  154. if(!top) top=0;
  155. oShade.css({
  156. "width":"100%",
  157. "height":$(document.body).outerHeight(true),
  158. "position":"absolute",
  159. "top":top,
  160. "background":"rgba(0,0,0,0.3)",
  161. "z-index":"5"
  162. })
  163. oShade.attr("class","shadeLayer");
  164. oShade.click(function(){
  165. oShade.remove()
  166. $(".popBox").css("display","none");
  167. })
  168. $("body").append(oShade);
  169. }
  170. $(".popBox").click(function(even){
  171. event.stopPropagation();
  172. })