URL schemes, open app app with hyperlinks
varMobileappinstall = (function () { varUA =Navigator.useragent, Loadiframe, Win=window, Isipad= Ua.match (/ipad/i)! =NULL, Isiphone=!isipad && (ua.match (/iphone/i)! =NULL) || (Navigator.userAgent.match (/ipod/i)! =NULL)), Isios= Isipad | |Isiphone, Isandroid=!isios && ua.match (/android/i)! =NULL, IsMobile= Isios | |isandroid; functionGetintentiframe () {if(!loadiframe) { variframe = document.createelement ("iframe"); Iframe.style.cssText= "display:none;width:0px;height:0px;"; Document.body.appendChild (IFRAME); Loadiframe=iframe; } returnLoadiframe; } functionGetplayurl (ivideoid, sLy) {varVideoplayurl = Ivideoid = = ""? "": "http://m.video.baomihua.com/m/" +ivideoid; Videoplayurl= Videoplayurl = = ""? ": Videoplayurl + (SLy = =" "?" ":" _ly= "+sLy); returnVideoplayurl; } varAppInstall ={IsChrome:ua.match (/chrome\/([\d.] +)/) || Ua.match (/crios\/([\d.] +)/), IsAndroid:ua.match (/(Android);? [\s\/]+ ([\d.] +)?/), IsWeixin:ua.match (/micromessenger/i)! =NULL, IsUC:ua.match (/ucbrowser/i)! =NULL, timeout:500, /** * Try to jump AppUrl, if jump failed, enter H5url * @param {object} appurl apply Address * @param {object} Chromeurl app address * @param {Object} h5url http address*/Open:function(AppUrl, Chromeurl, H5url) {vart =Date.now (); Appinstall.openapp (AppUrl); SetTimeout (function () { if(Date.now ()-T < Appinstall.timeout * 2 + 100) {H5url&&Appinstall.openh5 (H5url); }}, Appinstall.timeout)}, Openapp:function(appurl) {if(appinstall.ischrome) {if(appinstall.isandroid) {win.location.href=Chromeurl; } Else{win.location.href=AppUrl; } } Else{getintentiframe (). SRC=AppUrl; }}, OpenH5:function(h5url) {win.location.href=H5url; }, PlayVideo:function(Ivideoid, Ichannelid, sLy) {varVideoplayurl =Getplayurl (ivideoid, sLy); if(SLy = = "UC" | | sLy = = "Bdqyy") {window.location=Videoplayurl; return; } if(!isandroid | | appinstall.isweixin | |appinstall.isuc) {window.location=Videoplayurl; return; } AppUrl=Getandroidappurl (Ichannelid, ivideoid, sLy); Chromeurl=getchromeintent (Ichannelid, ivideoid, sLy); varSredirect =Getdownloadurl (Ichannelid, ivideoid, sLy); Mobileappinstall.open (AppUrl, Chromeurl, Sredirect); } } returnAppInstall; functionGetdownloadurl (Ichannelid, ivideoid, sLy) {varDownloadURL = "http://m.video.baomihua.com/play2/player/dlVideoApp.htm?videoid=" +ivideoid; DownloadURL= DownloadURL + (Ichannelid = = ""? "": "&channelid=" +ichannelid); DownloadURL= DownloadURL + (SLy = = ""? "": "&ly=" +sLy); returnDownloadURL; } functionGetandroidappurl (Ichannelid, ivideoid, sLy) {varDL = "Pmhapp://video.view/play"; Switch(parseint (ichannelid)) { Case13: DL= "Pmhapp://video.view/play"; Break; Case3: DL= "Pmhapp://video.view/play"; Break; Case55: DL= "Pmhgcw://video.view/play"; Break; default: DL= "Pmhapp://video.view/play"; Break; } returnDL + "? id=" + Ivideoid + (sLy?) "&ly=" + sLy: ""); } functiongetchromeintent (Ichannelid, ivideoid, ily) {//modify it according to your own product. varDL = "Intent://video.view/play?id=" + ivideoid + (ily? "&ly=" + ily: "") + "#Intent; Scheme=pmhapp;package=com.com.baomihuawang.androidclient;end"; Switch(parseint (ichannelid)) { Case13: DL= "Intent://video.view/play?id=" + ivideoid + (ily?) "&ly=" + ily: "") + "#Intent; Scheme=pmhapp;package=com.com.baomihuawang.androidclient;end"; Break; Case3: DL= "Intent://video.view/play?id=" + ivideoid + (ily?) "&ly=" + ily: "") + "#Intent; Scheme=pmhapp;package=com.com.baomihuawang.androidclient;end"; Break; Case55: DL= "Intent://video.view/play?id=" + ivideoid + (ily?) "&ly=" + ily: "") + "#Intent; Scheme=pmhgcw;package=com.com.baomihuawang.androidclient;end"; Break; default: DL= "Intent://video.view/play?id=" + ivideoid + (ily?) "&ly=" + ily: "") + "#Intent; Scheme=pmhapp;package=com.com.baomihuawang.androidclient;end"; } returnDL; }})();
Open App app via hyperlinks