share-popup.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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" :qrcodeUrl="qrcodeUrl"></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. data() {
  50. return {
  51. show: false,
  52. userInfo: {},
  53. qrcodeUrl: ''
  54. };
  55. },
  56. methods: {
  57. open() {
  58. this.show = true;
  59. this.userInfo = uni.getStorageSync('userInfo') || {};
  60. this.$u.api.getIsbnQrcodeAjax(this.product.isbn).then(res => {
  61. if (res.code == 200) {
  62. console.log(res);
  63. this.qrcodeUrl = res.data;
  64. }
  65. });
  66. },
  67. close() {
  68. this.show = false;
  69. },
  70. onGeneratePoster() {
  71. this.close();
  72. // Wait for close animation or immediate?
  73. // Usually immediate is fine, but if mask fades out, it might look weird.
  74. // But CustomPopup v-model controls visibility.
  75. this.$nextTick(() => {
  76. this.$refs.posterPopup.open();
  77. });
  78. }
  79. }
  80. };
  81. </script>
  82. <style lang="scss" scoped>
  83. .share-popup-content {
  84. position: relative;
  85. width: 100%;
  86. // Remove padding-top as background image defines the shape
  87. }
  88. .bg-image {
  89. position: absolute;
  90. top: 0;
  91. left: 0;
  92. width: 100%;
  93. height: 100%;
  94. z-index: 0;
  95. }
  96. .close-btn {
  97. position: absolute;
  98. top: -40rpx; // Position outside the card
  99. right: 20rpx;
  100. width: 80rpx;
  101. height: 80rpx;
  102. z-index: 10;
  103. display: flex;
  104. align-items: center;
  105. justify-content: center;
  106. image {
  107. width: 60rpx;
  108. }
  109. }
  110. .main-box {
  111. // Remove background and border-radius as they are provided by image
  112. position: relative;
  113. z-index: 1;
  114. padding: 80rpx 40rpx 60rpx; // Adjust padding to fit content within the background image design
  115. .title {
  116. font-size: 36rpx;
  117. font-weight: bold;
  118. color: #308740;
  119. margin-bottom: 60rpx;
  120. padding-left: 30rpx;
  121. }
  122. .share-options {
  123. display: flex;
  124. justify-content: space-around;
  125. padding: 0 40rpx;
  126. padding-top: 60rpx;
  127. .share-item {
  128. display: flex;
  129. flex-direction: column;
  130. align-items: center;
  131. .share-btn {
  132. display: flex;
  133. flex-direction: column;
  134. align-items: center;
  135. background: none;
  136. padding: 0;
  137. margin: 0;
  138. line-height: 1.5;
  139. &::after {
  140. border: none;
  141. }
  142. }
  143. image {
  144. width: 100rpx;
  145. height: 100rpx;
  146. margin-bottom: 20rpx;
  147. }
  148. text {
  149. font-size: 28rpx;
  150. color: #333;
  151. }
  152. }
  153. }
  154. }
  155. </style>