share-popup.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view>
  3. <CustomPopup v-model="show" mode="center" width="700rpx" bgColor="transparent" :maskClosable="true">
  4. <view class="share-popup-content">
  5. <!-- Background Image -->
  6. <image class="bg-image" src="/pages-sell/static/goods/icon-share-bg.png" mode="widthFix"></image>
  7. <!-- Close Button -->
  8. <view class="close-btn" @click="close">
  9. <image src="/pages-sell/static/goods/icon-close.png" mode="widthFix"></image>
  10. </view>
  11. <!-- Main Content -->
  12. <view class="main-box">
  13. <view class="title">分享</view>
  14. <view class="share-options">
  15. <view class="share-item">
  16. <button class="share-btn" open-type="share">
  17. <image src="/pages-sell/static/goods/icon-wx.png" mode="widthFix"></image>
  18. <text>微信好友</text>
  19. </button>
  20. </view>
  21. <view class="share-item" @click="onGeneratePoster">
  22. <image src="/pages-sell/static/goods/icon-pic.png" mode="widthFix"></image>
  23. <text>生成海报</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </CustomPopup>
  29. <!-- Poster Popup -->
  30. <PosterPopup ref="posterPopup" :product="product" :userInfo="userInfo"></PosterPopup>
  31. </view>
  32. </template>
  33. <script>
  34. import CustomPopup from '@/components/custom-popup.vue';
  35. import PosterPopup from './poster-popup.vue';
  36. import { mapState } from 'vuex';
  37. export default {
  38. name: 'SharePopup',
  39. components: {
  40. CustomPopup,
  41. PosterPopup
  42. },
  43. props: {
  44. product: {
  45. type: Object,
  46. default: () => ({})
  47. }
  48. },
  49. computed: {
  50. ...mapState('user', ['userInfo'])
  51. },
  52. data() {
  53. return {
  54. show: false
  55. };
  56. },
  57. methods: {
  58. open() {
  59. this.show = true;
  60. },
  61. close() {
  62. this.show = false;
  63. },
  64. onGeneratePoster() {
  65. this.close();
  66. // Wait for close animation or immediate?
  67. // Usually immediate is fine, but if mask fades out, it might look weird.
  68. // But CustomPopup v-model controls visibility.
  69. this.$nextTick(() => {
  70. this.$refs.posterPopup.open();
  71. });
  72. }
  73. }
  74. };
  75. </script>
  76. <style lang="scss" scoped>
  77. .share-popup-content {
  78. position: relative;
  79. width: 100%;
  80. // Remove padding-top as background image defines the shape
  81. }
  82. .bg-image {
  83. position: absolute;
  84. top: 0;
  85. left: 0;
  86. width: 100%;
  87. height: 100%;
  88. z-index: 0;
  89. }
  90. .close-btn {
  91. position: absolute;
  92. top: -40rpx; // Position outside the card
  93. right: 20rpx;
  94. width: 80rpx;
  95. height: 80rpx;
  96. z-index: 10;
  97. display: flex;
  98. align-items: center;
  99. justify-content: center;
  100. image {
  101. width: 60rpx;
  102. }
  103. }
  104. .main-box {
  105. // Remove background and border-radius as they are provided by image
  106. position: relative;
  107. z-index: 1;
  108. padding: 80rpx 40rpx 60rpx; // Adjust padding to fit content within the background image design
  109. .title {
  110. font-size: 36rpx;
  111. font-weight: bold;
  112. color: #308740;
  113. margin-bottom: 60rpx;
  114. padding-left: 30rpx;
  115. }
  116. .share-options {
  117. display: flex;
  118. justify-content: space-around;
  119. padding: 0 40rpx;
  120. padding-top: 60rpx;
  121. .share-item {
  122. display: flex;
  123. flex-direction: column;
  124. align-items: center;
  125. .share-btn {
  126. display: flex;
  127. flex-direction: column;
  128. align-items: center;
  129. background: none;
  130. padding: 0;
  131. margin: 0;
  132. line-height: 1.5;
  133. &::after {
  134. border: none;
  135. }
  136. }
  137. image {
  138. width: 100rpx;
  139. height: 100rpx;
  140. margin-bottom: 20rpx;
  141. }
  142. text {
  143. font-size: 28rpx;
  144. color: #333;
  145. }
  146. }
  147. }
  148. }
  149. </style>