share.vue 2.1 KB
<template>
	<view class="shareBox">
		<view class="shareDialog">
		<view class="sharelist">
			<view class="shareitem" @click="share('weixin','WXSceneSession')">
				<image src="../static/image/share-icon1.png" mode=""></image>
				<text>微信好友</text>
			</view>
			<view class="shareitem" @click="share('weixin','WXSenceTimeline')">
				<image src="../static/image/share-icon2.png" mode=""></image>
				<text>微信朋友圈</text>
			</view>
			<!-- <view class="shareitem" @click="share('qq')">
				<image src="../static/share-icon3.png" mode=""></image>
				<text>QQ</text>
			</view>
			<view class="shareitem" @click="share('sinaweibo')">
				<image src="../static/share-icon4.png" mode=""></image>
				<text>微博</text>
			</view> -->
		</view>
		<view class="cancelShare" @click="cancel">
			取消分享
		</view>
		</view>
	</view>
</template>

<script>
	export default{
		methods:{
			cancel(){
				this.$emit('close')
			},
			share(parm1,parm2=''){
				//"weixin", "qq", "sinaweibo"
				// WXSceneSession	分享到聊天界面
				// WXSenceTimeline	分享到朋友圈
				// WXSceneFavorite	分享到微信收藏
				uni.share({
					provider:parm1,
					title:"找地主",
					scene:parm2,
					type:0,
					summary:"找地主测试描述",
					href:"http://baidu.com",
					imageUrl:"https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/uni@2x.png",
					success:(res)=>{
						console.log(res)
					}
					
				})
			}
			
		},
		created() {
			
			uni.getProvider({
				service:"share",
				success(res) {
					console.log(res)
				}
			})
			
		},
		
	}
</script>

<style>
	.shareBox{position: fixed;top:0;left:0;right:0;bottom:0;background: rgba(0,0,0,0.5);}
.shareDialog{height: 320rpx;background: #fff;position: absolute;bottom:0;
width: 100%;}
.sharelist{display: flex;margin:50rpx 0 44rpx;justify-content: center;}
.shareitem{width: 25%;}
.shareitem image{width: 100rpx;height: 100rpx;display: block;margin:0 auto;}
.shareitem text{display: block;text-align: center;line-height: 40rpx;font-size: 24rpx;}
.cancelShare{text-align: center;border-top:1rpx solid #e5e5e5;line-height: 86rpx;
font-size: 28rpx;}
</style>