<template>
	<view class="">
		<!-- 分享信息 -->
		<view>
			<uni-popup ref="sharewx" type="bottom" backgroundColor="#fff">
				<view class="popup-content">
					<view class="shareBox">
						<view class="shareOptionItem" @click="uniShare(1)">
							<view class="imgBox">
								<image src="../../static/app-plus/sharemenu/wechatfriend.png" mode="widthFix"></image>
							</view>
							<text>微信好友</text>
						</view>
						<view class="shareOptionItem" @click="uniShare(2)">
							<view class="imgBox">
								<image src="../../static/app-plus/sharemenu/wechatmoments.png" mode="widthFix"></image>
							</view>
							<text>分享朋友圈</text>
						</view>
					</view>
				</view>
				<view class="popup-footer" @click="closeShare()">
					<view>取消</view>
				</view>
			</uni-popup>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				WXdata:{}
			}
		},
		methods:{
			open(option) {
				console.log(option, 155)
				this.WXdata = option
				this.$refs.sharewx.open()
			},
			
			// 关闭微信分享啊
			closeShare() {
				this.$refs.sharewx.close()
			},
			uniShare(type) {
				// if (type === 1) {
					uni.share({
						provider: "weixin",
						scene: type === 1? "WXSceneSession":"WXSceneTimeline",
						type: 0,
						href: this.WXdata.href,
						title: this.WXdata.title,
						summary: this.WXdata.summary,
						imageUrl: this.WXdata.imageUrl,
						success: function(res) {
							console.log("success:" + JSON.stringify(res));
						},
						fail: function(err) {
							console.log("fail:" + JSON.stringify(err));
						}
					});
			},
		}
	}
</script>

<style lang="scss">
	.popup-footer {
		color: #666;
		font-size: 36rpx;
		border-top: 2rpx solid #f0f0f0;
		display: flex;
		justify-content: center;
		align-items: center;
		padding-top: 36rpx;
	}
	.popup-content {
		font-size: 32rpx;
		color: #666;
		padding-bottom: 40rpx;
	
		.shareBox {
			display: flex;
			justify-content: space-around;
			align-items: center;
	
			.shareOptionItem {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
	
				.imgBox {
					width: 100rpx;
				}
			}
	
		}
	}
</style>