/*
* @Author: zhaobo
* @Date:   2021-03-01 10:19:11
* @Last Modified by:   name
* @Last Modified time: 2021-09-28 11:52:08
*/

//   关注
    $('body').on('click','.photoAlbum-attention',function(e){
        if(CONFIG['isLogin'] == 0){
            env.login();
            return false;
        };
        var attention = $(this).attr('data-attention');
        if(attention == 0){
            // 关注
            $.post('/photographer/createFriendShip',{follow_uid : $('.photoAlbum-banner img').attr('data-id')},function(res){
                console.log(res);
                if(res.state){
                    $('.photoAlbum-attention').html('取消关注').attr('data-attention',1);
                    $('body').toast('关注成功');
                }else{
                    $('body').toast(res.message);
                }
            });
        }else{
            // 取消关注
            $.post('/photographer/destroyFriendShip',{follow_uid : $('.photoAlbum-banner img').attr('data-id')},function(res){
                console.log(res);
                if(res.state){
                    $('.photoAlbum-attention').html('关&nbsp;&nbsp;注').attr('data-attention',0);
                    $('body').toast('取消关注成功');
                }else{
                    $('body').toast(res.message);
                }
            })
        }
    });

      // 换背景弹窗显示
    $('body').on('click','.photoAlbum-bannerbtn',function(e){
      $('.winpopbg,.ChangeBackground-pop').fadeIn(300);
    });
    // 换背景弹窗隐藏
    $('body').on('click','.ChangeBackground-pop .icon-guanbi,.ChangeBackground-pop .ChangeBackground-cancel',function(e){
      $('.winpopbg,.ChangeBackground-pop').fadeOut(300);
    });
    // 替换背景
    var isAjax = true;
    $('body').on('click','.ChangeBackground-pop .ChangeBackground-confirm',function(e){
      if(!isAjax)return;
      isAjax = false;
      var pid = $.trim($('.ChangeBackground-text').val());
      if(!pid.length){
        $('.ChangeBackground-err').text('ID不能为空').show();
        $('.ChangeBackground-text').addClass('err');
        isAjax = true;
        return;
      };
      $.get('/api/subject/ajax_change_bg',{pid:pid},function(res){
        if(res.state){
          $('.photoAlbum-banner').css('background-image','url('+ res.data.big_preview_src +')');
          $('.ChangeBackground-text').val('');
          $('.winpopbg,.ChangeBackground-pop').fadeOut(300);
        }else{
          $('.ChangeBackground-err').text(res.message).show();
          $('.ChangeBackground-text').addClass('err');
        }
        isAjax = true;
      });
    });
    $('body').on('focus','.ChangeBackground-pop .ChangeBackground-text',function(e){
      $('.ChangeBackground-text').removeClass('err');
      $('.ChangeBackground-err').hide();
    });

    $('body').on('click','.photoAlbum-navtab a',function(e){
      $(".photoAlbum-navtab-box a").removeClass('on');
      $(this).addClass('on');
      // $('.photoAlbum-searchText').val('');
      var kw= $.trim($('.photoAlbum-searchText').val());
      currentPage = 1;
      var pic=$(this).attr('data-pic');
      var videoType = $(this).attr('data-video') ? $(this).attr('data-video') : '';
      var setNewQuery = (videoType ? "?picType=" + pic + "&video_c1=" + videoType : "?picType="+pic) + window.location.hash;
      window.history.replaceState(null, null, setNewQuery);
      if($(this).hasClass("photoAlbum-navtab-alltype")) {
        renderNavFun()
      }
      updateList($(this).attr('data-sort'), pic, kw, videoType);
    });
    renderNavFun()
    function renderNavFun() {
        var getQueryPicType = getQueryString('picType');
        $(".photoAlbum-navtab-box .photoAlbum-navtab-sub").hide();
        getQueryPicType == 100 ? $(".photoAlbum-navtab-video .photoAlbum-navtab-sub").show() : $(".photoAlbum-navtab-img .photoAlbum-navtab-sub").show();
    }
    // 排序切换
    $('body').on('click','.photoAlbum-filtrate a',function(e){
      var kw= $.trim($('.photoAlbum-searchText').val());
      var videoType = $('.photoAlbum-navtab a.on').attr('data-video') ? $('.photoAlbum-navtab a.on').attr('data-video') : '';
      if($(this).hasClass('on'))return;
      $(this).addClass('on').siblings().removeClass('on');
      currentPage = 1;
      updateList($(this).attr('data-sort'), $('.photoAlbum-navtab a.on').attr('data-pic'), kw, videoType);
    });

    $('body').on('keyup','.photoAlbum-search',function(e){
    // 兼容FF和IE和Opera
    var theEvent = window.event || e;
    var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
      if (code == 13) {
          $('.photoAlbum-searchBtn').trigger('click');
      };
    });
    var issou = false;
    $('body').on('click','.photoAlbum-searchBtn',function(e){
      var kw= $.trim($('.photoAlbum-searchText').val());
      var pic = $('.photoAlbum-navtab a.on').attr('data-pic');
      var videoType = $('.photoAlbum-navtab a.on').attr('data-video') ? $('.photoAlbum-navtab a.on').attr('data-video') : '';
      issou=true;
      currentPage = 1;
      updateList($('.photoAlbum-filtrate a.on').attr('data-sort'), pic, kw, videoType);
    });
// 请求数据
  var currentPage = 1;
  var pageNavObj = null;//用于储存分页对象
  function updateList(sort,pic,kw,video_type){
    if(!isAjax)return;
    isAjax = false;
    $('.Works-imgList').addClass('Loading').html('');
    $('.photoAlbum-kong').hide();
  $.get('/api/subject/ajax_works',{
        uid:$('.photoAlbum-banner img').attr('data-id'),
        pic_type:pic||0 ,
        sort:sort,
        page:currentPage,
        kw:kw||'',
        video_c1: video_type
      },function(res){
        if(res.status == 1){
          if(!res.data.list.length){
            $('.Works-imgList').removeClass('Loading');
            $('.searchQuantity').text('共0结果');
            if(issou){
                $('.photoAlbum-kong p').html('抱歉，在该设计师下没有搜到您想要的内容，建议您<a class="stationSearch color" data-souci="'+ kw +'">全站搜索>></a>')
            };
            $('.photoAlbum-kong').show();
            $('#PageNavId').hide();
            isAjax = true;
            return;
          };
          // es最大限制40000，图片每页显示100个，最大400页，视频每页显示60个，最大667页
          if(pic == 100) {
            res.page.p_max > 667 ? res.page.p_max = 667 : '';
          } else {
            res.page.p_max > 400 ? res.page.p_max = 400 : '';
          }
          
          pageNavObj = new PageNavCreate("PageNavId",{ pageCount:res.page.p_max, currentPage:res.page.p_num, perPageNum:5});
          pageNavObj.afterClick(pageNavCallBack);
          function pageNavCallBack(clickPage){
            if(clickPage > res.page.p_max){
                clickPage = res.page.p_max;
            }
            currentPage=clickPage;
            updateList(sort,pic,kw,video_type);
            $('body,html').scrollTop(520);
            pageNavObj = new PageNavCreate("PageNavId",{ pageCount:res.page.p_max, currentPage:clickPage, perPageNum:5});
            pageNavObj.afterClick(pageNavCallBack);
        }
        $('#PageNavId').show();

          $('.Works-imgList').removeClass('Loading');
          if(pic == 100){
            $('.Works-imgList').addClass('video');
            RenderViewVideo(res.data.list);
          }else{
            $('.Works-imgList').removeClass('video');
            RenderView(res.data.list,pic);
          };
          $('.searchQuantity').text('共'+ res.page.p_total +'结果');

        }else{
            $('.Works-imgList').removeClass('Loading');
            $('.searchQuantity').text('共0结果');
            $('.photoAlbum-kong p').html('抱歉，'+res.message)
            $('.photoAlbum-kong').show();
            $('#PageNavId').hide();
            isAjax = true;
            $('body').toast(res.message);
            return;
        };
        isAjax = true;

      });
    };
    $('body').on('click','.stationSearch',function(){
      $('#search-input').val($(this).attr('data-souci'));
      $('.fast-link_item[data-type="all"]').trigger('click');
      $('.header-search .header-search_btn').trigger('click');
    });
    // 图片渲染
  function RenderView(msg,pic){
    var dom = '',
        fixedWidth = '',
        isfixd = false;
    if(pic == 6){
        isfixd = true;
        $('.Works-imgList').addClass('fixedWidth');
    }else{
        $('.Works-imgList').removeClass('fixedWidth');
    }
    $.each(msg,function(i,v){
        var type = '',
            typeIcon = '',
            fixedWidth='',
            yuansu = '';
        switch (v.pic_type) {
            case 1:
            type = '照片';
            typeIcon = '<i class="iconfont icon-huiyuan-tupian"></i> ';
            break;
            case 2:
            type = '背景';
            typeIcon = '<i class="iconfont icon-huiyuan-hecheng"></i> ';
            break;
            case 3:
            type = '插画';
            typeIcon = '<i class="iconfont icon-huiyuan-chahua"></i> ';
            break;
            case 4:
            type = '模板';
            typeIcon = '<i class="iconfont icon-huiyuan-moban"></i> ';
            if(isfixd){
                if(v.cate.indexOf("907") != -1){
                    fixedWidth = '!/fw/336/clip/0x451a0a0';
                }else{
                    fixedWidth = '!/fw/651/clip/336x453a152a0';
                };
            }else{
                fixedWidth = '!/fw/431/clip/0x300a0a0';
                v.width = 431;
                v.height = 300;
            }

            break;
            case 5:
            type = '办公';
            typeIcon = '<i class="iconfont icon-huiyuan-bangong"></i> ';
            fixedWidth = '!/fw/347/clip/347x298a0a0/quality/90';
                v.width = 347;
                v.height = 298;
            break;
            case 6:
            type = '模板';
            typeIcon = '<i class="iconfont icon-huiyuan-moban"></i> ';
            if(isfixd){
                if(v.cate.indexOf("907") != -1){
                    fixedWidth = '!/fw/336/clip/0x451a0a0';
                }else{
                    fixedWidth = '!/fw/651/clip/336x453a152a0';
                };
            }else{
                fixedWidth = '!/fw/431/clip/0x300a0a0';
                v.width = 431;
                v.height = 300;
            }
            break;
            case 7:
            type = '元素';
            typeIcon = '<i class="iconfont icon-huiyuan-yuansu"></i> ';
            yuansu = 'yuansu'
            break;
            case 9:
            type = 'GIF';
            typeIcon = '<i class="iconfont icon-Shapex"></i> ';
          case 11: 
            type = '图标'
            typeIcon = '<i class="sticon sti-tubiaoX1S"></i> '
            break;
        }
        // 下载btn
        var dlBtnEl = '';
        if(v.sub_data && v.sub_data.indexOf(49) == -1) {
            dlBtnEl = '<a class="downimg fr ' + (v.pic_type == 11 ? 'icon-download' : 'imgDownGeetest') +'" rel="nofollow" href="javascript:void(0);" data-oldphotoid="'+ v.old_photo_id +'" data-searchid="'+ msg.kwId +'" data-page="'+ msg.page +'" data-url="'+ v.thumbnail_preview_src +'" data-title="'+ v.display_title +'" >立即下载</a>';
        }
        //判断gif
        if(v.pic_type == 9){
            dom +='<div class="list" data-w="'+ v.width +'" data-h="'+ v.height +'" data-id="'+ v.old_photo_id +'" data-thumburl= "'+ v.thumbnail_preview_src +'" data-objurl="'+ v.thumbnail_preview_src_2 +'">' +
                    '<a href="//699pic.com/'+ ( v.source_id == 2 ? 'tupianplus' : 'tupian') +'-'+ v.old_photo_id +'.html" target="_blank" title="'+ v.display_title +'">' +
                        '<img alt="'+ v.display_title + type +'素材" title="'+ v.display_title + type +'下载" class="lazy" src="//static.699pic.com/images/blank.png" data-original="'+ v.thumbnail_preview_src +'" width="450" height="300" />' +
                    '</a>' +
                    '<span class="gifHint">GIF</span>';
        } else if (v.pic_type == 11) { // 图标
          if (env.isLogin) {
            var href = _userInfo && _userInfo.enterprise_id && _userInfo.qiye_vip ? '//co.699pic.com/detail/icon/' + v.old_photo_id : '/front/icon-' + v.old_photo_id;
            dom +='<div class="list '+ yuansu +'" data-w="'+ v.width +'" data-h="'+ v.height +'" data-id="'+ v.old_photo_id +'" >' +
                      '<a href="'+ href +'" target="_blank" title="'+ v.display_title +'">' +
                          '<img style="background: #fff;" alt="'+ v.display_title + type +'素材" title="'+ v.display_title + type +'下载" class="lazy" src="//static.699pic.com/images/blank.png" data-original="//img95.699pic.com'+ v.thumbnail_preview_src +'" width="450" height="300" />' +
                      '</a>';
          } else {
            dom +='<div class="list '+ yuansu +'" data-w="'+ v.width +'" data-h="'+ v.height +'" data-id="'+ v.old_photo_id +'" >' +
                      '<a href="javascript:void(0)" onclick="env.login();" title="'+ v.display_title +'">' +
                          '<img style="background: #fff;" alt="'+ v.display_title + type +'素材" title="'+ v.display_title + type +'下载" class="lazy" src="//static.699pic.com/images/blank.png" data-original="//img95.699pic.com'+ v.thumbnail_preview_src +'" width="450" height="300" />' +
                      '</a>';
          }
        } else{
            dom +='<div class="list '+ yuansu +'" data-w="'+ v.width +'" data-h="'+ v.height +'" data-id="'+ v.old_photo_id +'" >' +
                    '<a href="//699pic.com/'+ ( v.source_id == 2 ? 'tupianplus' : 'tupian') +'-'+ v.old_photo_id +'.html" target="_blank" title="'+ v.display_title +'">' +
                        '<img alt="'+ v.display_title + type +'素材" title="'+ v.display_title + type +'下载" class="lazy" src="//static.699pic.com/images/blank.png" data-original="'+ v.thumbnail_preview_src +'" width="450" height="300" />' +
                    '</a>';
        };
        if(v.sub_data && v.sub_data.indexOf('16')!= -1 && v.sub_data.indexOf(49) == -1){
            dom +='<div class="qiye-exclusiveTips" style="position: absolute;top: -4px;left: 8px;width: 47px;height: 49px;box-sizing: border-box;padding-top: 5px;background: url(//static.699pic.com/images/search/qiye-exclusiveTips.png) no-repeat -3px 0;font-size: 12px;color: #FFFFFF;text-align: center;line-height: 14px;">企业<br>专享</div>'
        };
                if(v.copyright){
                    dom +='<div class="certificate" data-pid="'+ v.old_photo_id +'" copyright="'+ v.copyright +'"><i class="iconfont"></i>' +
                            '<div class="certificate-icontip">版权商用</div>' +
                        '</div>';
                }
                dom +='<div class="popup">' + dlBtnEl;
                dom +=
                  (v.pic_type != 11 ? ('<a rel="nofollow fr" class="collect-one shoucang' + (v.is_collect_status == 2 ? 'yet' : '') + '" data-pid="' + v.old_photo_id + '"><i class="iconfont icon-liebiaoxiangqing-shoucangshu"></i></a>') : '') +
                (v.pic_type == 11 ? (env.isLogin ? ('<a href="'+ (_userInfo && _userInfo.enterprise_id && _userInfo.qiye_vip ? '//co.699pic.com/detail/icon/' + v.old_photo_id : '/front/icon-' + v.old_photo_id) +'" target="_blank" class="icon-edit" ><i class="sticon sti-bianjiX2S"></i></a>') : '<a href="javascript:void(0)" onclick="env.login();" class="icon-edit" ><i class="sticon sti-bianjiX2S"></i></a>' ) : '') +
                '</div>' +
                '<div class="photo-tag">' +
                    '<h2 style="margin-left:12px;">' +
                        '<span>' +
                            typeIcon + type +'  |' +
                        '</span>' +
                        '<a href="//699pic.com/' + (v.source_id == 2 ? 'tupianplus' : 'tupian') + '-' + v.old_photo_id + '.html" target="_blank">' + v.display_title + '</a>' +
                    '</h2>' +
                '</div>' +
            '</div>';
    });
    $('.photoAlbum-kong').hide();
    if(isfixd){
        $('.Works-imgList').html(dom);
    }else{
        $('.Works-imgList').html(dom).flexImages({'rowHeight':300,'container':'.list','truncate':false });
    }
    $('.Works-imgList img.lazy').lazyload({threshold :350});
     //下一页
       var wrapperWidth = $('.Works-imgList').width(),
              oLastOneL = $('.Works-imgList .list:last').length > 0 && $('.Works-imgList .list:last').get(0).offsetLeft,
              oLastOneW = $('.Works-imgList .list:last').outerWidth();
          if( oLastOneL + oLastOneW + 12 == wrapperWidth ) {
              // 填满了
          } else {
              if(!$('.pageNum:last').hasClass('active'))
              {
                  var lastNavItemW = wrapperWidth - oLastOneL - oLastOneW-4,
                      lastNavItemH = $('.Works-imgList .list:last').outerHeight();
                  if(lastNavItemW > 160) {
                      $('<div class="lastNavItem list" data-w="'+(lastNavItemW-8)+'" data-h="'+lastNavItemH+'" ><div class="lastNavItem-pos"><span class="iconfont icon-jiantou-you-quan"></span><p>下一页<br />更多精彩</p></div></div>').insertAfter('.Works-imgList .list:last').click(function(){
                          $('.page-nav-next').trigger('click');
                      });
                  }
                  $('.Works-imgList').flexImages({'rowHeight':300,'container':'.list','truncate':true });
              }
          }
};
/* ========================= 绑定事件 =========================*/
     // gif图片切换
     $('body').on('mouseover','[data-thumburl]',function(){
        $(this).find('img').attr('src',$(this).attr('data-objurl'));
        $(this).find('.gifHint').hide();
    })
    $('body').on('mouseout','[data-thumburl]',function(){
        $(this).find('img').attr('src',$(this).attr('data-thumburl'));
        $(this).find('.gifHint').show();
    })
    // 竖图处理
    $('body').on('mouseover','.Works-imgList .list',function (){
        var oA  = null;
        var pid = null;
        if($(this).width() <= '200' && $(this).find("a.downimg").attr('is-handle') == void 0) {
            oA  = $(this).find("a.downimg");
            pid = oA.siblings('a.collect-one').attr('data-pid');
            oA.css("width",'43px');
            oA.empty();
            oA.append("<i></i>");
            oA.attr('is-handle',1);
        }
    });

/* 视频渲染 */
function RenderViewVideo(msg){
    var dom = '',video_rate = '',fileType = 0;
    $.each(msg,function(i,v){
          switch(v.video_rate) {
              case 1:
                  video_rate = '720P';
                  fileType = v.category == 1 || v.category == 7 ?  1 : 7;
                  break;
              case 2:
                  video_rate = '1080P';
                  fileType = v.category == 1 || v.category == 7 ?  1 : 7;
                  break;
              case 3:
                  video_rate = '4K';
                  fileType = v.category == 1 || v.category == 7 ?  1 : 7;
                  break;
              case 4:
                  video_rate = '8K';
                  fileType = v.category == 1 || v.category == 7 ?  1 : 7;
                  break;
              case 5:
                  video_rate = '2K';
                  fileType = v.category == 1 || v.category == 7 ?  0 : 7;
                  break;
              case 6:
                  video_rate = '4K';
                  fileType = v.category == 1 || v.category == 7 ?  1 : 7;
                  break;
              case 7:
                  video_rate = '8K';
                  fileType = v.category == 1 || v.category == 7 ?  1 : 7;
                  break;
              case 11:
                  video_rate = '720P';
                  fileType = v.category == 1 || v.category == 7 ?  1 : 7;
                  break;
              case 12:
                  video_rate = '1080P';
                  fileType = v.category == 1 || v.category == 7 ?  1 : 7;
                  break;
              case 13:
                  video_rate = '4K';
                  fileType = v.category == 1 || v.category == 7 ?  1 : 7;
                  break;
              case 14:
                  video_rate = '8K';
                  fileType = v.category == 1 || v.category == 7 ?  1 : 7;
                  break;
              default:
                  video_rate = '其它';
                  fileType = v.category == 1 || v.category == 7 ?  0 : 7;
                  break;
          }
          v.duration = secToTIme(v.duration);
          var newSmallVideoHtml = "";
          var videoCoverImgUrl = '//img95.699pic.com' + v.thumbnail_preview_src;
          var showNewVideoType = '<div class="video-vips-type">'+ (v.category == 1 ? '实拍' : '模板') +'</div>';
          var setVideoTypeClass = (video_rate == '8K') ? 'video-type8' : (video_rate == '4K' ? 'video-type4' : '');
          var showVideoTags = '<div class="video-tag-box clearfix">' + (v.only_single_sale == 1 ? '<div class="video-tag video-tag-optimizing">付费视频<div class="video-tag-drop"><p>应版权方要求，该素材仅支持单个购买后使用</p></div></div>' : '') + (v.auth_type == 2 ? '<div class="video-tag video-tag-enterprise">视频企业专享<div class="video-tag-drop"><p>仅支持企业商用授权，请开通视频企业VIP下载</p><p><a href="/video/vipinfo?click_type=916" target="_blank">查看更多视频 VIP权益 >></a></p></div></div>' : '') + '</div>';
          var showDownloadBtn = v.only_single_sale != 1 ? '<span class="icon-download fr" video-op-type="download-video" video-op-id="'+v.id+'" video-op-value="/download/video?id='+v.id+'" data-fileType="'+ fileType +'" data-videoRate="'+ v.video_rate +'" data-isQyExclusive="'+ (v.auth_type == 2 ? 1 : 0) +'"><i class="iconfont icon-liebiaoxiangqing-xiazaishu"></i>立即下载</span>' : '';
          if(v.category == 220) {
              newSmallVideoHtml += '<div class="video-cover-img">' +
                  '<div class="video-cover-bgimg">' +
                      '<img class="lazy video-cover-bg" src="//static.699pic.com/images/blank.png" data-original="'+ videoCoverImgUrl +'!/fh/178" alt="">' +
                      '<div class="video-cover-def">' +
                          '<img class="lazy" src="//static.699pic.com/images/blank.png" data-original="'+ videoCoverImgUrl +'!/fh/178" alt="">' +
                      '</div>' +
                  '</div>' +
              '</div>';
          } else {
              newSmallVideoHtml += '<img class="lazy" src="'+ videoCoverImgUrl +'!/both/317x178" alt="">';
          }
          dom +='<div class="video-li" data-time="'+v.duration+'" >'+
          '<a href="/video-'+v.id+'.html" target="_blank"> '+
              '<div class="video-box">'+ showNewVideoType + newSmallVideoHtml +
                  '<video muted="" class="video-hover '+ (v.height > v.width ? "video-spec" : "") +'" data-original="//video.699pic.com/'+ v.video_preview_10s_src+'" loop="loop" width="100%" height="100%"></video>'+
              '</div>'+
          '</a>'+
          '<a class="video-name fl" target="_blank" href="/video-'+v.id+'.html" title="'+v.display_title+'视频素材">'+
              '<h3>'+v.display_title+'</h3>'+
              '<span class="video-time">- '+v.duration+'</span>'+
              '<div class="type '+ setVideoTypeClass +'"><span>'+(video_rate == '4K' || video_rate == '8K' ? '' : video_rate)+'</span></div>'+
          '</a>'+
          '<div class="video-option clearfix">'+ showDownloadBtn +
              '<span class="video-collect fr " data-shou-id="'+v.id+'"><i class="iconfont icon-liebiaoxiangqing-shoucangshu"></i></span>'+
          '</div>'+
          '<div class="progress-bar">'+
              '<div class="progress-slider"></div>'+
          '</div>'+ showVideoTags +
      '</div>';
      });
    $('.photoAlbum-kong').hide();
    $('.Works-imgList').html('');
    $(dom).appendTo('.Works-imgList').find('img').lazyload({threshold :350});
    renderVideoCoverImg();
};
function renderVideoCoverImg() {
    if($(".video-cover-bgimg").length > 0) {
        document.head.style.filter = 'blur(10px)';
        var result = window.getComputedStyle(document.head).filter == 'blur(10px)';
        var getIeVersion = IEVersion();
        var isTargetIeVersion = Boolean(getIeVersion == 6 || getIeVersion == 7 || getIeVersion == 8 || getIeVersion == 9);
        (!result && !isTargetIeVersion) ? $(".video-cover-bgimg").find(".video-cover-bg").attr("data-original", "//static.699pic.com/images/video/video-default-cover.jpg") : '';
    }
}
// 获取IE版本
function IEVersion() {
    // 取得浏览器的userAgent字符串
    var userAgent = navigator.userAgent;
    // 判断是否为小于IE11的浏览器
    var isLessIE11 = userAgent.indexOf('compatible') > -1 && userAgent.indexOf('MSIE') > -1;
    // 判断是否为IE的Edge浏览器
    var isEdge = userAgent.indexOf('Edge') > -1 && !isLessIE11;
    // 判断是否为IE11浏览器
    var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf('rv:11.0') > -1;
    if (isLessIE11) {
        var IEReg = new RegExp('MSIE (\\d+\\.\\d+);');
        // 正则表达式匹配浏览器的userAgent字符串中MSIE后的数字部分，，这一步不可省略！！！
        IEReg.test(userAgent);
        // 取正则表达式中第一个小括号里匹配到的值
        var IEVersionNum = parseFloat(RegExp['$1']);
        if (IEVersionNum === 7) {
            // IE7
            return 7
        } else if (IEVersionNum === 8) {
            // IE8
            return 8
        } else if (IEVersionNum === 9) {
            // IE9
            return 9
        } else if (IEVersionNum === 10) {
            // IE10
            return 10
        } else {
            // IE版本<7
            return 6
        }
    } else if (isEdge) {
        // edge
        return 'edge'
    } else if (isIE11) {
        // IE11
        return 11
    } else {
        // 不是ie浏览器
        return -1
    }
}
/* ========================= 绑定事件 =========================*/
 /*视频hover*/
 var videoPromise = null;
    $('body').on('mouseenter', '.Works-imgList .video-li', function () {
        var $this = $(this);
        var video = $(this).find('video');
        var videoUrl = video.attr('data-original');
        var videoSrc = video.attr('src');
        var slider = $(this).find('.progress-slider');
        if(!$(this).attr('data-time')) return;
        var time = Number($(this).attr('data-time').split(':')[1]);
        var useTime =  time < 10 ? time - 1 : 9;
        var progressBarW = $(this).find('.progress-bar').width();
        if (!videoSrc) {
            video.attr('src', videoUrl);
            video[0].removeAttribute('controls');
        }
        video[0].playbackRate = 2;
        videoPromise = Promise.resolve(video[0].play());
        $this.find('.progress-bar').show();
        $this.find('.video-cover-img').length > 0 ? $this.find('.video-cover-img').hide() : $this.find('img').hide();

        video.off('timeupdate');
        video.on('timeupdate', function () {
            var timeStr = parseInt(video[0].currentTime);
            slider.css('width', timeStr / useTime * progressBarW);
        })
    });

    $('body').on('mouseleave', '.Works-imgList .video-li', function () {
        var video = $(this).find('video');
        $(this).find('.video-cover-img').length > 0 ? $(this).find('.video-cover-img').show() : $(this).find('img').show();
        $(this).find('.progress-bar').hide();
        try {
            videoPromise.then(function () {
                video[0].pause();
            }, function () {
                video.attr('src', null);
            })
        } catch (e) {
            video.attr('src', null);
        }
    });
// 收藏
$('body').on('click', '.video-collect', function () {
    if (!env.isLogin) {
        env.login();
        return;
    }
    // 获取用户收藏图片的PID
    userCollectPid = $(this).attr('data-shou-id');
    userCollectType = 7;
    var _obj = $(this);
    if($(this).hasClass('on'))
    {
        $.ajax({
            type: 'get',
            url: '/my/removeNewCollect',
            data: 'pid=' + userCollectPid + '&type='+userCollectType,
            success: function(res) {
                // 收藏、取消收藏转换
                _obj.removeClass('on');
            }
        })
        $(this).removeClass('on');

    }else{
        // 已收藏的图片提示，收藏成功
        $.ajax({
            type: 'get',
            url: '/my/getNewMyCollectInfo',
            data: 'option=getNewCollectGroup&pid=' + userCollectPid + '&type='+userCollectType,
            success: function(res) {
                if (res.state == '-11') {
                    doAlertNoCache('/alert/uniqueLogout');
                } else if (res.state == '-12') {
                    env.login();
                } else {
                    key = CONFIG['uid'] + '_user_is_collect_' + userCollectPid;
                    // 用户已经收藏过该图片
                    if (res.isCollect == true) {
                        // list.parents(".list").css("overflow", "initial");
                        // list.prev(".show").show();
                        console.log('已经收藏过了');
                        return;
                    }
                    // 用户没有收藏过该图片
                    if (res.limit) {
                        if (collectLimit == false) {
                            $("body").append(res.limit);
                        }
                        collectLimit = true; // 表示弹窗加载到页面
                        eval(res.run);
                    } else {
                        $('.copy-tips,.collect-onePop,.zhezhao').remove();
                        $("body").append(res.html);
                        $('#collect_pid').val(res.pid);
                        $(".shou_cang").show();
                        $(".zhezhao").show();
                    }
                }
            }
        })
        $(this).addClass('on');
    }
});
if($.trim($('.photoAlbum-searchText').val()).length){
  issou=true;
};
// 触发点击
if($('.photoAlbum-nav').length){
  var getUrlQueryPictype = getQueryString('picType') ? getQueryString('picType') : '';
  var getUrlQueryVideo = getQueryString('video_c1') ? getQueryString('video_c1') : '';
  if(getUrlQueryPictype == 100) {
    getUrlQueryVideo ? $('[data-video='+ getUrlQueryVideo +']').trigger('click') : $('.photoAlbum-navtab a.on').trigger('click');
  } else {
    getUrlQueryPictype ? $('[data-pic='+ getUrlQueryPictype +']').trigger('click') : $('.photoAlbum-navtab a.on').trigger('click');
  }
}