broadcast.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. //获取url中的参数
  2. function getUrlParam(name) {
  3. //构造一个含有目标参数的正则表达式对象
  4. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  5. //匹配目标参数
  6. var r = window.location.search.substr(1).match(reg);
  7. //alert(r);
  8. //返回参数值
  9. if (r != null) return decodeURI(r[2]);
  10. return null;
  11. }
  12. // 筛选 选中效果
  13. var _city = getUrlParam('city'); //价格
  14. if (_city) {
  15. var _index = $('.wrapper02 .scroller li[country="' + _city + '"]').index();
  16. }
  17. ;
  18. // console.log(_index);
  19. // //导航移动 demo示例六 通过id调取
  20. $('#demo06').navbarscroll({
  21. defaultSelect: _index, //默认选中
  22. scrollerWidth: 4,
  23. fingerClick: 1,
  24. endClickScroll: function (obj) {
  25. // console.log(obj.text())
  26. }
  27. });
  28. function getParams(url) {
  29. var theRequest = new Object();
  30. if (!url)
  31. url = location.href;
  32. if (url.indexOf("?") !== -1) {
  33. var str = url.substr(url.indexOf("?") + 1) + "&";
  34. var strs = str.split("&");
  35. for (var i = 0; i < strs.length - 1; i++) {
  36. var key = strs[i].substring(0, strs[i].indexOf("="));
  37. var val = strs[i].substring(strs[i].indexOf("=") + 1);
  38. theRequest[key] = val;
  39. }
  40. }
  41. return theRequest;
  42. }
  43. var objUrl = {}; //获取get参数
  44. var url = window.location.href;
  45. var searchParams = ''; //最后拼接的参数
  46. var urlParams = '';
  47. // 页数
  48. var page = 1;
  49. // 每页展示5个
  50. var size = 4;
  51. var params = getParams(url); //获取get请求的参数
  52. if (!$.isEmptyObject(params)) {
  53. $.each(params, function (key, val) {
  54. if (key == 'city') feng_cityTel = val;
  55. objUrl[key] = val;
  56. urlParams += key + '=' + val + '&';
  57. })
  58. urlParams = urlParams.substring(0, urlParams.length - 1);
  59. searchParams = '&' + urlParams;
  60. }
  61. var country = $('.m_click li').eq(0).attr('country');
  62. $('.m_click li').on('click', function () {
  63. var _this = $(this);
  64. country = $(this).attr('country');
  65. var ParamsArr = ['city']; //搜索字段
  66. var atrName = _this.attr('name');
  67. var _val = _this.attr('country');
  68. var urlParams = '';
  69. for (var k in ParamsArr) {
  70. if (ParamsArr[k] == atrName) {
  71. objUrl[atrName] = _val;
  72. delete objUrl.page;
  73. }
  74. }
  75. $.each(objUrl, function (key, val) {
  76. if (key == 'py') return true; //跳出当前循环
  77. urlParams += key + '=' + val + '&';
  78. })
  79. var cityUrl = '';
  80. urlParams = urlParams.substring(0, urlParams.length - 1);
  81. if (typeof objUrl.py == 'string') {
  82. cityUrl = 'py=' + objUrl.py + '&';
  83. }
  84. if (urlParams == '' && cityUrl != '') {
  85. cityUrl = cityUrl.substring(0, cityUrl.length - 1);
  86. }
  87. // console.log(urlParams);
  88. window.location.href = '?' + cityUrl + urlParams;
  89. })
  90. $(function () {
  91. $('.m_lplist_box').dropload({
  92. scrollArea: window,
  93. domDown: {
  94. domClass: 'dropload-down',
  95. domRefresh: '<div class="dropload-refresh">↑上拉加载更多</div>',
  96. domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
  97. domNoData: '<div class="dropload-noData">我也是有底线的...</div>'
  98. },
  99. loadDownFn: function (me, da) {
  100. page++;
  101. // 拼接HTML
  102. var requesturl = '';
  103. if (url.indexOf('city') > -1) {
  104. requesturl = 'live/home/getlive?page=' + page + '&limit=' + size + searchParams;
  105. } else {
  106. requesturl = 'live/home/getlive?page=' + page + '&limit=' + size + searchParams + '&city=' + country;
  107. }
  108. var result = '';
  109. $.ajax({
  110. type: 'GET',
  111. url: requesturl,
  112. dataType: 'json',
  113. async: false,
  114. success: function (data) {
  115. var data = data.data;
  116. // console.log(data);
  117. if (data != null) {
  118. $.each(data, function (key, val) {
  119. result += '<li class="c">';
  120. result += '<a href="/live/home/detail?id=' + val.id + '&city=' + val.swt + '">';
  121. result += '<div class="m_lplist_img">';
  122. result += '<p class="c">';
  123. switch (val.state) {
  124. case '直播中': //直播中
  125. result += '<i class="zb">·直播中</i>';
  126. break;
  127. case '预告': //预告
  128. result += '<i>预告</i>';
  129. result += '<span>' + val.time + '</span>';
  130. break;
  131. case '回放': //回放
  132. result += '<i class="hf">回放</i>';
  133. break;
  134. }
  135. result += '</p>';
  136. result += '<img src="' + val.img + '" alt="">';
  137. result += '</div>';
  138. result += '<div class="m_zx_listText">';
  139. result += '<em>' + val.title + '</em>';
  140. result += '<p class="c">';
  141. result += '<span class="dz"><img src="/modules/live/image/zb2.png" alt="">' + val.house.f.city_name + ' ' + val.city_name + ' </span>';
  142. // result+='<span class="sl"><img src="./image/zb3.png" alt="">浏览量: '+val.number+'</span>';
  143. result += '</p>';
  144. result += '</div>';
  145. result += '</a>';
  146. result += '</li>';
  147. })
  148. $('.m_lplist_box ul').append(result);
  149. // 如果没有数据
  150. } else {
  151. // 锁定
  152. me.lock();
  153. // 无数据
  154. me.noData();
  155. }
  156. me.resetload();
  157. // 为了测试,延迟1秒加载
  158. // setTimeout(function(){
  159. // // 插入数据到页面,放到最后面
  160. // $('.y_hotnews_list ul').append(result);
  161. // // 每次数据插入,必须重置
  162. // me.resetload();
  163. // },100);
  164. },
  165. error: function (xhr, type) {
  166. // alert('Ajax error!');
  167. // 即使加载出错,也得重置
  168. me.resetload();
  169. }
  170. });
  171. }
  172. });
  173. });