<template>
	<view class="content">
		<view class="box">
			<web-view :src="url" @message="message"></web-view> 
		</view>
		<!-- <view>12zf</view> -->
		 
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: '',
				shareData:'',
				wxOpendata:'',
				id:'',
			}
		},
		onLoad(opt) {
			this.wxOpendata=uni.getStorageSync("wxOpendata");
			var that=this;
			if (opt.path) {
			      //this.url = `${this.url}${options.path}`
				   //this.url = opt.path
				    console.log('options', opt)
				    this.url=JSON.parse(opt.path).url+"?id="+opt.id+"&codeapp="+that.wxOpendata.code+'&shareID='+opt.shareID
			     
			}else{
				
				uni.getLocation({
				    type: 'wgs84',
				    success: function (res) {
				       if(opt.id){
				       	that.url=that.$webURL+'paySuccess?orderId='+opt.id+'&hideHeader=true&codeapp='+that.wxOpendata.code+'&lat='+res.latitude+'&lng='+res.longitude
				       }else{
				       	if(!that.wxOpendata.shopID){
				       		uni.navigateTo({
				       			url:'../login/empower'
				       		})
				       	}
				       	if(that.wxOpendata.code){
				       		//this.url='http://dms.32che.cn/#/carOwner/index?codeapp='+this.wxOpendata.code+ '&shopId='+this.wxOpendata.shopID
				       		that.url=that.$webURL+'?codeapp='+that.wxOpendata.code+ '&shopId='+that.wxOpendata.shopID+'&lat='+res.latitude+'&lng='+res.longitude
				       	}
				       }
						
				    },
					fail(err) {
						if(opt.id){
							that.url=that.$webURL+'paySuccess?orderId='+opt.id+'&hideHeader=true&codeapp='+that.wxOpendata.code+'&lat=""&lng=""'
						}else{
							if(!that.wxOpendata.shopID){
								uni.navigateTo({
									url:'../login/empower'
								})
							}
							if(that.wxOpendata.code){
								//this.url='http://dms.32che.cn/#/carOwner/index?codeapp='+this.wxOpendata.code+ '&shopId='+this.wxOpendata.shopID
								that.url=that.$webURL+'?codeapp='+that.wxOpendata.code+ '&shopId='+that.wxOpendata.shopID+'&lat=""&lng=""'
							}
						}
					}
				});
				
			}
			
			/* if(opt.id){
				this.url=this.$webURL+'paySuccess?orderId='+opt.id+'&hideHeader=true&codeapp='+this.wxOpendata.code
			}else{
				if(!this.wxOpendata.shopID){
					uni.navigateTo({
						url:'../login/empower'
					})
				}
				if(this.wxOpendata.code){
					//this.url='http://dms.32che.cn/#/carOwner/index?codeapp='+this.wxOpendata.code+ '&shopId='+this.wxOpendata.shopID
					this.url=this.$webURL+'?codeapp='+this.wxOpendata.code+ '&shopId='+this.wxOpendata.shopID
				}
			} */
			
			/* if(opt.shopId){
				this.url2='http://wx.32che.cn/weixin/authorize?path=/carOwner/index&isCarOwner=true&shopId='+opt.shopId
			} */
           
		   
		
		   
		},
		
		
		methods: {
            message(event){
                console.log(event);
				let { data } = event.mp.detail
				console.log('message', data)
				this.shareData = JSON.parse(data.pop())
				console.log(this.shareData)
				//this.shareData= event.mp.detail
            },
			
		},
		onShareAppMessage(){
			console.log(this.shareData)
			var share={
				url:this.shareData.path
			}
			var obj=JSON.stringify(share)
			console.log(obj)
			/*   
			    if (this.shareData) {
			       path = shareData.path
			    } */
		 return {
		       title:'1111',
		       //path: 'pages/index/home?path='+ encodeURI(obj),
			   path: 'pages/index/home?path='+ obj+'&id='+this.shareData.id+'&shareID='+this.shareData.shareID,
		       imageUrl:this.shareData.img,
		       success: function (res) {
		           // 转发成功
		         wx.showToast({
		           title: "转发成功",
		           icon: 'success',
		           duration: 2000
		         })
		       },
		       fail: function (res) {
		           // 转发失败
		       },
			   }
		
		}
	}
	
</script>

<style>
	.content {
		/* display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center; */
		
	}
	.box{
		padding-bottom: env(safe-area-inset-bottom);
		
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>