uniapp打开其他应用

data(){
	return{
		appMap:{
			'itms-apps':{
				name: 'App Store',
				scheme: 'itms-apps://'
			},
			'alipay':{
				name: '支付宝',
				pname: 'com.eg.android.AlipayGphone',
				scheme: 'alipay://'
			},
			'taobao':{
				name: '淘宝',
				pname: 'com.taobao.taobao',
				scheme: 'taobao://'
			},
			'mqq':{
				name: 'QQ',
				pname: 'com.tencent.mobileqq',
				scheme: 'mqq://'
			},
			'weixin':{
				name: '微信',
				pname: 'com.tencent.mm',
				scheme: 'weixin://'
			},
			'jdMobile':{
				name: '京东',
				pname: 'com.jingdong.app.mall',
				scheme: 'openApp.jdMobile://'
			},
			'sinaweibo':{
				name: '新浪微博',
				pname: 'com.sina.weibo',
				scheme: 'sinaweibo://'
			},
			'youku':{
				name: '优酷',
				pname: 'com.youku.phone',
				scheme: 'youku://'
			},
		}
	}
},
methods:{
	launchApp(name) {//例如:this.launchApp('alipay') 打开支付宝
		if (plus.os.name == 'Android') {
			plus.runtime.launchApplication({
					pname: this.appMap[name].pname
				},
				function(e) {
					console.log('Open system default browser failed: ' + e.message);
				}
			);
		} else if (plus.os.name == 'iOS') {
			plus.runtime.launchApplication({
				action: this.appMap[name].scheme
			}, function(e) {
				console.log('Open system default browser failed: ' + e.message);
			});
		}
	}
}

你可能感兴趣的:(uniapp)