album.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. $(function(){
  2. $('#yii-debug-toolbar').hide();
  3. // 相册ajax
  4. function index_lp (){
  5. var html = '';
  6. $('.m_album_r_lsit').html('')
  7. $.ajax({
  8. url: "/house/albumlist",
  9. data:{hid:hid,album_id:album_id},
  10. type: "POST",
  11. dataType: "json",
  12. success: function(data) {//请求成功完成后要执行的方法
  13. if (data.code == 200) {
  14. $.each(data.data, function (i, data) {
  15. html+='<div class="m_lsitImg" data-style="'+data.album_id+'" data-index="'+i+'"><img src="'+data.img+'" alt=""></div>';
  16. });
  17. };
  18. $('.m_album_r_lsit').html(html);
  19. $('.m_album_r_lsit .m_lsitImg').on('click',function(){
  20. var _dataStyle = $(this).attr('data-style');
  21. var _dataIndex = $(this).attr('data-index');
  22. console.log(_dataStyle);
  23. console.log(_dataIndex);
  24. window.location='/house/pvimage/'+hid+'?album_id='+_dataStyle+'&mindex='+_dataIndex+'&hid='+hid+'';
  25. })
  26. }
  27. });
  28. }
  29. //获取url中的参数
  30. function getUrlParam(name){
  31. //构造一个含有目标参数的正则表达式对象
  32. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  33. //匹配目标参数
  34. var r = window.location.search.substr(1).match(reg);
  35. //alert(r);
  36. //返回参数值
  37. if (r!=null) return decodeURI(r[2]);
  38. return null;
  39. }
  40. var hid = $('.m_album_l_title span').eq(0).attr('hid');
  41. var album_id = '';
  42. // URL接受参数
  43. var _albumid = getUrlParam('album_id'); //类型
  44. if(_albumid){ //是否从放大页,进入页面
  45. album_id = _albumid
  46. $('.m_album_l_title span[value="'+_albumid+'"]').attr('class','on');
  47. }else{
  48. album_id = $('.m_album_l_title span').eq(0).attr('value');
  49. $('.m_album_l_title span').eq(0).attr('class','on');
  50. }
  51. index_lp();
  52. $('.m_album_l_title span').on('click',function(){
  53. hid = $(this).attr('hid');
  54. album_id = $(this).attr('value');
  55. $(this).attr('class','on').siblings().attr('class','')
  56. index_lp();
  57. })
  58. var height =$(window).height() -155;
  59. $('.m_album_box').height(height);
  60. })
  61. var _dataid = $('.m_hq li.cur').attr('dataid');
  62. //demo示例六 通过id调取 底部菜单插件
  63. $('#mdemo06').navbarscroll({
  64. defaultSelect:_dataid,
  65. scrollerWidth:6,
  66. fingerClick:1,
  67. endClickScroll:function(obj){
  68. // console.log(obj.text())
  69. }
  70. });