<template>
	<view>
		
		<!--#ifdef MP-WEIXIN -->
		<web-view :src="outUrl"></web-view>
		<!--#endif-->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				enterUrl:"",//进入页面路由
				outUrl:"",//跳出页面路由
			}
		},
		onLoad(option) {
			//#ifdef MP-WEIXIN
			this.enterUrl=option.q
			//#endif
			
			//#ifdef MP-ALIPAY
				this.enterUrl=uni.getStorageSync("alipayQrCode")
			//#endif
			
			if(this.enterUrl){//普通二维码扫码进入
				let channelId=this.getUrlKey("channelId")
				let companyId=this.getUrlKey("companyId")
				let merchantId=this.getUrlKey("merchantId")
				let groupId=this.getUrlKey("groupId")
				let groupChannelId=this.getUrlKey("groupChannelId")
				let pageType=this.getUrlKey("pageType")
				if(pageType==1){//组合
					this.outUrl="https://wx.pangdly.com/#/combiChoose?channelId="+channelId+"&merchantId="+merchantId+"&groupId="+groupId+"&groupChannelId="+groupChannelId+"&companyId="+companyId
					
				}else{//分销
					uni.navigateTo({
						url:"../distributionCombiChoose/distributionCombiChoose?channelId="+channelId+"&merchantId="+merchantId+"&groupId="+groupId+"&groupChannelId="+groupChannelId+"&companyId="+companyId
					})
				}
			}else{//小程序页面跳转进入
				let channelId=option.channelId
				let companyId=option.companyId
				let merchantId=option.merchantId
				let groupId=option.groupId
				let groupChannelId=option.groupChannelId
				let thirdOpenid=option.thirdOpenid//第三方openid
				let touristType=option.touristType//游客类型
				let pdOpenid=uni.getStorageSync("openid")//胖丁小程序openid
				let baseUrl="https://wx.pangdly.com/#/combiChoose?pdOpenid="+pdOpenid
				this.outUrl=baseUrl+"&thirdOpenid="+thirdOpenid+"&touristType="+touristType+"&channelId="+channelId+"&merchantId="+merchantId+"&groupId="+groupId+"&groupChannelId="+groupChannelId+"&companyId="+companyId
			}
			
			
		},
		methods: {
			getUrlKey(name){//---------------------------------------------------------------获取url
			  return(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(decodeURIComponent(this.enterUrl)) || [, ""])[1].replace(/\+/g, '%20') || "";
			},
		}
	}
</script>

<style>

</style>
