唤醒原生app

	wakeApp:function(schem, type) {
		var urlStr = '';
		if (type === 'cate') {
			urlStr = schem;
		} else {
	    	urlStr = 'tticarstorecall://' + schem;
		}
		// 判断机型
		var u = navigator.userAgent;
		var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1 || u.indexOf('Linux') > -1;  // android终端或者uc浏览器
		var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);  // ios终端
		// 判断是否在微信或者qq内
		var flagqqweixin = false;
		var ua = window.navigator.userAgent.toLowerCase();
		if (ua.match(/MicroMessenger/i) !== null) {
			flagqqweixin = true;
		}
		if (isAndroid && ua.match(/mobile mqqbrowser/i) !== null) {
			// 在QQ空间打开
			flagqqweixin = true;
		} else if (isiOS && ua.match(/qq/i) !== null) {
			flagqqweixin = true;
		}
		if (!flagqqweixin) {
			window.location.href = urlStr;
		    setTimeout(function () {
		    	window.location.href = window.location.protocol + '//' + 'test.h5-share.tticar.com/share'
				//	window.location.href = window.location.protocol + '//' + window.location.host + '/share';
		    }, 2000);
		} else {
			return true;
		}
		
	},
	
openApp:function(urlStr) {
	var flag = this.wakeApp(urlStr);
	if (flag) {
		$('.page_mask').css('display', 'block');
	}
},
that.$clickGoodDetails.on('click', function() {
	var goodsId = $(this).attr('id');
	var urlStr = '100/' + goodsId;
	that.openApp(urlStr);
});

你可能感兴趣的:(js)