Procházet zdrojové kódy

修改分享图片

zhanghui před 1 rokem
rodič
revize
353fbcc69c
2 změnil soubory, kde provedl 110 přidání a 42 odebrání
  1. 82 38
      pages/groupbuying_details/index.vue
  2. 28 4
      pages/index/index.vue

+ 82 - 38
pages/groupbuying_details/index.vue

@@ -648,7 +648,7 @@ export default {
 		let that = this;
 		return {
 			title: groupon.mainTitle,
-			imageUrl: groupon.slideshow[0],
+			imageUrl:groupon.shareImage || groupon.slideshow[0],
 			path: `/pages/groupbuying_details/index?id=${groupon.id}&selfTakeId=${that.selfTakeId}&organizerUserId=${that.organizerUserId}&inviteUserId=${userInfo.userId}`,
 			success(res){
                 uni.showToast({
@@ -663,27 +663,73 @@ export default {
             }
 		};
 	},
+	//分享到朋友圈
+	// onShareTimeline(option) {
+	// 	let groupon = this.storeInfo;
+	// 	let userInfo = this.$Cache.get("USER_INFO", true)
+	// 	let that = this;
+	// 	return {
+	// 		title: groupon.slideshow[0],
+	// 		imageUrl: groupon.shareImage || groupon.slideshow[0],
+	// 		path: `/pages/groupbuying_details/index?id=${groupon.id}&selfTakeId=${that.selfTakeId}&organizerUserId=${that.organizerUserId}&inviteUserId=${userInfo.userId}`,
+	// 		success(res) {
+	// 			uni.showToast({
+	// 				title: '分享成功'
+	// 			})
+	// 		},
+	// 		fail(res) {
+	// 			uni.showToast({
+	// 				title: '分享失败',
+	// 				icon: 'none'
+	// 			})
+	// 		}
+	// 	};
+	// },
 	// #endif
 	onNavigationBarButtonTap (e) {
 		this.currentPage = !this.currentPage
 	},
 	methods: {
 
+		// goFirendo(){
+		// 	let groupon = this.storeInfo;
+		// 	let userInfo = this.$Cache.get("USER_INFO", true)
+		// 	let that = this;
+		// 	uni.share({
+		// 		provider: "weixin",
+		// 		scene: "WXSceneTimeline",
+		// 		type: 0,
+		// 		href: `/pages/groupbuying_details/index?id=${groupon.id}&selfTakeId=${that.selfTakeId}&organizerUserId=${that.organizerUserId}&inviteUserId=${userInfo.userId}`,
+		// 		title: groupon.slideshow[0],
+		// 		summary: groupon.slideshow[0],
+		// 		imageUrl:`/pages/groupbuying_details/index?id=${groupon.id}&selfTakeId=${that.selfTakeId}&organizerUserId=${that.organizerUserId}&inviteUserId=${userInfo.userId}`,
+		// 		success: function (res) {
+		// 			console.log(res)
+		// 			uni.showToast({
+		// 				title: '分享成功'
+		// 			})
+		// 		},
+		// 		fail: function (err) {
+		// 			console.log(err)
+		// 			uni.showToast({
+		// 				title: '分享失败',
+		// 				icon: 'none'
+		// 			})
+		// 		}
+		// 	});
+		//
+		//
+		// },
+
 		getFirstGoodsTop(id){
 			let that =this
-			console.log('+++++++++++++++++++++++获取第一个商品到顶部的距离+++++++++++++++++++++++++++++++++',id)
 			uni.createSelectorQuery().select("#goods"+id).boundingClientRect(data =>{
-				console.log('+++++++++++++++++++++++获取第一个商品到顶部的距离+++++++++++++++++++++++++++++++++')
-				console.log('+++++++++++++++++++++++获取第一个商品到顶部的距离+++++++++++++++++++++++++++++++++',data)
 				that.firstGoodsTop= Math.round(data.top);
-				console.log('+++++++++++++++++++++++第一个商品到顶部的距离+++++++++++++++++++++++++++++++++',firstGoodsTop)
 			}).exec();
 		},
 		toGoods1(id){
 			console.log(id)
 			uni.createSelectorQuery().select("#goods"+id).boundingClientRect(data =>{
-				console.log("得到布局位置信息" , data);
-				console.log("节点离页面顶部的距离为" + data.top);
 				this.scrollTop = Math.round(data.top) + Math.round(this.scrollY)
 			}).exec();
 			this.lookGoods = false
@@ -692,8 +738,6 @@ export default {
 		toGoods(id){
 			console.log(id)
 			uni.createSelectorQuery().select("#goods"+id).boundingClientRect(data =>{
-				console.log("得到布局位置信息" , data);
-				console.log("节点离页面顶部的距离为" + data.top);
 				this.scrollTop = Math.round(data.top);
 			}).exec();
 		},
@@ -1548,35 +1592,35 @@ export default {
 			this.$refs.cusPreviewImg.open(this.selectSku.suk);
 		},
 		//滑动轮播图选择商品
-		changeSwitch (e) {
-			let productSelect = this.skuArr[e];
-			this.$set(this, "selectSku", productSelect);
-			var skuList = productSelect.suk.split(",");
-			this.$set(this.attr.productAttr[0], "index", skuList[0]);
-
-			if (skuList.length == 2) {
-				this.$set(this.attr.productAttr[0], "index", skuList[0]);
-				this.$set(this.attr.productAttr[1], "index", skuList[1]);
-			} else if (skuList.length == 3) {
-				this.$set(this.attr.productAttr[0], "index", skuList[0]);
-				this.$set(this.attr.productAttr[1], "index", skuList[1]);
-				this.$set(this.attr.productAttr[2], "index", skuList[2]);
-			} else if (skuList.length == 4) {
-				this.$set(this.attr.productAttr[0], "index", skuList[0]);
-				this.$set(this.attr.productAttr[1], "index", skuList[1]);
-				this.$set(this.attr.productAttr[2], "index", skuList[2]);
-				this.$set(this.attr.productAttr[3], "index", skuList[3]);
-			}
-			if (productSelect) {
-				this.$set(this.attr.productSelect, "image", productSelect.image);
-				this.$set(this.attr.productSelect, "price", productSelect.price);
-				this.$set(this.attr.productSelect, "stock", productSelect.stock);
-				this.$set(this.attr.productSelect, "unique", productSelect.unique);
-				this.$set(this.attr.productSelect, "vipPrice", productSelect.vipPrice);
-				this.$set(this, "attrTxt", this.$t(`已选择`));
-				this.$set(this, "attrValue", productSelect.suk);
-			}
-		},
+		// changeSwitch (e) {
+		// 	let productSelect = this.skuArr[e];
+		// 	this.$set(this, "selectSku", productSelect);
+		// 	var skuList = productSelect.suk.split(",");
+		// 	this.$set(this.attr.productAttr[0], "index", skuList[0]);
+		//
+		// 	if (skuList.length == 2) {
+		// 		this.$set(this.attr.productAttr[0], "index", skuList[0]);
+		// 		this.$set(this.attr.productAttr[1], "index", skuList[1]);
+		// 	} else if (skuList.length == 3) {
+		// 		this.$set(this.attr.productAttr[0], "index", skuList[0]);
+		// 		this.$set(this.attr.productAttr[1], "index", skuList[1]);
+		// 		this.$set(this.attr.productAttr[2], "index", skuList[2]);
+		// 	} else if (skuList.length == 4) {
+		// 		this.$set(this.attr.productAttr[0], "index", skuList[0]);
+		// 		this.$set(this.attr.productAttr[1], "index", skuList[1]);
+		// 		this.$set(this.attr.productAttr[2], "index", skuList[2]);
+		// 		this.$set(this.attr.productAttr[3], "index", skuList[3]);
+		// 	}
+		// 	if (productSelect) {
+		// 		this.$set(this.attr.productSelect, "image", productSelect.image);
+		// 		this.$set(this.attr.productSelect, "price", productSelect.price);
+		// 		this.$set(this.attr.productSelect, "stock", productSelect.stock);
+		// 		this.$set(this.attr.productSelect, "unique", productSelect.unique);
+		// 		this.$set(this.attr.productSelect, "vipPrice", productSelect.vipPrice);
+		// 		this.$set(this, "attrTxt", this.$t(`已选择`));
+		// 		this.$set(this, "attrValue", productSelect.suk);
+		// 	}
+		// },
     addGoodsNum(item) {
 
     }

+ 28 - 4
pages/index/index.vue

@@ -20,6 +20,7 @@ export default {
 		uni.$on('is_diy', (data) => {
 			this.isDiy = data
 		})
+
 	},
 	onHide() {
 		// this.isDiy = -1
@@ -28,6 +29,13 @@ export default {
 		this.$refs.diy.pullResh();
 		// uni.stopPullDownRefresh()
 	},
+	onLoad(){
+		// wx.showShareMenu({
+		// 	withShareTicket:true,
+		// 	//设置下方的Menus菜单,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
+		// 	menus:["shareAppMessage","shareTimeline"]
+		// })
+	},
 	methods: {
 	},
 	// onReachBottom: function() {
@@ -44,7 +52,7 @@ export default {
 		let that = this;
 		return {
 			title: groupon.mainTitle,
-			imageUrl: groupon.slideshow[0],
+			imageUrl: groupon.shareImage || groupon.slideshow[0],
 			path: `/pages/groupbuying_details/index?id=${groupon.id}&selfTakeId=${that.selfTakeId}&organizerUserId=${that.organizerUserId}&inviteUserId=${userInfo.userId}`,
 			success(res) {
 				uni.showToast({
@@ -60,10 +68,26 @@ export default {
 		};
 	},
 	//分享到朋友圈
-	// onShareTimeline() {
+	// onShareTimeline(option) {
+	// 	console.log(option)
+	// 	let groupon = option.target.dataset.groupon;
+	// 	let userInfo = this.$Cache.get("USER_INFO", true)
+	// 	let that = this;
 	// 	return {
-	// 		title: this.shareInfo.title,
-	// 		imageUrl: this.shareInfo.img,
+	// 		title: groupon.shareImage || groupon.slideshow[0],
+	// 		imageUrl: groupon.slideshow[0],
+	// 		path: `/pages/groupbuying_details/index?id=${groupon.id}&selfTakeId=${that.selfTakeId}&organizerUserId=${that.organizerUserId}&inviteUserId=${userInfo.userId}`,
+	// 		success(res) {
+	// 			uni.showToast({
+	// 				title: '分享成功'
+	// 			})
+	// 		},
+	// 		fail(res) {
+	// 			uni.showToast({
+	// 				title: '分享失败',
+	// 				icon: 'none'
+	// 			})
+	// 		}
 	// 	};
 	// },
 	//#endif