villalist.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. $(window).scroll(function (){
  2. var st = $(this).scrollTop();
  3. if(st >50){
  4. $('.y_header').hide();
  5. $('.y_homelist_head').addClass('wtop');
  6. }else{
  7. $('.y_header').show();
  8. $('.y_homelist_head').removeClass('wtop');
  9. }
  10. });
  11. // function Qalert(num = 0) {
  12. // var M = {};
  13. // if(M.dialog1){
  14. // return M.dialog1.show();
  15. // }
  16. // M.dialog1 = jqueryAlert({
  17. // 'content' : '已为您找到<span style="color:#FF6926;font-size: 1.0rem;"> '+count+' </span>套房源',
  18. // 'closeTime' : 4000,
  19. // })
  20. //
  21. // }
  22. function getParams(url) {
  23. var theRequest = new Object();
  24. if (!url)
  25. url = location.href;
  26. if (url.indexOf("?") !== -1)
  27. {
  28. var str = url.substr(url.indexOf("?") + 1) + "&";
  29. var strs = str.split("&");
  30. for (var i = 0; i < strs.length - 1; i++)
  31. {
  32. var key = strs[i].substring(0, strs[i].indexOf("="));
  33. var val = strs[i].substring(strs[i].indexOf("=") + 1);
  34. theRequest[key] = val;
  35. }
  36. }
  37. return theRequest;
  38. }
  39. var objUrl = {}; //获取get参数
  40. var url = window.location.href;
  41. var searchParams = ''; //最后拼接的参数
  42. var urlParams = '';
  43. // 页数
  44. var page = 0;
  45. // 每页展示5个
  46. var size = 10;
  47. var params = getParams(url); //获取get请求的参数
  48. if(!$.isEmptyObject(params)){
  49. $.each(params,function(key,val){
  50. if(key == 'city') feng_cityTel = val;
  51. objUrl[key] = val;
  52. urlParams += key+'='+val+'&';
  53. })
  54. urlParams = urlParams.substring(0,urlParams.length - 1);
  55. searchParams = '&'+ urlParams;
  56. }
  57. $('.y_qylist_cnet_ind').on('click','a.link_click',function () {
  58. var _this = $(this);
  59. if(_this.attr('name') == 'city' && _this.attr('value') != 0){
  60. _this.parent().parent().hide();
  61. }
  62. _this.parent().hide();
  63. var nameattr = $(this).attr('name');
  64. $('.feng_'+nameattr).children('span').html(_this.html());
  65. if( _this.attr('name') == 'price'){
  66. var subject = price_deal(_this.find('span').text());
  67. if(subject != 1){
  68. $('.feng_'+nameattr).children('span').html(subject);
  69. }else{
  70. $('.feng_'+nameattr).children('span').html(_this.html());
  71. }
  72. }
  73. if(_this.attr('name') == 'city'){
  74. objUrl['py'] = _this.attr('pinyin');
  75. }
  76. var ParamsArr = ['city','type','sort','price','py']; //搜索字段
  77. var atrName = _this.attr('name');
  78. var _val = _this.attr('value');
  79. var urlParams = '';
  80. for (var k in ParamsArr){
  81. if(ParamsArr[k] == atrName){
  82. objUrl[atrName] = _val;
  83. delete objUrl.page;
  84. delete objUrl.name;
  85. }
  86. }
  87. $.each(objUrl,function(key,val){
  88. if(key == 'py') return true; //跳出当前循环
  89. urlParams += key+'='+val+'&';
  90. })
  91. var cityUrl = '';
  92. urlParams = urlParams.substring(0,urlParams.length - 1);
  93. if(typeof objUrl.py == 'string'){
  94. cityUrl = 'py='+objUrl.py+'&';
  95. }
  96. if(urlParams == '' && cityUrl != '')
  97. {
  98. cityUrl = cityUrl.substring(0,cityUrl.length - 1);
  99. }
  100. window.location.href = '/villa/villalist?'+ cityUrl+urlParams;
  101. })
  102. $(function(){
  103. var onoff=true;
  104. $('.y_homelist_list').dropload({
  105. scrollArea : window,
  106. loadDownFn : function(me,da){
  107. page++;
  108. // 拼接HTML
  109. var result = '';
  110. $.ajax({
  111. type: 'GET',
  112. url: '/house/searchdata?page='+page+'&limit='+size+searchParams+'&hao=1',
  113. dataType: 'json',
  114. async:false,
  115. success: function(data){
  116. // if(data.count){
  117. // // Qalert(data.count);
  118. // }
  119. var data = data.data;
  120. // console.log(data);
  121. if(data != null){
  122. $.each(data,function (key,val) {
  123. var randomX = 300;
  124. var randomY = 800;
  125. var randvalue = parseInt(Math.random() * (randomX - randomY + 1) + randomY);
  126. // var dataID = (key+1)+(page-1)*size;
  127. result += '<li class="c">';
  128. // result += '<a href="javascript:void(0);">';
  129. // result += '<a href="/house/'+val.id+'">';
  130. result += '<div class="picture">';
  131. result += '<a href="/house/'+val.id+'">';
  132. result += '<div class="picture_price">';
  133. result += '<h2>'+val.name+'</h2>';
  134. result += '</div>';
  135. result += '<img src='+val.hao_img+' alt="">';
  136. result += '</a>';
  137. result += '</div>';
  138. result += '<div class="picture_font">';
  139. result += '<a href="/house/'+val.id+'">';
  140. result += '<div class="picture_name">';
  141. result += '<label>荐</label>';
  142. result += '<p>'+val.reason+'</p>';
  143. result += '</div>';
  144. result += '<div class="price-bx">';
  145. result += '<p class="picture_price_font">';
  146. result += '¥';
  147. result += '<span>'+val.sale_price+'</span>';
  148. result += '<label>'+val.price_unit+'</label>';
  149. result += '</p>';
  150. result += '<p class="valid">有效期:'+getNextMonth(time)+'</p>';
  151. result += '</div>';
  152. result += '<div class="heroism-box">';
  153. var reg = parseInt(val.jingmi) + parseInt(val.haoqi);
  154. var reg1 = reg/2;
  155. result += '<div class="minute"> '+reg1+'分</div>';
  156. result += '<div class="precision">静密值:<span>';
  157. result += starFn(val.jingmi);
  158. result += '</span></div>';
  159. result += '<div class="heroism">豪气值:<span>';
  160. result += starFn(val.haoqi);
  161. result += '</span></div>';
  162. result += '</div>';
  163. result += '<p class="site"><img src="/image/icn-map.png" alt="">'+val.address+'</p>';
  164. result += '</a>';
  165. result += '<div class="trademark">';
  166. result += '<div class="trademark-logo">';
  167. result += '<img src='+val.logo+' alt="">';
  168. result += '</div>';
  169. result += '<a class="trademark-btn popup" href="javascript:void(0);" data-name="获取优惠" data-text="我们将为您保密个人信息!专业团队,一对一服务,让你全程无忧看房!" data-id="'+val.id+'" data-module="46">获取优惠</a>';
  170. result += '</div>';
  171. result += '</div>';
  172. // result += '</a>';
  173. result += '</li>';
  174. if((key+1)%5 == 0){
  175. result += apply();
  176. }
  177. })
  178. // 如果没有数据
  179. }else{
  180. // 锁定
  181. me.lock();
  182. // 无数据
  183. me.noData();
  184. }
  185. // 为了测试,延迟1秒加载
  186. setTimeout(function(){
  187. // 插入数据到页面,放到最后面
  188. $('.y_homelist_list ul').append(result);
  189. // 每次数据插入,必须重置
  190. me.resetload();
  191. },100);
  192. },
  193. error: function(xhr, type){
  194. // alert('Ajax error!');
  195. // 即使加载出错,也得重置
  196. me.resetload();
  197. }
  198. });
  199. }
  200. });
  201. });
  202. $.each($('.m_nav_qy').find('a'),function(){
  203. var each_name = $(this).attr('name');
  204. var each_val = $(this).attr('value');
  205. if(each_val == objUrl[each_name]){
  206. $(this).attr('id','nav');
  207. }
  208. })
  209. //
  210. $(".y_qylist_cnet_ind").on('click','a.link-item',function(){
  211. var _this = $(this);
  212. _this.addClass('on');
  213. _this.siblings().removeClass('on');
  214. $('.three_area').show();
  215. $.post('/villa/soncity',{pid:_this.attr('value')},function(data){
  216. $(".three_area").html('');
  217. if(data.code == 200){
  218. var str = '';
  219. str += '<a class="link_click" name="city" pinyin="'+_this.attr('pinyin')+'" value="'+_this.attr('value')+'" href="javascript:;">'+_this.find('span').html()+'</a>';
  220. $.each(data.data,function (k,v) {
  221. str += '<a class="link_click" name="city" pinyin="'+v.pinyin+'" value="'+v.id+'" href="javascript:;"><span>'+v.city_name+'</span></a>';
  222. })
  223. }
  224. $(".three_area").append(str);
  225. })
  226. $(".three_area").animate({left:"35%"});
  227. })
  228. $(".y_qylist_cnet_ind").on('click','a.actived-item',function(){
  229. $(".three_area").animate({left:"100%"});
  230. })
  231. function waptab(name1,name2,name3){
  232. $(name1).on('click',function(){
  233. $(name2).hide();
  234. var Idoption = $(this).attr(name3);
  235. var that = $(this);
  236. if($(this).hasClass('on')){ //判断css on 是否存在
  237. that.parents('.y_qylist').find(name2+'['+name3+''+'='+ Idoption +']').hide();
  238. $(this).removeClass('on');
  239. }else{
  240. $(this).addClass('on').siblings().removeClass('on');
  241. that.parents('.y_qylist').find(name2+'['+name3+''+'='+ Idoption +']').show();
  242. }
  243. })
  244. }
  245. waptab('.y_qylist_hoe .y_qylist_con','.y_qylist_cnet_ind','data-id');
  246. // 有效期 时间加两个自然月
  247. function getNextMonth(date) {
  248. var arr = date.split('/');
  249. var year = arr[0]; //获取当前日期的年份
  250. var month = arr[1]; //获取当前日期的月份
  251. var day = arr[2]; //获取当前日期的日
  252. var days = new Date(year, month, 0);
  253. days = days.getDate(); //获取当前日期中的月的天数
  254. var year2 = year;
  255. var month2 = parseInt(month) + 2;
  256. if (month2 > 13) {
  257. year2 = parseInt(year2) + 1;
  258. if (parseInt(month)==11) {
  259. month2 = 1;
  260. }else if (parseInt(month)==12) {
  261. month2 = 2;
  262. };
  263. }
  264. var day2 = day;
  265. var days2 = new Date(year2, month2, 0);
  266. days2 = days2.getDate();
  267. if (day2 > days2) {
  268. day2 = days2;
  269. }
  270. if (month2 < 10) {
  271. month2 = '0' + month2;
  272. }
  273. var t2 = year2 + '/' + month2 + '/' + day2;
  274. return t2;
  275. }
  276. var myDate = new Date;
  277. var year = myDate.getFullYear(); //获取当前时间年份
  278. var yue = myDate.getMonth()+1;//获取当前时间月份
  279. if (yue<10) {
  280. yue= '0' + yue;
  281. };
  282. // 有效期时间 获取当前时间
  283. var time = year+'/'+yue+'/01';
  284. // 处理选中价格
  285. function price_deal(subject){
  286. switch(subject){
  287. case '8000-10000元':
  288. subject = '8千-1万';
  289. break;
  290. case '6000-8000元':
  291. subject = '6-8千';
  292. break;
  293. case '4000-6000元':
  294. subject = '4-6千';
  295. break;
  296. case '4000元以下':
  297. subject = '4千以下';
  298. break;
  299. default:
  300. subject = 1;
  301. break;
  302. }
  303. return subject;
  304. }
  305. // 处理跳转过来选中价格
  306. var textspan=$('.y_qylist_con').eq(1).find('p.feng_price span').text();
  307. $('.y_qylist_con p.feng_price span').html(price_deal2(textspan))
  308. function price_deal2(subject2){
  309. switch(subject2){
  310. case '8000-10000元':
  311. subject2 = '8千-1万';
  312. break;
  313. case '6000-8000元':
  314. subject2 = '6-8千';
  315. break;
  316. case '4000-6000元':
  317. subject2 = '4-6千';
  318. break;
  319. case '4000元以下':
  320. subject2 = '4千以下';
  321. break;
  322. }
  323. return subject2;
  324. }
  325. // 添加报名窗口
  326. function apply(){
  327. var _div ="";
  328. _div +='<div class="w_apply">';
  329. // _div +='<div class="w_fn">设置楼盘动态提醒,加推开盘早知道</div>'
  330. _div +='<div class="w_apply_img"><img src="/image/icon-wbg01.png" alt=""></div>';
  331. _div +='<form class="submit_area">';
  332. _div +='<input type="hidden" name="hid" value="0"> <!-- 0 为公共报名,其它为楼盘ID-->';
  333. _div +='<input type="hidden" name="source" value="47"> <!--报名来源 具体查看applyVerify.js文件中SourceModule 标识说明-->';
  334. _div +='<input type="hidden" name="equipment" value="1"> <!--来源设备 ( PC端 2,手机端 1 )-->';
  335. _div +='<div class="import">';
  336. _div +='<img src="/image/icon-wtel.png" alt="" />';
  337. _div +='<input class="w_apply_txt" type="text" name="mobile" placeholder="请输入您的手机号码">';
  338. _div +='</div>';
  339. _div +='<a class="apply_submit" href="javascript:;">报名看房</a>';
  340. _div +='</form>';
  341. _div +='</div>';
  342. return _div;
  343. }
  344. // 判断数字是否为整数
  345. function isInt(obj) {
  346. return obj%1 === 0
  347. }
  348. function starFn(oi){
  349. var _i = '';
  350. if(oi)
  351. // 判断输入的数字是否为整数
  352. if(isInt(oi)){
  353. // 判断输入的数字是否为5
  354. if(oi-5==0){
  355. for(var i = 0; i < oi;i++){
  356. _i +='<i></i>';
  357. }
  358. }else{
  359. // 添加有颜色的星
  360. for(var i = 0 ;i < oi;i++){
  361. _i += '<i></i>';
  362. }
  363. // 添加没有颜色的星
  364. for(var i = 0 ;i < 5-oi;i++){
  365. _i += '<i class="colourless"></i>';
  366. }
  367. }
  368. }else{
  369. // 添加有颜色的星
  370. for(var i = 1 ;i < oi;i++){
  371. _i += '<i></i>';
  372. }
  373. // 添加半颗星
  374. _i += '<i class="half"></i>';
  375. // 添加没有颜色的星
  376. for(var i = 1 ;i < 5-oi;i++){
  377. _i += '<i class="colourless"></i>';
  378. }
  379. }
  380. return _i;
  381. }