share.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. },
  64. methods: {
  65. open : function() {
  66. this.$refs.popup.open();
  67. },
  68. init : function() {
  69. this.Dever.shareInit(this.data);
  70. },
  71. share : function(type) {
  72. eval("this."+type+"()");
  73. },
  74. copy : function() {
  75. var self = this;
  76. var value = this.data.title;
  77. if (this.data.content) {
  78. value += "\r\n" + this.data.content;
  79. }
  80. if (this.data.link) {
  81. value += "\r\n" + this.data.link;
  82. }
  83. copyText.getClipboardData(value, function(res) {
  84. if (res) {
  85. self.Dever.alert('复制成功');
  86. } else {
  87. self.Dever.alert('复制失败');
  88. }
  89. });
  90. },
  91. weixin : function() {
  92. this.Dever.share('weixin', 'WXSceneSession', 0, this.data);
  93. },
  94. weixin_group : function() {
  95. this.Dever.share('weixin', 'WXSenceTimeline', 0, this.data);
  96. },
  97. qq : function() {
  98. this.Dever.share('qq', '', 1, this.data);
  99. },
  100. poster : function() {
  101. if (this.data.poster) {
  102. // 弹出海报
  103. } else {
  104. this.Dever.alert('没有海报素材');
  105. }
  106. }
  107. },
  108. components:{
  109. deverPopup
  110. }
  111. }
  112. </script>
  113. <style lang="scss">
  114. /* 底部分享 */
  115. .sharebtn {
  116. .uni-share {
  117. width: 690rpx;
  118. margin: 30rpx;
  119. border-radius: 30rpx;
  120. /* #ifndef APP-NVUE */
  121. display: flex;
  122. flex-direction: column;
  123. /* #endif */
  124. background-color: #fff;
  125. .uni-share-content {
  126. /* #ifndef APP-NVUE */
  127. display: flex;
  128. /* #endif */
  129. flex-direction: row;
  130. flex-wrap: nowrap;
  131. justify-content: center;
  132. overflow-x: scroll;
  133. padding: 15px 50rpx;
  134. .uni-share-content-box {
  135. /* #ifndef APP-NVUE */
  136. display: flex;
  137. /* #endif */
  138. flex-direction: column;
  139. align-items: center;
  140. // width: 25%;
  141. // justify-content: space-between;
  142. &:nth-last-child(1) {
  143. margin-right: 0;
  144. }
  145. .uni-share-content-image {
  146. /* #ifndef APP-NVUE */
  147. display: flex;
  148. /* #endif */
  149. flex-direction: row;
  150. justify-content: center;
  151. align-items: center;
  152. width: 90rpx;
  153. height: 90rpx;
  154. overflow: hidden;
  155. border-radius: 10rpx;
  156. .content-image {
  157. width: 90rpx;
  158. height: 90rpx;
  159. }
  160. }
  161. &:nth-last-child(1){
  162. .uni-share-content-image .content-image {
  163. width: 50rpx!important;
  164. height: 50rpx!important;
  165. }
  166. }
  167. .uni-share-content-text {
  168. font-size: 26rpx;
  169. color: #333;
  170. padding-top: 5px;
  171. padding-bottom: 10px;
  172. }
  173. }
  174. }
  175. }
  176. }
  177. </style>