share.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template name="dever-share">
  2. <view>
  3. <dever-popup ref="popup" type="bottom">
  4. <view class="sharebtn">
  5. <view class="uni-share">
  6. <view class="uni-share-content">
  7. <view v-for="(v, k) in button" :key="k" class="uni-share-content-box" :style="v.type == 'copy' ? 'margin-right:0rpx;' : mr" @click='share(v.type)'>
  8. <view class="uni-share-content-image">
  9. <image :src="v.icon" class="content-image" />
  10. </view>
  11. <text class="uni-share-content-text">{{ v.text }}</text>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </dever-popup>
  17. </view>
  18. </template>
  19. <script>
  20. import deverPopup from "@/lib/dever/components/popup.vue";
  21. import copyText from "@/lib/clipboard.thorui.js";
  22. import wx from "@/lib/dever/components/jweixin.js";
  23. export default {
  24. data() {
  25. return {
  26. button: [{
  27. text: '微信',
  28. icon: '/static/dever/weixin.png',
  29. type: 'weixin'
  30. },
  31. {
  32. text: '朋友圈',
  33. icon: '/static/dever/pengyouquan.png',
  34. type: 'weixin_group'
  35. },
  36. {
  37. text: 'QQ',
  38. icon: '/static/dever/qq.png',
  39. type: 'qq'
  40. }
  41. ],
  42. }
  43. },
  44. props: {
  45. id : 0,
  46. data : {},
  47. },
  48. created : function() {
  49. this.mr = 'margin-right:60rpx';
  50. if (this.data && this.data.poster) {
  51. this.mr = 'margin-right:40rpx';
  52. this.button.push({
  53. text: '海报',
  54. icon: '/static/dever/poster.png',
  55. type: 'poster'
  56. });
  57. }
  58. this.button.push({
  59. text: '复制',
  60. icon: '/static/dever/copy.png',
  61. type: 'copy'
  62. });
  63. this.init();
  64. },
  65. methods: {
  66. open : function() {
  67. this.$refs.popup.open();
  68. },
  69. init : function() {
  70. this.Dever.shareInit(wx, 1, 1, this.data);
  71. },
  72. share : function(type) {
  73. eval("this."+type+"()");
  74. },
  75. copy : function() {
  76. var self = this;
  77. var value = this.data.title;
  78. if (this.data.content) {
  79. value += "\r\n" + this.data.content;
  80. }
  81. if (this.data.link) {
  82. value += "\r\n" + this.data.link;
  83. }
  84. copyText.getClipboardData(value, function(res) {
  85. if (res) {
  86. self.Dever.alert('复制成功');
  87. } else {
  88. self.Dever.alert('复制失败');
  89. }
  90. });
  91. },
  92. weixin : function() {
  93. this.Dever.share('weixin', 'WXSceneSession', 0, this.data);
  94. },
  95. weixin_group : function() {
  96. this.Dever.share('weixin', 'WXSenceTimeline', 0, this.data);
  97. },
  98. qq : function() {
  99. this.Dever.share('qq', '', 1, this.data);
  100. },
  101. poster : function() {
  102. if (this.data.poster) {
  103. // 弹出海报
  104. } else {
  105. this.Dever.alert('没有海报素材');
  106. }
  107. }
  108. },
  109. components:{
  110. deverPopup
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. /* 底部分享 */
  116. .sharebtn {
  117. .uni-share {
  118. width: 690rpx;
  119. margin: 30rpx;
  120. border-radius: 30rpx;
  121. /* #ifndef APP-NVUE */
  122. display: flex;
  123. flex-direction: column;
  124. /* #endif */
  125. background-color: #fff;
  126. .uni-share-content {
  127. /* #ifndef APP-NVUE */
  128. display: flex;
  129. /* #endif */
  130. flex-direction: row;
  131. flex-wrap: nowrap;
  132. justify-content: center;
  133. overflow-x: scroll;
  134. padding: 15px 50rpx;
  135. .uni-share-content-box {
  136. /* #ifndef APP-NVUE */
  137. display: flex;
  138. /* #endif */
  139. flex-direction: column;
  140. align-items: center;
  141. // width: 25%;
  142. // justify-content: space-between;
  143. &:nth-last-child(1) {
  144. margin-right: 0;
  145. }
  146. .uni-share-content-image {
  147. /* #ifndef APP-NVUE */
  148. display: flex;
  149. /* #endif */
  150. flex-direction: row;
  151. justify-content: center;
  152. align-items: center;
  153. width: 90rpx;
  154. height: 90rpx;
  155. overflow: hidden;
  156. border-radius: 10rpx;
  157. .content-image {
  158. width: 90rpx;
  159. height: 90rpx;
  160. }
  161. }
  162. &:nth-last-child(1){
  163. .uni-share-content-image .content-image {
  164. width: 50rpx!important;
  165. height: 50rpx!important;
  166. }
  167. }
  168. .uni-share-content-text {
  169. font-size: 26rpx;
  170. color: #333;
  171. padding-top: 5px;
  172. padding-bottom: 10px;
  173. }
  174. }
  175. }
  176. }
  177. }
  178. </style>