twt 2 years ago
parent
commit
c7f518a2fd
1 changed files with 82 additions and 35 deletions
  1. 82 35
      pages/index/home.vue

+ 82 - 35
pages/index/home.vue

@@ -13,48 +13,58 @@
 		data() {
 			return {
 				url: '',
-				
+				shareData:'',
 				wxOpendata:'',
 				id:'',
 			}
 		},
 		onLoad(opt) {
-			var that=this;
 			this.wxOpendata=uni.getStorageSync("wxOpendata");
-			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=""'
+			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
@@ -83,9 +93,46 @@
 		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>