├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

index.vue 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="vip-page">
  3. <!-- 会员状态卡片 -->
  4. <view class="vip-card" :class="{'active': isVIP}">
  5. <view class="card-header">
  6. <text class="title">{{ isVIP ? `超级会员 · 有效期至${expireDate}` : '立即开通会员' }}</text>
  7. <text v-if="!isVIP" class="tag">限时6折</text>
  8. </view>
  9. <view class="privileges">
  10. <view v-for="(item, index) in privileges" :key="index" class="privilege-item">
  11. <uni-icons type="checkmark" size="16" color="#fff"></uni-icons>
  12. <text>{{ item }}</text>
  13. </view>
  14. </view>
  15. <button v-if="!isVIP" class="purchase-btn" @click="showPlans">立即开通</button>
  16. <button v-else class="renew-btn" @click="showPlans">续费会员</button>
  17. </view>
  18. <!-- 会员套餐列表 -->
  19. <view v-if="showPlanSelector" class="plan-container">
  20. <view class="plan-header">
  21. <text class="plan-title">选择套餐</text>
  22. <uni-icons type="close" size="24" @click="showPlanSelector = false"></uni-icons>
  23. </view>
  24. <view class="plan-list">
  25. <view
  26. v-for="plan in vipPlans"
  27. :key="plan.id"
  28. :class="['plan-item', { 'recommended': plan.recommended }]"
  29. @click="selectPlan(plan)"
  30. >
  31. <view class="plan-top">
  32. <text class="duration">{{ plan.duration }}个月</text>
  33. <text v-if="plan.recommended" class="rec-tag">推荐</text>
  34. </view>
  35. <view class="price">
  36. <text class="symbol">¥</text>
  37. <text class="amount">{{ plan.price }}</text>
  38. <text class="original">¥{{ plan.originalPrice }}</text>
  39. </view>
  40. <text class="daily">日均¥{{ (plan.price / (plan.duration * 30)).toFixed(2) }}</text>
  41. </view>
  42. </view>
  43. <button class="confirm-btn" @click="handlePurchase">确认支付</button>
  44. </view>
  45. </view>
  46. </template>
  47. <script setup>
  48. import { ref, computed } from 'vue'
  49. import { useVipStore } from '@/stores/vip'
  50. const vipStore = useVipStore()
  51. const showPlanSelector = ref(false)
  52. const selectedPlan = ref(null)
  53. // 会员套餐配置
  54. const vipPlans = ref([
  55. { id: 1, duration: 1, price: 15, originalPrice: 30, recommended: false },
  56. { id: 2, duration: 3, price: 40, originalPrice: 90, recommended: true },
  57. { id: 3, duration: 12, price: 120, originalPrice: 360, recommended: false }
  58. ])
  59. // 计算到期日显示
  60. const expireDate = computed(() => {
  61. if (!vipStore.expireTime) return ''
  62. const date = new Date(vipStore.expireTime)
  63. return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
  64. })
  65. // 显示套餐选择器
  66. const showPlans = () => {
  67. showPlanSelector.value = true
  68. }
  69. // 选择套餐
  70. const selectPlan = (plan) => {
  71. selectedPlan.value = plan
  72. }
  73. // 执行购买
  74. const handlePurchase = async () => {
  75. if (!selectedPlan.value) {
  76. uni.showToast({ title: '请选择套餐', icon: 'none' })
  77. return
  78. }
  79. const success = await vipStore.purchaseVip(selectedPlan.value)
  80. if (success) {
  81. showPlanSelector.value = false
  82. }
  83. }
  84. </script>
  85. <style scoped>
  86. .vip-page {
  87. padding: 20px;
  88. }
  89. .vip-card {
  90. background: linear-gradient(135deg, #2a5caa 0%, #1a3353 100%);
  91. border-radius: 16px;
  92. padding: 24px;
  93. color: white;
  94. position: relative;
  95. overflow: hidden;
  96. }
  97. .card-header {
  98. display: flex;
  99. justify-content: space-between;
  100. align-items: center;
  101. margin-bottom: 20px;
  102. }
  103. .title {
  104. font-size: 20px;
  105. font-weight: bold;
  106. }
  107. .tag {
  108. background-color: #ffc53d;
  109. color: #1a3353;
  110. padding: 3px 8px;
  111. border-radius: 12px;
  112. font-size: 12px;
  113. }
  114. .privileges {
  115. margin-bottom: 24px;
  116. }
  117. .privilege-item {
  118. display: flex;
  119. align-items: center;
  120. margin-bottom: 10px;
  121. font-size: 15px;
  122. }
  123. .privilege-item text {
  124. margin-left: 8px;
  125. }
  126. .purchase-btn, .renew-btn {
  127. background-color: #ffc53d;
  128. color: #1a3353;
  129. border: none;
  130. border-radius: 24px;
  131. height: 44px;
  132. line-height: 44px;
  133. font-weight: bold;
  134. }
  135. .plan-container {
  136. position: fixed;
  137. bottom: 0;
  138. left: 0;
  139. right: 0;
  140. background-color: #fff;
  141. border-top-left-radius: 24px;
  142. border-top-right-radius: 24px;
  143. padding: 20px;
  144. box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
  145. z-index: 100;
  146. }
  147. .plan-header {
  148. display: flex;
  149. justify-content: space-between;
  150. align-items: center;
  151. margin-bottom: 20px;
  152. }
  153. .plan-title {
  154. font-size: 18px;
  155. font-weight: bold;
  156. }
  157. .plan-list {
  158. display: flex;
  159. justify-content: space-between;
  160. margin-bottom: 24px;
  161. }
  162. .plan-item {
  163. border: 1px solid #eee;
  164. border-radius: 12px;
  165. padding: 15px;
  166. width: 30%;
  167. text-align: center;
  168. }
  169. .plan-item.recommended {
  170. border-color: #2a5caa;
  171. background-color: #e6f7ff;
  172. position: relative;
  173. }
  174. .rec-tag {
  175. position: absolute;
  176. top: -10px;
  177. right: 10px;
  178. background-color: #2a5caa;
  179. color: white;
  180. font-size: 12px;
  181. padding: 2px 8px;
  182. border-radius: 10px;
  183. }
  184. .plan-top {
  185. display: flex;
  186. flex-direction: column;
  187. align-items: center;
  188. margin-bottom: 10px;
  189. }
  190. .duration {
  191. font-size: 16px;
  192. font-weight: bold;
  193. }
  194. .price {
  195. display: flex;
  196. justify-content: center;
  197. align-items: baseline;
  198. margin-bottom: 5px;
  199. }
  200. .symbol {
  201. font-size: 16px;
  202. color: #f5222d;
  203. }
  204. .amount {
  205. font-size: 24px;
  206. font-weight: bold;
  207. color: #f5222d;
  208. margin: 0 3px;
  209. }
  210. .original {
  211. font-size: 12px;
  212. color: #999;
  213. text-decoration: line-through;
  214. }
  215. .daily {
  216. font-size: 12px;
  217. color: #666;
  218. }
  219. .confirm-btn {
  220. background: linear-gradient(to right, #2a5caa, #1a3353);
  221. color: white;
  222. border: none;
  223. border-radius: 24px;
  224. height: 44px;
  225. line-height: 44px;
  226. font-weight: bold;
  227. }
  228. </style>