share.vue
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<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>