shopro-share.vue
4.6 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<template>
<view class="content">
<view class="cu-modal bottom-modal" :class="[{ show: showModal }, modalType]" cathctouchmove @tap="hideModal">
<view class="cu-dialog" @tap.stop style="background: none; overflow: visible;">
<view class="share-box">
<view class="share-list-box x-f">
<!-- #ifdef MP-WEIXIN -->
<button class="share-item share-btn y-f" open-type="share">
<image class="share-img" src="http://shopro.7wpp.com/imgs/share_wx.png" mode=""></image>
<text class="share-title">微信好友</text>
</button>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<view class="share-item y-f" @tap="share">
<image class="share-img" src="http://shopro.7wpp.com/imgs/share_wx.png" mode=""></image>
<text class="share-title">微信好友</text>
</view>
<!-- #endif -->
<view
class="share-item y-f"
@tap="
sharePoster('/pages/public/poster/index', {
id: shareData.id,
image: shareData.image,
title: shareData.title,
price: posterType === 'groupon' ? shareData.groupon_price : shareData.price,
original_price: shareData.original_price,
teamNum: posterType === 'groupon' ? goodsInfo.num : 0,
posterType: posterType
})
"
>
<image class="share-img" src="http://shopro.7wpp.com/imgs/share_poster.png" mode=""></image>
<text class="share-title">分享海报</text>
</view>
<view class="share-item y-f" @tap="copySharePath">
<image class="share-img" src="http://shopro.7wpp.com/imgs/share_link.png" mode=""></image>
<text class="share-title">复制链接</text>
</view>
</view>
<view class="share-foot x-c" @tap="hideModal">取消</view>
</view>
</view>
</view>
<!-- 指引 -->
<shopro-share-guide v-model="showShareGuide"></shopro-share-guide>
</view>
</template>
<script>
import shoproShareGuide from '@/components/shopro-share-guide/shopro-share-guide.vue';
export default {
name: 'shoproShare',
components: {
shoproShareGuide
},
data() {
return {
showShareGuide: false,
shareData: {} //组装海报分享信息
};
},
props: {
value: {},
modalType: {
type: String,
default: ''
},
posterType: '', //海报类别
goodsInfo: {} //商品信息
},
computed: {
showModal: {
get() {
return this.value;
},
set(val) {
this.$emit('input', val);
}
}
},
created() {
let that = this;
if (that.posterType === 'groupon') {
that.shareData = that.goodsInfo.goods;
that.shareData.id = that.goodsInfo.id;
} else {
that.shareData = that.goodsInfo;
that.shareData.image = that.goodsInfo.image;
}
that.setShareInfo({
query: {
url: that.posterType + '-' + that.shareData.id
},
title: that.shareData.title,
image: that.shareData.image
});
},
methods: {
copySharePath() {
let that = this;
that.showModal = false;
uni.setClipboardData({
data: this.shareInfo.copyLink,
success: function(data) {
//#ifdef H5
that.$tools.toast('已复制到剪切板');
//#endif
},
fail: function(err) {},
complete: function(res) {}
});
},
sharePoster(path, query) {
let that = this;
this.showModal = false;
this.$Router.push({
path: path,
query: query
});
},
hideModal() {
this.showModal = false;
},
share() {
let that = this;
that.showModal = false;
// #ifdef H5
that.showModal = false;
that.showShareGuide = true;
// #endif
// #ifdef APP-PLUS
uni.share({
provider: 'weixin',
scene: 'WXSceneSession',
type: 0,
href: that.shareInfo.path,
title: that.shareInfo.title,
summary: that.shareData.title,
imageUrl: that.shareData.image,
success: res => {
console.log('success:' + JSON.stringify(res));
},
fail: err => {
console.log('fail:' + JSON.stringify(err));
}
});
// #endif
}
}
};
</script>
<style lang="scss">
.share-box {
background: #fff;
width: 750rpx;
border-radius: 30rpx 30rpx 0 0;
padding-top: 30rpx;
position: relative;
.share-foot {
font-size: 24rpx;
color: #bfbfbf;
height: 80rpx;
border-top: 1rpx solid #eee;
}
.share-list-box {
.share-btn {
background: none;
border: none;
line-height: 1;
padding: 0;
&::after {
border: none;
}
}
.share-item {
flex: 1;
padding-bottom: 20rpx;
.share-img {
width: 70rpx;
height: 70rpx;
background: rgba(246, 246, 254, 1);
border-radius: 50%;
margin-bottom: 20rpx;
}
.share-title {
font-size: 24rpx;
color: #666;
}
}
}
}
</style>