public.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. // 导航切换语言
  2. $(function(){
  3. // 导航切换语言 显示 隐藏
  4. function navMouseleave (id,id1){
  5. $(id).on({
  6. mouseover: function() {
  7. $(id1).show();
  8. },
  9. mouseleave: function() {
  10. $(id1).hide();
  11. }
  12. });
  13. }
  14. navMouseleave('.area','.area .option');//导航区域显示 隐藏
  15. // 底部报名 关闭按钮
  16. $('.ocls').on('click',function(){
  17. $('.order-box').animate({width:"0"},function(){
  18. $('.order-box').hide();
  19. $('.min-left').show();
  20. })
  21. })
  22. // 显示报名 窗口
  23. $('.min-left').on('click',function(){
  24. $('.order-box').show(function(){
  25. $('.min-left').hide();
  26. $('.order-box').animate({width:"100%"},function(){})
  27. })
  28. })
  29. // 首页、列表页、楼盘首页底部公共报名
  30. /*
  31. * 调用的方法
  32. * */
  33. PublicAction.AjaxSend(
  34. {
  35. CORID:'wa_submit', /*操作ID*/
  36. }
  37. );
  38. })
  39. // 处理资讯详情页面的底部一个月的有效日期
  40. var myDate = new Date;
  41. var year = myDate.getFullYear(); //获取当前时间年份
  42. var yue = myDate.getMonth()+1;//获取当前时间月份
  43. if (yue<10) {
  44. yue= '0' + yue;
  45. }else if(yue == 13){
  46. yue = '01';
  47. };
  48. // 返回下个月有多少天数
  49. function mGetDate(yue){     
  50. var date = new Date();     
  51. var year = date.getFullYear();     
  52. var d = new Date(year,parseInt(yue), 0);
  53. return d.getDate();
  54. }
  55. var whtmltimes = year + '/'+ yue + '/' + mGetDate(yue);
  56. var whtmltime = year + '/'+ yue + '/' +'01'+'-'+ year + '/'+ yue + '/' + mGetDate(yue);
  57. var time_yxq= whtmltime;
  58. $('.youxiaoqi_sj').html('(有效期:'+time_yxq+')');
  59. //底部横幅关闭
  60. $('.m_tc_gb').on('click',function(){
  61. $('.m_tc_box').hide();
  62. })
  63. // 广告自动修改时间
  64. function getNextMonth_m(date) {
  65. var arr = date.split('/');
  66. var year = arr[0]; //获取当前日期的年份
  67. var month = arr[1]; //获取当前日期的月份
  68. var day = arr[2]; //获取当前日期的日
  69. var days = new Date(year, month, 0);
  70. days = days.getDate(); //获取当前日期中的月的天数
  71. var year2 = year;
  72. var month2 = parseInt(month);
  73. if (parseInt(day) > 20) {
  74. var month2 = parseInt(month) + 1;
  75. if (month2 > 12) {
  76. year2 = parseInt(year2) + 1;
  77. month2 = 1;
  78. }
  79. };
  80. if (month2 < 10) {
  81. month2 = '0' + month2;
  82. }
  83. var t2 = year2 + '年' + month2 + '月';
  84. return t2;
  85. }
  86. var myDate = new Date;
  87. var year = myDate.getFullYear(); //获取当前时间年份
  88. var yue = myDate.getMonth()+1;//获取当前时间月份
  89. var date=myDate.getDate(); //获取当前日
  90. if (yue<10) {
  91. yue= '0' + yue;
  92. };
  93. // 有效期时间 获取当前时间
  94. var time = year+'/'+yue+'/'+date;
  95. $('.shijian_text').html(getNextMonth_m(time)+'20日启程')
  96. // 底部JS
  97. $('.m_FriendshipLinks a').eq(0).attr('class','on');
  98. var _default = $('.m_FriendshipLinks a').eq(0).attr('qhid');
  99. $('.m_regionfc[qhid="'+_default+'"]').show();
  100. $('.m_FriendshipLinks a').on('mousemove',function(){
  101. var _qhid = $(this).attr('qhid');
  102. $('.m_regionfc').hide();
  103. $('.m_regionfc[qhid="'+_qhid+'"]').show();
  104. $(this).attr('class','on').siblings().attr('class','');
  105. })
  106. var data_id = $('.gzhclick').attr('data-id');
  107. // console.log(data_id)
  108. // 处理当没有获取到ID时,不执行以下请求;
  109. if(data_id != undefined && data_id != '' && data_id != 'undefined'){
  110. var html = '';
  111. var tophtml = '';
  112. var toplist = '';
  113. $.ajax({
  114. url: "/index/getgzh", // 索取
  115. data:{id:data_id}, //传ID
  116. type: "GET",
  117. dataType: "json",
  118. success: function(data) {//请求成功完成后要执行的方法
  119. if(data.code == 200){
  120. // console.log(data);
  121. html+= '<ul class="m_gzhlist c">';
  122. html+= '<img class="m_tb" src="/image/v2/index33.png" alt="">';
  123. $.each(data.data, function (i, data) {
  124. html+= '<li>';
  125. html+= '<img src="'+data.icon+'" alt="">';
  126. html+= '<p>'+data.name+'</p>';
  127. html+= '</li>';
  128. var text_tit=data.name.split('公众号');
  129. toplist+='<a href="javascript:;" data-id="'+i+'">'+text_tit[0]+'</a>';
  130. tophtml+='<div class="right_imgUl" data-id="'+i+'">';
  131. tophtml+='<div class="right_imgUl_m">';
  132. tophtml+='<i class="sj"></i>';
  133. tophtml+='<p class="top_img"><img src="'+data.icon+'" alt=""></p>';
  134. tophtml+='<p class="title">'+data.name+'</p>';
  135. tophtml+='</div>';
  136. tophtml+='</div>';
  137. });
  138. }
  139. $('.m_HeadGzh_box_a').html(toplist);
  140. $('.m_HeadGzh_box_right').html(tophtml);
  141. $('.m_gzhlist_box').html(html);
  142. // 首页头部 公众号选项卡切换
  143. $('body .m_HeadGzh_box_a a').eq(0).addClass('on');
  144. $('body .right_imgUl').eq(0).show();
  145. $('body').on('mouseover','.m_HeadGzh_box_a a',function(){
  146. $('body .right_imgUl').hide();
  147. var Idoption = $(this).attr('data-id');
  148. $('body .right_imgUl[data-id='+ Idoption +']').show();
  149. $(this).addClass('on').siblings().removeClass('on');
  150. })
  151. }
  152. });
  153. }
  154. $('.m_regionfc a').on('mousemove',function(){
  155. $('.m_gzhlist_box').hide();
  156. })
  157. $('.gzhclick').on('mousemove',function(){
  158. $('.m_gzhlist_box').show();
  159. })
  160. $('.m_regionfc').on('mouseleave',function(){
  161. $('.m_gzhlist_box').hide();
  162. })
  163. // 导航
  164. $('.wm_Navigation ul li').on('mousemove',function(){
  165. $('.wm_Navigation_list').hide();
  166. })
  167. $('.wm_Navigation ul .Navigation_click').on('mousemove',function(){
  168. $(this).find('.wm_Navigation_list').show();
  169. })
  170. $('.wm_Navigation').on('mouseleave',function(){
  171. $('.wm_Navigation_list').hide();
  172. })
  173. // 楼盘首页报名 --最新价格 ---变动通知
  174. //创建一个弹出层,width 宽度,height 高度,url
  175. function CreatePopLayerDiv(width,height,url){
  176. var Iheight=$(window).height();
  177. var Iwidth =$(window).width();
  178. var heights = height || 300;
  179. var widths = width || 500;
  180. var Oheight= (Iheight -heights) / 2;
  181. var Owidth = (Iwidth - widths) /2;
  182. var div ='<div id="InDiv" style="width:'+Iwidth+'px;height:'+Iheight+'px;background:rgba(0,0,0,0.6);position:fixed;z-index:1000;top:0;left:0;">';
  183. div+='<div id="offDiv" style="width:'+widths+'px;height:'+heights+'px;left:'+Owidth+'px;position:fixed;z-index:32;border-radius:5px;">';
  184. div+='<a id="AClose" class="y_close" href="javascript:;" onclick="btnCloses()"><img src="/image/ico_close1.png" alt="" /></a>';
  185. div+='<div id="Content"></div>';
  186. div+='</div>';
  187. div+='</div>';
  188. $(document.body).append(div);
  189. if(url != ""){
  190. $("#Content").load(url);
  191. }
  192. }
  193. //移除弹出层
  194. function RemoveDiv(){
  195. $("#AClose").remove();
  196. $("#HTitle").remove();
  197. $("#offDiv").remove();
  198. $("#InDiv").remove();
  199. }
  200. function btnCloses(){
  201. RemoveDiv();
  202. }
  203. $(function(){
  204. // //降价通知
  205. var w_type,w_id,w_title,w_tel,w_module,w_text,w_button; //为了这些变量在其它地方用;
  206. $('body').on('click','.applekf-id,.pic_jjtz',function(){
  207. var $that = $(this);
  208. CreatePopLayerDiv(440,510,"/public/reduced"); //添加加载页面
  209. $('#offDiv').css({'margin-top':'-300px'}).animate({top:'50%'},500);
  210. parent.w_type = $that.attr('data-type'); //把报名窗口 类型传向父级
  211. parent.w_id = $that.attr('data-id'); //把楼盘ID传向父级
  212. parent.w_text = $that.attr('data-text'); //把报名 text文本传向父级
  213. parent.w_module = $that.attr('data-module'); //来源模块ID
  214. parent.w_title = $that.attr('data-name'); //报名标题
  215. parent.w_tel = $that.attr('data-tel'); //楼盘电话
  216. parent.w_button = $that.attr('data-button'); //提交按钮文案
  217. });
  218. $('#InDiv').on('click',function(){
  219. btnCloses();
  220. })
  221. //报名验证提交的调用
  222. PublicAction.AjaxSend({CORID:'v2inform_buttom'/*操作ID*/});
  223. })
  224. /*---------------------------------------COOKIE方法 end-----------------------------------------*/
  225. // 封装一个COOKIE方法
  226. var cookie = {
  227. //设置cookie方法
  228. set:function(key,val,time){
  229. var date=new Date(); //获取当前时间
  230. var expiresDays=time; //将date设置为n天以后的时间
  231. date.setTime(date.getTime()+expiresDays*24*3600*1000); //格式化为cookie识别的时间
  232. document.cookie=key + "=" + val +";expires="+date.toGMTString(); //设置cookie
  233. },
  234. //获取cookie方法
  235. get:function(key){
  236. /*获取cookie参数*/
  237. var getCookie = document.cookie.replace(/[ ]/g,""); //获取cookie,并且将获得的cookie格式化,去掉空格字符
  238. var arrCookie = getCookie.split(";") //将获得的cookie以"分号"为标识 将cookie保存到arrCookie的数组中
  239. var tips; //声明变量tips
  240. for(var i=0;i<arrCookie.length;i++){ //使用for循环查找cookie中的tips变量
  241. var arr=arrCookie[i].split("="); //将单条cookie用"等号"为标识,将单条cookie保存为arr数组
  242. if(key==arr[0]){ //匹配变量名称,其中arr[0]是指的cookie名称,如果该条变量为tips则执行判断语句中的赋值操作
  243. tips=arr[1]; //将cookie的值赋给变量tips
  244. break; //终止for循环遍历
  245. }
  246. }
  247. return tips;
  248. },
  249. //删除cookie方法
  250. delete:function(key){
  251. var date = new Date(); //获取当前时间
  252. date.setTime(date.getTime()-10000); //将date设置为过去的时间
  253. document.cookie = key + "=v; expires =" +date.toGMTString();//设置cookie
  254. }
  255. }
  256. // 调用方法
  257. // cookie.set("www","54165165",24);//设置为24天过期
  258. // console.log(cookie.get("www"));//获取cookie
  259. /*---------------------------------------COOKIE方法 end-----------------------------------------*/