Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

libai / fireflyReg

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • fireflyReg
  • 1
  • share
  • js
  • index.js
Find file
Normal viewHistoryPermalink
index.js 13.1 KB
Newer Older
libai's avatar
测试
8e24e39a
 
libai committed a year ago
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
/**
 * Created by webshow on 2018/3/16.
 */

$(function () {

    key='egro0h';
    console.log(returnCitySN["cname"])
    var ua = navigator.userAgent.toLowerCase();
    if (/android/.test(ua)) {
        province =['北京','天津','河北','山西','内蒙古','辽宁','吉林','黑龙江','上海','江苏','浙江','安徽','福建','江西','山东 ','河南','湖北','湖南','广东','广西','海南 ','重庆','四川','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆','香港','澳门']
        for(var i=0;i<province.length;i++){
            if(returnCitySN["cname"].indexOf(province[i])!=-1){
                key="ssvd7x";
            }
        }
    }
    else if(/iphone|ipad|ipod/.test(ua)){
        key='ssvd7x';
    }
    //var $ip = "http://ceshi.yabolive.tv/web";
    var $ip = "https://webserver.yabolive.net";
    var bilibi=true;
    //var url =window.location.href;
    ////var url="https://zhibo.yazhaiyabo.com/share/show/678be01626054a8ee/0/361501.html";
    //var userId=url.split('=')[url.split('=').length-1];
    var bbb = location.href;
    var data = url_get_params(bbb)
    var userId = data.uid; //t
    //sessionStorage.kkk = data.token;//k
    function url_get_params(url_path) {
        var url = url_path;
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(url.indexOf("?") + 1);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
    var h=$(window).height();
    $(".video-play").css("height",h+'px');
    //获取主播相关列表
    room(userId)
    $.ajax({
        url: $ip + "/share/getHotList.html",
        type: "post",
        data: {
            //'type':1,
            'os':"WEB",
            'cid':"web_gw",
            'lang':2,
            //'page':1,
            //'pageSize':12,
            //'type':2
        },
        error: function (msg) {
            console.log('请求出错');
        },
        success: function (msg) {
            var data=JSON.parse(msg);
            console.log(data);
            var html=[];
            for(var i=0;i<data.rooms.length;i++){
                html+='<li><img src=https://zhibocdn.yabolive.net/comm'+data.rooms[i].faceimg+'?x-oss-process=image/resize,w_200><div class="live"><span class="dian"></span><span class="live-text">Live</span></div><i style="float: left;font-size: 0">'+data.rooms[i].roomId+'</i></li>';
            }
            $(".more-ul").html(html);
            var id=data.rooms[0].roomId;
            //console.log(id);
            //room(id);
            $(".more-ul li").on("click", function () {
                var oid=$(this).children("i").text();
                console.log(oid)
                $(".video-play-bg1").addClass('video-play-bg').removeClass('video-play-bg1');
                room(oid);
                $("html,body").animate({scrollTop:0}, 0);
            })
        }
    })
    //闪灯
    var t1=setInterval(function () {

        if(bilibi==true){
            $(".dian").fadeOut(200);
            bilibi=false;
        }else if(bilibi==false){
            bilibi=true;
            $(".dian").fadeIn(200);
        }
    },700)

    $(window).on("scroll", function () {
        if($(window).scrollTop() >= 50){
            $(".down").fadeOut(0)
            $(".down-bottom").fadeIn(200)
        }
        else if($(window).scrollTop() < 50){
            $(".down").fadeIn(0)
            $(".down-bottom").fadeOut(0)
        }
    })
    //点击下载
    $(".down-btn").on("click", function () {
        browserRedirect();
    })
    $(".gift").on("click", function () {
        browserRedirect();
    })
    $(".inp").on("click", function () {
        browserRedirect();
    })
    $(".down-btn").on("click", function () {
        browserRedirect();
    })
    $(".guanzhu").on("click", function () {
        browserRedirect();
    })
    var ua = navigator.userAgent.toLowerCase();
    var userAgent = navigator.userAgent;
    if(/iphone|ipad|ipod/.test(ua)){
        if(ua.match(/MicroMessenger/i) == 'micromessenger'){
            $(".shadow-img").fadeIn(500)
        }
        if (userAgent.indexOf("witter") > -1){
            $(".shadow-img").fadeIn(500)
        }
        if (userAgent.indexOf("facebook") > -1){
            $(".shadow-img").fadeIn(500)
        }
        if(ua.match(/MicroMessenger/i) == 'micromessenger'){
            $(".shadow-img").fadeIn(500)
        }else{
            var data = OpenInstall.parseUrlParams();
            new OpenInstall({
                appKey: key,
                preferWakeup: true,
                mask:function(){
                    return '<div id="openinstall_shadow" class="shadow-img"><img src="images/share-img.png" alt=""></div>'
                },
                onready: function () {
                    var m = this, button = document.getElementById("down-btn");
                    setTimeout(function () {
                        $(".down-btn").on("click", function () {
                            m.schemeWakeup();
                            m.wakeupOrInstall();
                        })
                        $(".gift").on("click", function () {
                            m.schemeWakeup();
                            m.wakeupOrInstall();
                        })
                        $(".inp").on("click", function () {
                            m.schemeWakeup();
                            m.wakeupOrInstall();
                        })
                        $(".down-btn").on("click", function () {
                            m.schemeWakeup();
                            m.wakeupOrInstall();
                        })
                        $(".guanzhu").on("click", function () {
                            m.schemeWakeup();
                            m.wakeupOrInstall();
                        })
                        $(".text2").on("click", function () {
                            m.schemeWakeup();
                            m.wakeupOrInstall();
                        })
                        return false;
                    },300)


                }
            }, data);
        }
    }

    //openinstall初始化,初始化时将与openinstall服务器交互,应尽可能早的调用
    /*web页面向app传递的json数据(json string/js Object),应用被拉起或是首次安装时,通过相应的android/ios api可以获取此数据*/
    //var data = OpenInstall.parseUrlParams();//openinstall.js中提供的工具函数,解析url中的所有查询参数
    //new OpenInstall({
    //    /*appKey必选参数,openinstall平台为每个应用分配的ID*/
    //    appKey : "gyi4ky",
    //    /*可选参数,自定义android平台的apk下载文件名,只有apk在openinstall托管时才有效;个别andriod浏览器下载时,中文文件名显示乱码,请慎用中文文件名!*/
    //    //apkFileName : "OpenInstallDemo-v2-1.1.1.apk",
    //    /*可选参数,是否优先考虑拉起app,以牺牲下载体验为代价*/
    //    //preferWakeup:true,
    //    /*openinstall初始化完成的回调函数,可选*/
    //    onready : function() {
    //        //openinstall已成功回调,清除定时器
    //        clearTimeout(timer);
    //        timer = null;
    //
    //        var m = this, button = document.getElementsByClassName("down-btn");
    //        button.style.visibility = "visible";
    //
    //        /*在app已安装的情况尝试拉起app*/
    //        m.schemeWakeup();
    //        /*用户点击某个按钮时(假定按钮id为downloadButton),安装app*/
    //        button.onclick = function() {
    //            m.wakeupOrInstall();
    //        }
    //    }
    //}, data);

    function room(o){
        //获取直播间相关数据
        $.ajax({
            url: $ip + "/share/getInfo.html",
            type: "post",
            data: {
                'uid':0,
                'os': "WEB",
                'cid': "web_gw",
                'lang': 2,
                'fid': o,
            },
            error: function (msg) {
                console.log('请求出错');
            },
            success: function (msg) {
                var data=JSON.parse(msg);
                console.log(data);
                if(data.code==1){
                    $(".play-btn").fadeIn(500);
                    var html=[];
                    html+='<div class="box-img">' +
                        '<img class="bg-img" src=https://zhibocdn.yabolive.net/comm'+data.room.faceImg+' alt="">' +
                        '</div>';
                    $(".video-play-bg").html(html)
                    var html2=[];
                    html2+='<img src=https://zhibocdn.yabolive.net/comm'+data.room.faceImg+'?x-oss-process=image/resize,w_50 alt="">'
                    html2+='<span class="name">'+data.room.roomName+'</span>'
                    html2+='<span class="hot">'+data.room.lookNum+' 围观</span>'
                    $(".more").html(html2);
                    var vplay=data.room.hlsUrl;
                    console.log(vplay)
                    $(".play-btn").unbind();
                    $(".play-btn").on("click", function () {
                        var html=[];
                        $(".video-play-bg").css("height","100%");
                        html+='<video  id="videoID"webkit-playsinline="true" x-webkit-airplay="true"  playsinline="true"x5-video-player-type="h5"x5-video-player-fullscreen="true"style="width: 10rem; height:100%; object-fit:fill;position: absolute;z-index: 10"  poster="" src='+vplay+'></video>' +
                            '<div class="box-img">' +
                            '<img class="bg-img" src=https://zhibocdn.yabolive.net/comm'+data.room.faceImg+' alt="">' +
                            '<img class="zhuan" src="images/Loading.png" alt="">' +
                            '</div>';
                        $(".video-play-bg").html(html);

                        $(".video-play-bg").addClass('video-play-bg1').removeClass('video-play-bg');
                        $(".play-btn").fadeOut(500);
                        document.getElementById('videoID').play();
                    })
                }else{
                    var html =[];
                    html+='<div class="end">'
                    html+='<span class="text1">直播已结束</span>'
                    html+='<span class="text2">进入APP看直播</span>'
                    html+='</div>'
                    $(".video-play-bg").html(html)
                    $(".play-btn").fadeOut(0);
                    $(".name-more").fadeOut(0);
                    $(".guanzhu").fadeOut(0);
                    $(".video-play-bg").css("filter","blur(0px)");
                    //$(".text2").on("click", function () {
                    //    browserRedirect();
                    //    isWeiXin()
                    //})
                    //<div class="end">
                    //<span class="text1">直播已结束</span>
                    //<span class="text2">进入APP看直播</span>
                    //</div>
                }

            }

        });
        //用戶下載
        setInterval(function () {
            try{
                if (videoID.paused){
                    $(".play-btn").fadeIn(500);
                    $(".zhuan").fadeOut(500);
                }
            }catch(msg){

            }

        },1000)
    }

    function browserRedirect() {
        var ua = navigator.userAgent.toLowerCase();
        var userAgent = navigator.userAgent;

        //安卓
        if (/android/.test(ua)) {
            var data = OpenInstall.parseUrlParams();
            new OpenInstall({
                appKey: key,
                preferWakeup: true,
                mask:function(){
                    return '<div id="openinstall_shadow" class="shadow-img"><img src="images/share-img.png" alt=""></div>'
                },
                onready: function () {
                    var m = this, button = document.getElementById("down-btn");
                    m.schemeWakeup();
                    m.wakeupOrInstall();
                    return false;
                }
            }, data);
            //ios
        }
        //else if(/iphone|ipad|ipod/.test(ua)){
        //    if(ua.match(/MicroMessenger/i) == 'micromessenger'){
        //        $(".shadow-img").fadeIn(500)
        //    }else{
        //        var data = OpenInstall.parseUrlParams();
        //        new OpenInstall({
        //            appKey: 'j72b8j',
        //            preferWakeup: true,
        //            mask:function(){
        //                return '<div id="openinstall_shadow" class="shadow-img"><img src="images/share-img.png" alt=""></div>'
        //            },
        //            onready: function () {
        //                var m = this, button = document.getElementById("down-btn");
        //                setTimeout(function () {
        //                    m.schemeWakeup();
        //                    m.wakeupOrInstall();
        //                    return false;
        //                },300)
        //
        //
        //            }
        //        }, data);
        //    }
        //}
    }
})