simple-share-popup.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="simple-share-popup">
  3. <cm-popup ref="sharePopup" type="bottom" :safe-area="safeArea">
  4. <!-- 操作栏 -->
  5. <view class="share-popup__control" @click.stop>
  6. <view class="share-popup__slot"><slot></slot></view>
  7. <view class="share-popup__row share-popup__items">
  8. <button
  9. open-type="share"
  10. class="share-popup__item share-popup__button share-popup__default"
  11. @click="onClick('share')"
  12. >
  13. <view class="share-popup__icon"><image :src="baseUrl + 'icon-share-wechat.png'"></image></view>
  14. <text class="share-popup__label">分享给好友</text>
  15. </button>
  16. <view class="share-popup__item share-popup__button" @click="onClick('create-poster')">
  17. <view class="share-popup__icon"><image :src="baseUrl + 'icon-poster.png'"></image></view>
  18. <text class="share-popup__label">生成海报</text>
  19. </view>
  20. </view>
  21. <view class="share-popup__row"><view class="share-popup__cancel" @click.stop="close">取消</view></view>
  22. </view>
  23. </cm-popup>
  24. </view>
  25. </template>
  26. <script>
  27. import cmPopup from '../uni-popup/uni-popup.vue'
  28. export default {
  29. props: {
  30. baseUrl: {
  31. type: String,
  32. default: 'https://static.caimei365.com/app/mini-hehe/icon/'
  33. },
  34. safeArea: {
  35. type: Boolean,
  36. default: true
  37. }
  38. },
  39. components: {
  40. cmPopup
  41. },
  42. methods: {
  43. open() {
  44. this.$refs.sharePopup.open()
  45. this.$emit('open')
  46. },
  47. close() {
  48. this.$refs.sharePopup.close()
  49. this.$emit('close')
  50. },
  51. onClick(type) {
  52. this.$emit('click', { type })
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. .simple-share-popup {
  59. .share-popup__control {
  60. width: 100%;
  61. background-color: #fff;
  62. border-radius: 16rpx 16rpx 0 0;
  63. padding-top: 40rpx;
  64. &.share-popup__no__safeArea {
  65. transform: translateY(34px);
  66. }
  67. &::after {
  68. content: '';
  69. position: absolute;
  70. width: 100%;
  71. height: 38px;
  72. bottom: -38px;
  73. background-color: #fff;
  74. }
  75. .share-popup__row {
  76. display: flex;
  77. justify-content: space-evenly;
  78. align-items: center;
  79. }
  80. .share-popup__items {
  81. padding-bottom: 40rpx;
  82. }
  83. .share-popup__button {
  84. display: flex;
  85. justify-content: center;
  86. align-items: center;
  87. flex-direction: column;
  88. &.share-popup__default {
  89. line-height: inherit;
  90. padding: 0;
  91. margin: 0;
  92. border: 0;
  93. background: transparent;
  94. &::after {
  95. border: 0;
  96. }
  97. }
  98. .share-popup__icon {
  99. display: flex;
  100. justify-content: center;
  101. align-items: center;
  102. width: 100rpx;
  103. height: 100rpx;
  104. border-radius: 50%;
  105. background-color: #f7f7f7;
  106. image {
  107. width: 64rpx;
  108. height: 64rpx;
  109. }
  110. }
  111. .share-popup__label {
  112. font-size: 26rpx;
  113. color: #333;
  114. margin-top: 16rpx;
  115. }
  116. }
  117. .share-popup__cancel {
  118. width: 100%;
  119. padding: 32rpx 0;
  120. border-top: 1rpx solid #e1e1e1;
  121. font-size: 28rpx;
  122. color: #666;
  123. font-weight: bold;
  124. text-align: center;
  125. }
  126. }
  127. }
  128. </style>