话说好像是这样,ios下面通常用iframe来打开你的scheme地址; Android下通常用location.href来。。。 不过实际情况好像比这个复杂得多。。
http://js.40017.cn/touch/hb/p/openApp.js /**
* Created by wsy10943 on 2015/5/18.
*/
window._web_public_app = {
/*
* 根据ua,判定手机系统ios,android,wp
* */
getUa: function () {
var ua = window.navigator.userAgent.toLocaleLowerCase(), isApple = !!ua.match(/(ipad|iphone|mac)/i), isAndroid = !!ua.match(/android/i), isWinPhone = !!ua.match(/MSIE/i), ios6 = !!ua.match(/os 6.1/i);
return { isApple: isApple, isAndroid: isAndroid, isWinPhone: isWinPhone, ios6: ios6 }
},
/*
* 执行唤起、下载动作
* */
openApp: function (json) {
var _uaName = this.browserName(), self = this, platforms = self.getUa(), skipUrl = "", schemeURL = "", tcSchemeURL="";
if (json.param.businessParam == undefined) {
if (json.param.schemeUrl == "h5Site") {
schemeURL = json.param.refid + "?schemUrl=" + self.getSchemeUrl(json.param);
tcSchemeURL = "tctravel://" + self.getSchemeUrl(json.param);
}
else {
schemeURL = json.param.refid + "/" + self.getSchemeUrl(json.param);
tcSchemeURL = "tctravel://" + self.getSchemeUrl(json.param);
} }
else {
if (json.param.schemeUrl == "h5Site") {
schemeURL = json.param.refid + "?schemUrl=" + self.getSchemeUrl(json.param) + "|" + self.getbusinessParam(json.param.schemeUrl, json.param.businessParam);
tcSchemeURL = "tctravel://" + self.getSchemeUrl(json.param) + "|" + self.getbusinessParam(json.param.schemeUrl, json.param.businessParam);
}
else {
schemeURL = json.param.refid + "/" + self.getSchemeUrl(json.param) + "|" + self.getbusinessParam(json.param.schemeUrl, json.param.businessParam);
tcSchemeURL = "tctravel://" + self.getSchemeUrl(json.param) + "|" + self.getbusinessParam(json.param.schemeUrl, json.param.businessParam);
} }
tcSchemeURL = decodeURIComponent(tcSchemeURL).replace(/\|/g, "/");
if (json.param.actionType == || json.param.actionType == "") {
if (platforms.isAndroid) {
skipUrl = "http://m.17u.cn/client/sj/" + schemeURL;
if (_uaName == "WeiXin") {
window.location.href = "http://m.17u.cn/client/qr/" + schemeURL;//微信对m.17u.cn站点做了白名单
}
else if (_uaName == "sogousearch") {
window.location.href = "http://m.17u.cn/client/sj/" + schemeURL;//兼容搜狗浏览器
}
//针对uc做特殊处理
else if (_uaName == "ucbrowser") {
window._web_public_app.iframeWake(tcSchemeURL);
}
else if (_uaName == "Chrome") {
window.location.href = "http://m.17u.cn/client/sj/" + schemeURL;//兼容谷歌浏览器
}
else {
window._web_public_app.iframeWake(skipUrl);
}
}
else if (platforms.isApple) {
if (_uaName == "Chrome" || _uaName == "Crios") {
window.location.href = tcSchemeURL;//兼容谷歌浏览器
}
//如果未安装客户端,ios6版本,Safari浏览解析地址出错
else if (platforms.ios6 && _uaName == "Safari") {
}
else {
skipUrl = "http://m.17u.cn/client/sj/" + schemeURL;
if (_uaName == "WeiXin") {
window.location.href = "http://m.17u.cn/client/qr/" + schemeURL;//微信对m.17u.cn站点做了白名单
}
else {
window._web_public_app.iframeWake(skipUrl);
}
}
}
}
else if (json.param.actionType == || json.param.actionType == "") {
skipUrl = "http://m.17u.cn/client/dj/" + json.param.refid;
if (_uaName == "WeiXin") {
window.location.href = "http://m.17u.cn/client/qr/" + json.param.refid;
}
else {
if (platforms.isApple) {
if (_uaName == "Chrome" || _uaName == "Safari" || _uaName == "Crios") {
window.location.href = "https://itunes.apple.com/cn/app/tong-cheng-lu-you-zhou-mo/id475966832?mt=8";
}
else {
window._web_public_app.iframeWake(skipUrl);
}
}
else {
if (_uaName == "sogousearch") {
window.location.href = skipUrl;//兼容搜狗浏览器
}
else {
window._web_public_app.iframeWake(skipUrl);
}
}
}
}
else {
var wakeUrl = "http://m.17u.cn/client/sj/" + schemeURL,
downUrl = "http://m.17u.cn/client/dj/" + json.param.refid;;
if (platforms.isAndroid) {
if (_uaName == "WeiXin") {
window.location.href = "http://m.17u.cn/client/qr/" + schemeURL;//微信对m.17u.cn站点做了白名单
}
else if (_uaName == "sogousearch") {
window.location.href = "http://m.17u.cn/client/sj/" + schemeURL;//兼容搜狗浏览器
}
//针对uc做特殊处理
else if (_uaName == "ucbrowser") {
window._web_public_app.iframeWake(tcSchemeURL);
}
else if (_uaName == "Chrome") {
window.location.href = "http://m.17u.cn/client/sj/" + schemeURL;//兼容谷歌浏览器
}
else {
window._web_public_app.iframeWake(wakeUrl);
}
setTimeout(function () {
if (_uaName == "sogousearch") {
window.location.href = downUrl;//兼容搜狗浏览器
}
else if (_uaName == "WeiXin") {
}
else {
window._web_public_app.iframeWake(downUrl);
}
}, );
}
else if (platforms.isApple) {
if (_uaName == "Chrome" || _uaName == "Crios") {
window.location.href = tcSchemeURL;//兼容谷歌浏览器
}
//如果未安装客户端,ios6版本,Safari浏览解析地址出错
else if (platforms.ios6 && _uaName == "Safari") {
}
else {
if (_uaName == "WeiXin") {
window.location.href = "http://m.17u.cn/client/qr/" + schemeURL;//微信对m.17u.cn站点做了白名单
}
else {
window._web_public_app.iframeWake(wakeUrl);
}
}
setTimeout(function () {
if (_uaName == "Chrome" || _uaName == "Safari" || _uaName == "Crios") {
window.location.href = "https://itunes.apple.com/cn/app/tong-cheng-lu-you-zhou-mo/id475966832?mt=8";
}
else if (_uaName == "WeiXin") {
}
else {
window._web_public_app.iframeWake(downUrl);
}
}, );
}
}
},
/*
* 通过iframe唤起app
**/
iframeWake: function (url) {
var c = document.createElement("div");
c.style.visibility = "hidden";
c.innerHTML = '<iframe src="' + url + '" scrolling="no" width="1" height="1"></iframe>';
document.body.appendChild(c);
},
/*
* 获取浏览器名称
* */
browserName: function () {
var ua = window.navigator.userAgent.toLowerCase();
var browser = "";
if (window.ActiveXObject) {
browser = "IE"
} else {
if (document.getBoxObjectFor || ua.indexOf("firefox") > -) {
browser = "Firefox"
} else {
if (ua.indexOf("micromessenger") > -) {
browser = "WeiXin";
}
else {
if (ua.indexOf("baidu") != -) {
browser = "baidubrowser";
} else {
if (ua.indexOf("ucbrowser") != -) {
browser = "ucbrowser";
} else {
if (ua.indexOf("miuibrowser") > -) {
browser = "miuibrowser";
} else {
if (ua.indexOf("lbbrowser") > -) {
browser = "lbbrowser";
}
else {
if (ua.indexOf("qqbrowser") > -) {
browser = "qqbrowser";
}
else {
if (ua.indexOf("qhbrowser") > -) {
browser = "qhbrowser";
} else {
if (ua.indexOf("hao123") > -) {
browser = "hao123";
} else {
if (ua.indexOf("sogoumobilebrowser") > -) {
browser = "sogousearch";
} else {
if (ua.indexOf("crios") > -) {
browser = "Crios";
} else {
if (ua.indexOf("chrome") > -) {
browser = "Chrome";
} else {
if (window.opera) {
browser = "Opera";
} else {
if (ua.indexOf("safari") > -) {
browser = "Safari";
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return browser;
},
/**
*通过传入参数获取schemeUrl
*/
getSchemeUrl: function (data) {
var schemeUrl = "";
switch (data.schemeUrl) {
//大首页
case "tcHome":
schemeUrl = "shouji.17u.cn|internal_v950v" + data.refid + "v|home|home";
break;
//酒店首页
case "hotelHome":
schemeUrl = "shouji.17u.cn|internal_v9001v" + data.refid + "v|hotel|home";
break;
//酒店列表
case "hotelList":
schemeUrl = "shouji.17u.cn|internal_v9002v" + data.refid + "v|hotel|list";
break;
//酒店详情
case "hotelDetails":
schemeUrl = "shouji.17u.cn|internal_v9003v" + data.refid + "v|hotel|details";
break;
//景区首页
case "sceneryHome":
schemeUrl = "shouji.17u.cn|internal_v9011v" + data.refid + "v|scenery|home";
break;
//景区列表
case "sceneryList":
schemeUrl = "shouji.17u.cn|internal_v9012v" + data.refid + "v|scenery|list";
break;
//景区详情
case "sceneryDetails":
schemeUrl = "shouji.17u.cn|internal_v9013v" + data.refid + "v|scenery|details";
break;
//景区预订
case "sceneryBook":
schemeUrl = "shouji.17u.cn|internal_v9014v" + data.refid + "v|scenery|book";
break;
//国内机票首页
case "flightHome":
schemeUrl = "shouji.17u.cn|internal_v9021v" + data.refid + "v|flight|home";
break;
//国内机票列表
case "flightList":
schemeUrl = "shouji.17u.cn|internal_v9022v" + data.refid + "v|flight|list";
break;
//国际机票首页
case "interflightHome":
schemeUrl = "shouji.17u.cn|internal_v9031v" + data.refid + "v|interflight|home";
break;
//国际机票列表
case "interflightList":
schemeUrl = "shouji.17u.cn|internal_v9032v" + data.refid + "v|interflight|list";
break;
//周边游首页-混合
case "zhouMoYouHome":
schemeUrl = "shouji.17u.cn|internal_v9041v" + data.refid + "v|h5|file|8|main.html%3Fwvc1=1%26wvc2=1";
break;
//周边游列表
case "zhouMoYouList":
schemeUrl = "shouji.17u.cn|internal_v9042v" + data.refid + "v|selftrip|list";
break;
//周边游详情
case "zhouMoYouDetails":
schemeUrl = "shouji.17u.cn|internal_v9043v" + data.refid + "v|selftrip|details";
break;
//出境游首页
case "holidayHome":
schemeUrl = "shouji.17u.cn|internal_v9051v" + data.refid + "v|holiday|home";
break;
//出境游列表
case "holidayList":
schemeUrl = "shouji.17u.cn|internal_v9052v" + data.refid + "v|holiday|list";
break;
//出境游详情
case "holidayDetails":
schemeUrl = "shouji.17u.cn|internal_v9053v" + data.refid + "v|holiday|details";
break;
//邮轮首页
case "cruiseHome":
schemeUrl = "shouji.17u.cn|internal_v9061v" + data.refid + "v|h5|file|3|main.html%3Fwvc1=1%26wvc2=1";
break;
//邮轮列表
case "cruiseList":
schemeUrl = "shouji.17u.cn|internal_v9062v" + data.refid + "v|h5|file|3|main.html%3Fwvc1=1%26wvc2=1%23%7ccalendar";
break;
//邮轮详情
case "cruiseDetails":
schemeUrl = "shouji.17u.cn|internal_v9063v" + data.refid + "v|h5|file|3|main.html%3Fwvc1=1%26wvc2=1%23%7cdetail";
break;
//火车首页
case "trainHome":
schemeUrl = "shouji.17u.cn|internal_v9071v" + data.refid + "v|train|home";
break;
//火车列表
case "trainList":
schemeUrl = "shouji.17u.cn|internal_v9072v" + data.refid + "v|train|list";
break;
//攻略首页
case "guideHome":
schemeUrl = "shouji.17u.cn|internal_v9081v" + data.refid + "v|guide|home";
break;
//用车首页
case "yongCheHome":
schemeUrl = "shouji.17u.cn|internal_v9091v" + data.refid + "v|yongche|singlehome";
break;
//用车首页
case "busHome":
schemeUrl = "shouji.17u.cn|internal_v9101v" + data.refid + "v|bus|home";
break;
//电影票首页
case "movieHome":
schemeUrl = "shouji.17u.cn|internal_v9111v" + data.refid + "v|movie|home";
break;
//电影票详情
case "movieDetails":
schemeUrl = "shouji.17u.cn|internal_v9112v" + data.refid + "v|movie|details";
break;
//发现首页
case "discoverHome":
schemeUrl = "shouji.17u.cn|internal_v9121v" + data.refid + "v|tchome|tchome";
break;
//客户端内部跳转h5页面
case "h5Site":
var siteUrl;
if (!!data.siteUrl.match(/(http|http:|:)/i)) {
siteUrl = data.siteUrl.replace(/\http\:\/\//g, "");
}
else {
siteUrl = data.siteUrl;
}
schemeUrl = encodeURIComponent(siteUrl.replace(/\//g, "|"));
break;
case "selftripDetails":
schemeUrl = "shouji.17u.cn|internal_v9131v" + data.refid + "v|selftrip|groupdetails";
break;
case "smartNoteHome":
schemeUrl = "shouji.17u.cn|internal_v9141v" + data.refid + "v|h5|file|22|main.html%3Fwvc1=1%26wvc2=1%26wvc3=1";
break;
default:
schemeUrl = "shouji.17u.cn|internal_v950v" + data.refid + "v|home|home" ;
break; }
return schemeUrl;
},
/**
*获取拼接的参数
*/
getbusinessParam: function (projectType, objParam) {
var businessParam = "";
switch (projectType) {
//酒店列表
case "hotelList":
businessParam = encodeURIComponent(objParam.ctype + "_" + objParam.cId + "_" + objParam.smallcid + "_" + objParam.tagtype + "_" + objParam.tagid + "_" + objParam.tagname);
break;
//酒店详情
case "hotelDetails":
businessParam = encodeURIComponent(objParam.hotelId);
break;
//景区列表
case "sceneryList":
var cityid = "";
if (objParam.cityid != "") {
cityid = "|" + objParam.cityid;
}
businessParam = encodeURIComponent(objParam.keyword + cityid);
break;
//景区详情
case "sceneryDetails":
businessParam = encodeURIComponent(objParam.sceneryId);
break;
//景区预订
case "sceneryBook":
businessParam = encodeURIComponent(objParam.sceneryId + "|" + objParam.priceId);
break;
//国内机票列表
case "flightList":
businessParam = encodeURIComponent(objParam.originAirportCode + "|" + objParam.arriveAirportCode + "|" + objParam.flyOffTime);
break;
//国际机票列表
case "interflightList":
businessParam = encodeURIComponent(objParam.originAirportCode + "|" + objParam.arriveAirportCode + "|" + objParam.flyOffTime);
break;
//周边游列表
case "zhouMoYouList":
businessParam = encodeURIComponent(objParam.keyword);
break;
//周边游详情
case "zhouMoYouDetails":
businessParam = encodeURIComponent(objParam.lineId);
break;
//出境游列表
case "holidayList":
var activityId = "", timeId = "";
if (objParam.activityId != "") {
activityId = "|" + objParam.activityId;
}
if (objParam.timeId != "") {
timeId = "|" + objParam.timeId;
}
businessParam = encodeURIComponent(objParam.cityName + activityId + timeId);
break;
//出境游详情
case "holidayDetails":
businessParam = encodeURIComponent(objParam.lineId);
break;
case "cruiseList":
businessParam = encodeURIComponent(objParam.lineId);
break;
case "cruiseDetails":
businessParam = encodeURIComponent(objParam.id + "|" + objParam.dataTime + "|" + objParam.naTag);
break;
case "movieDetails":
businessParam = encodeURIComponent(objParam.movieId);
break;
case "discoverHome":
businessParam = encodeURIComponent("?tab=" + objParam.tab);
break;
//火车票列表
case "trainList":
businessParam = encodeURIComponent(objParam.startPlace + "|" + objParam.endPlace);
break;
//快乐周末详情
case "selftripDetails":
businessParam = encodeURIComponent("?srid=" + objParam.lineId);
break;
default:
break;
}
return businessParam;
}
}
话说好像是这样,ios下面通常用iframe来打开你的scheme地址; Android下通常用location.href来。。。 不过实际情况好像比这个复杂得多。。的更多相关文章
- Foundation框架下的常用类:NSNumber、NSDate、NSCalendar、NSDateFormatter、NSNull、NSKeyedArchiver
========================== Foundation框架下的常用类 ========================== 一.[NSNumber] [注]像int.float.c ...
- ios iphone ipad上iframe的宽度会扩大的解决办法
这个问题,我从网上查了下,好像是属于ios的bug,android,windows都没有问题. 解决办法,就是在iframe加载完成后,设置 iframe里面body的宽度为多少PX. $(" ...
- flutter之VSCode下Flutter常用终端命令行
https://www.cnblogs.com/lxlx1798/p/11049922.html 梁飞宇 [Flutter学习]之VSCode下Flutter常用终端命令行 Flutter 常用命令行 ...
- Linux下最常用的10个文件压缩工具
作者简介 李先生(Lemon),高级运维工程师(自称),SRE专家(目标),梦想在35岁买一辆保时捷.喜欢钻研底层技术,认为底层基础才是王道.一切新技术都离不开操作系统(CPU.内存.磁盘).网络等. ...
- 基于H5的移动端开发,window.location.href在IOS系统无法触发问题
最近负责公司的微信公众号开发项目,基于H5进行开发,某些页面window.location.href在Android机上能正常运行而IOS系统上无法运行,导致无法重定向到指定页面,查了好久终于找到方法 ...
- 54. Android中adb常用命令及应用常用目录
本文主要介绍adb常用命令及应用常用目录.1.adb常用命令adb devices列出所有连接的android设备.以下命令都是对单个devices而言,如果存在多个devices的话,下面的命令都需 ...
- 解决redhat linux下IP地址可以ping通,域名无法ping通问题
解决redhat linux下IP地址可以ping通,域名无法ping通 在/etc/resolv.conf中添点东西 格式如下: nameserver xxx.xxx.xxx.xxx nameser ...
- 移动web在ios和android下点击元素出现阴影问题
移动web开发经验总结 1.-webkit-tap-highlight-color:rgba(255,255,255,0)可以同时屏蔽ios和android下点击元素时出现的阴影.备注:transp ...
- 网站加载有商务通、商桥,定义js函数触发快商通代码
有的网站已经加载了商务通.商桥的,前期定义了js函数 触发商务通.商桥代码的,可以重新定义新的函数对之前的函数进行覆盖,其 js代码为: var domain = document.domain; / ...
随机推荐
- oss cmd
osscmd是基于python 2.5.4(其他版本没有试过),用来操作OSS的,可使用命令行来上传和下载文件. 下载地址:http://storage.aliyun.com/leo/osscmd.t ...
- 第一篇随笔!!!THE FIRST BLOOD!!!
注册成功,哈哈 以后就要在这扎窝了,要坚持记录下去,关于生活,关于学习. 选了个皮肤 darkgreen,不错,简洁舒服,喜欢. 好,差不多了,感觉没什么可说的了...==
- PHP数组处理函数的使用array_push(一)
使用PHP做数据处理时会涉及到大量的数组操作,这里我就记下各种数组处理函数的使用方法,好记性不如烂笔头!! 一.array_push的使用方法:将一个或多个单元压入数组的末尾(入栈) 说明:int a ...
- MYSQL调优
4核8G内存配置文件 explain SQL 查看SQL索引使用情况. my.cnf skip-external-locking skip-name-resolve back_log= key_buf ...
- Hibernate uniqueResult方法的使用
以前写代码,总免不了编写登陆部分.在获取user的时候,只可能返回一个user实例,或者为null.以前使用以下方法实现.public User get(String id){ Sessio ...
- GOF业务场景的设计模式-----单例模式
个人觉得 纯粹的学习设计模式,是不对的.也不能为了使用设计模式,而硬搬设计模式来使用 单例模式可能是 最简单的设计模式也是 大家知道最多的设计模式.当然 ,有很多种写法 定义:确保一个类只有一个实例, ...
- 知识梳理HTML篇
HTML 浏览器内核: IE:trident Firefox : gecko Safari/chrome : webkit Opera : presto(新 ...
- Linux鲜为人知的安全漏洞:不要将输出内容管道给你的shell
将wget或curl输出的内容管道给bash或者sh是一件非常愚蠢的事,例如像下面这样: wget -O - http://example.com/install.sh | sudo sh 命令解释: ...
- sql group by 理解
order by是对字段进行排序,group by 是对字段进行分类,在select 语句中可以使用group by 子句将行划分成较小的组,然后,使用组函数返回每一个组的汇总信息,另外,可以使用ha ...
- etcd
https://github.com/silenceper/dcmp http://studygolang.com/topics/1866