小说小程序前端代码仓库(小程序)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
3.2 KiB

  1. <template>
  2. <view class="subscription-popup" :class="{'dark-mode': isDarkMode}">
  3. <uv-popup ref="popup" mode="center" :closeOnClickOverlay="true" :customStyle="popupStyle">
  4. <view class="content theme-transition">
  5. <view class="popup-title theme-transition">{{ title }}</view>
  6. <view class="popup-desc theme-transition">{{ description }}</view>
  7. <view class="popup-btns">
  8. <button class="popup-btn theme-transition" @click="handleSubscribe">订阅本章</button>
  9. <button class="popup-btn popup-btn-video theme-transition">观看视频解锁</button>
  10. <button class="popup-btn popup-btn-batch theme-transition">批量订阅</button>
  11. </view>
  12. </view>
  13. </uv-popup>
  14. </view>
  15. </template>
  16. <script>
  17. import themeMixin from '@/mixins/themeMode.js'
  18. export default {
  19. name: 'subscriptionPopup',
  20. mixins: [themeMixin],
  21. props: {
  22. title: {
  23. type: String,
  24. default: '这是付费章节 需要订阅后才能阅读'
  25. },
  26. description: {
  27. type: String,
  28. default: '订阅后可继续阅读本章内容'
  29. }
  30. },
  31. data() {
  32. return {
  33. popupShown: false, // 是否已显示过
  34. }
  35. },
  36. computed: {
  37. popupStyle() {
  38. return {
  39. 'background': this.isDarkMode ? '#232323' : '#fff',
  40. 'padding': '48rpx 32rpx',
  41. 'text-align': 'center',
  42. 'border-radius': '24rpx',
  43. 'min-width': '500rpx'
  44. }
  45. }
  46. },
  47. methods: {
  48. // 打开弹窗
  49. open() {
  50. if (!this.popupShown) {
  51. this.$refs.popup.open();
  52. this.popupShown = true;
  53. }
  54. },
  55. // 关闭弹窗
  56. close() {
  57. this.$refs.popup.close();
  58. },
  59. // 重置状态,允许再次显示
  60. reset() {
  61. this.popupShown = false;
  62. },
  63. // 处理订阅按钮点击
  64. handleSubscribe() {
  65. this.$emit('subscribe');
  66. this.close();
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .subscription-popup {
  73. .content {
  74. .popup-title {
  75. font-size: 32rpx;
  76. font-weight: bold;
  77. color: #222;
  78. margin-bottom: 24rpx;
  79. word-wrap: break-word;
  80. white-space: normal;
  81. }
  82. .popup-desc {
  83. font-size: 26rpx;
  84. color: #999;
  85. margin-bottom: 40rpx;
  86. word-wrap: break-word;
  87. white-space: normal;
  88. }
  89. .popup-btns {
  90. display: flex;
  91. flex-wrap: wrap;
  92. justify-content: center;
  93. gap: 24rpx;
  94. .popup-btn {
  95. background: #ff9800;
  96. color: #fff;
  97. border-radius: 32rpx;
  98. font-size: 28rpx;
  99. padding: 0 32rpx;
  100. border: none;
  101. margin-bottom: 16rpx;
  102. word-break: keep-all;
  103. &.popup-btn-video {
  104. background: #fff3e0;
  105. color: #ff9800;
  106. border: 1px solid #ff9800;
  107. }
  108. &.popup-btn-batch {
  109. background: #fff;
  110. color: #ff9800;
  111. border: 1px solid #ff9800;
  112. }
  113. }
  114. }
  115. }
  116. &.dark-mode {
  117. .content {
  118. .popup-title {
  119. color: $dark-text-color-primary;
  120. }
  121. .popup-desc {
  122. color: $dark-text-color-tertiary;
  123. }
  124. .popup-btns {
  125. .popup-btn {
  126. background: #ff9800;
  127. color: #fff;
  128. &.popup-btn-video {
  129. background: rgba(255, 152, 0, 0.1);
  130. color: #ff9800;
  131. border: 1px solid #ff9800;
  132. }
  133. &.popup-btn-batch {
  134. background: $dark-bg-color-secondary;
  135. color: #ff9800;
  136. border: 1px solid #ff9800;
  137. }
  138. }
  139. }
  140. }
  141. }
  142. }
  143. </style>