shareProp.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <u-popup v-model="shareShow" mode="bottom">
  3. <view class="share">
  4. <view class="share-item">
  5. <button open-type="share" @click.stop="onShareAppMessage()" class="child">
  6. <image src="/static/image/share_1.png" mode="" style="width: 112upx;height: 112upx;"></image>
  7. <view class="item-text">
  8. 微信好友
  9. </view>
  10. </button>
  11. <button @click="onShare()" hover-stop-propagation="true" class="child">
  12. <image src="/static/image/share_2.png" mode="" style="width: 112upx;height: 112upx;"></image>
  13. <view class="item-text">
  14. 朋友圈
  15. </view>
  16. </button>
  17. <view class="child" @click="copy" v-if="!hidden">
  18. <image src="/static/image/share_3.png" mode="" style="width: 112upx;height: 112upx;"></image>
  19. <view class="item-text">
  20. 复制链接
  21. </view>
  22. </view>
  23. <view class="child" v-if="!hidden">
  24. <image src="/static/image/share_4.png" mode="" style="width: 112upx;height: 112upx;"></image>
  25. <view class="item-text">
  26. 保存图片
  27. </view>
  28. </view>
  29. </view>
  30. <view class="share-button" @click="shareShow=false">
  31. 取消分享
  32. </view>
  33. </view>
  34. </u-popup>
  35. </template>
  36. <script>
  37. var app = getApp()
  38. export default {
  39. name: "shareProp",
  40. data() {
  41. return {
  42. shareShow: false,
  43. detail: '', //详情
  44. hidden: app.globalData.hidden
  45. }
  46. },
  47. onLoad() {
  48. uni.showShareMenu({
  49. withShareTicket: true,
  50. menus: ["shareAppMessage", "shareTimeline"]
  51. })
  52. },
  53. onShareAppMessage(item) {
  54. return {
  55. title: this.detail.name,
  56. path: 'pages/detail/recruitDetail/recruitDetail?id=' + this.detail.id,
  57. }
  58. },
  59. // 自定义页面的分享到朋友圈
  60. onShareTimeline() { //分享好友
  61. return {
  62. title: this.detail_msg.name,
  63. path: 'pages/detail/recruitDetail/recruitDetail?id=' + this.detail_msg.id,
  64. }
  65. },
  66. methods: {
  67. showEdit(row) {
  68. this.detail = row
  69. console.log(row, 'rowrwowerwrwrwr')
  70. this.shareShow = true
  71. },
  72. // 复制
  73. copy() {
  74. uni.setClipboardData({
  75. data: 'pages/detail/recruitDetail/recruitDetail',
  76. success: () => {
  77. uni.showToast({
  78. icon: 'none',
  79. title: '复制成功'
  80. });
  81. }
  82. });
  83. },
  84. onShare() {
  85. uni.showToast({
  86. icon: 'none',
  87. title: '点击右上角三个点找到分享朋友圈'
  88. });
  89. },
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. //分享弹窗
  95. .share {
  96. .share-item {
  97. display: flex;
  98. padding: 40upx 30upx;
  99. align-items: center;
  100. width: 100%;
  101. .child {
  102. width: 25%;
  103. display: flex;
  104. flex-direction: column;
  105. align-items: center;
  106. }
  107. .item-text {
  108. font-size: 13px;
  109. color: #8a8a8a;
  110. margin-top: 10upx;
  111. }
  112. }
  113. .share-button {
  114. text-align: center;
  115. padding: 30upx;
  116. border-top: solid 1px #cacaca;
  117. }
  118. button {
  119. margin: 0 !important;
  120. background-color: #fff;
  121. }
  122. ::after {
  123. border: none;
  124. }
  125. }
  126. </style>