天天看點

uniapp打包app分享為微信小程式

小程式端和app端分享html:

<!-- #ifdef APP-PLUS -->
<view class="goodsMenu" @click="appShare">
	<view class="menuIcon">
		<image src="/package/static/mall/goodsShare.png" mode=""></image>
	</view>
	<view class="menuName">分享</view>
	</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<button open-type="share" hover-class="none" class="goodsMenu">
	<view class="menuIcon">
		<image src="/package/static/mall/goodsShare.png" mode=""></image>
	</view>
	<view class="menuName">分享</view>
</button>
<!-- #endif -->
           

小程式端分享js:

onShareAppMessage(res) {
	let _this = this;
	return {
		title: _this.goodsTit,
		// imageUrl: '',
		path: '/package/pages/mall/goodsDetail/goodsDetail?goods_id=' + _this.goods_id,
	}
},
           

app分享為微信小程式js:

appShare() {
	var _this=this;
	// App分享為微信小程式(App中分享一個内容到微信好友,對方微信中呈現的是一個小程式卡片)
	uni.share({
		provider: 'weixin',
		scene: "WXSceneSession",
		type: 5,
		imageUrl: '',
		title: _this.goodsDetail.goods_name,
		miniProgram: {
			id: getApp().globalData.originalId,
			path: 'pages/index/index',
			type: 0,
			webUrl: 'http://uniapp.dcloud.io'
		},
			success: res => {
			console.log(JSON.stringify(res));
		}
	});
},
           

app分享為微信小程式調用說明:uniapp官方分享文檔說明

繼續閱讀