index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view class="page-payment">
  3. <view class="header">
  4. <text class="header-title">{{ pageTitle }}</text>
  5. <text class="header-desc">{{ pageDesc }}</text>
  6. </view>
  7. <template v-if="loading">
  8. <view class="loading-state"><text class="loading-text">加载中...</text></view>
  9. </template>
  10. <template v-else-if="product === 'annual'">
  11. <!-- C端年费 ¥131 -->
  12. <view class="plan-card selected">
  13. <view class="plan-badge popular">推荐</view>
  14. <view class="plan-top">
  15. <text class="plan-name">C端会员</text>
  16. <view class="plan-price-row">
  17. <text class="price-symbol">¥</text>
  18. <text class="price">{{ formatYuan(pricing.annualFee) }}</text>
  19. <text class="per">/年</text>
  20. </view>
  21. <text class="price-daily">每天仅 ¥{{ (pricing.annualFee / 100 / 365).toFixed(2) }}</text>
  22. </view>
  23. <view class="plan-features">
  24. <text class="feature">✦ AI 互动问答 — 无限次</text>
  25. <text class="feature">✦ 获得推广权限,赚取佣金</text>
  26. <text class="feature">✦ 一级 40% + 二级 5% 佣金比例</text>
  27. <text class="feature">✦ VIP 标识</text>
  28. </view>
  29. </view>
  30. <button class="pay-btn" @click="onPay" :disabled="paying">
  31. {{ paying ? '处理中...' : `立即开通 · C端会员 ¥${formatYuan(pricing.annualFee)}/年` }}
  32. </button>
  33. </template>
  34. <template v-else-if="product === 'practitioner'">
  35. <!-- 能量师 种子价/标准价 -->
  36. <view class="plan-card plan-pro selected">
  37. <view class="plan-badge pro">专业</view>
  38. <view class="plan-top">
  39. <text class="plan-name">能量师</text>
  40. <view class="plan-price-row">
  41. <text class="price-symbol">¥</text>
  42. <text class="price">{{ formatYuan(currentPrice) }}</text>
  43. <text class="per">/年</text>
  44. </view>
  45. <view v-if="pricing.isSeedPrice" class="seed-badge">
  46. 种子价 · 仅剩 {{ pricing.remainingSeats }}/{{ pricing.seedLimit }} 个名额
  47. </view>
  48. <text v-else class="standard-label">标准定价</text>
  49. <text class="price-daily">每天仅 ¥{{ (currentPrice / 100 / 365).toFixed(2) }}</text>
  50. </view>
  51. <view class="plan-features">
  52. <text class="feature">✦ 包含 C 端全部权益</text>
  53. <text class="feature">✦ 无限命盘生成</text>
  54. <text class="feature">✦ AI 五区完整解读,随问随答</text>
  55. <text class="feature">✦ 全部历史记录永久保存</text>
  56. <text class="feature">✦ 推广佣金 — 固定 ¥500/人 + 二级 ¥100/人</text>
  57. </view>
  58. </view>
  59. <button class="pay-btn pro-btn" @click="onPay" :disabled="paying">
  60. {{ paying ? '处理中...' : `立即开通 · 能量师 ${priceLabel} ¥${formatYuan(currentPrice)}/年` }}
  61. </button>
  62. </template>
  63. <text class="note">支付即表示同意《订阅协议》</text>
  64. </view>
  65. </template>
  66. <script setup>
  67. import { ref, computed, onMounted } from 'vue'
  68. import { payApi, pricingApi } from '@/utils/api'
  69. const paying = ref(false)
  70. const loading = ref(true)
  71. const product = ref('annual')
  72. const pricing = ref({
  73. seedPrice: 131400,
  74. standardPrice: 198600,
  75. annualFee: 13100,
  76. isSeedPrice: true,
  77. remainingSeats: 300,
  78. seedLimit: 300
  79. })
  80. const pageTitle = computed(() => {
  81. return product.value === 'annual' ? 'C端会员' : '能量师专业版'
  82. })
  83. const pageDesc = computed(() => {
  84. return product.value === 'annual' ? '解锁无限AI解读,获取推广佣金' : '获取完整命盘分析、AI解读与分销推广权限'
  85. })
  86. const currentPrice = computed(() => {
  87. if (product.value === 'annual') return pricing.value.annualFee
  88. return pricing.value.isSeedPrice ? pricing.value.seedPrice : pricing.value.standardPrice
  89. })
  90. const priceLabel = computed(() => {
  91. return pricing.value.isSeedPrice ? '种子价' : '标准价'
  92. })
  93. function formatYuan(cents) {
  94. if (cents == null) return '0'
  95. return (cents / 100).toLocaleString()
  96. }
  97. onMounted(async () => {
  98. // Read product param from URL
  99. const pages = getCurrentPages()
  100. const page = pages[pages.length - 1]
  101. const params = page?.options || {}
  102. product.value = params.product || 'annual'
  103. try {
  104. const res = await pricingApi.current()
  105. if (res) pricing.value = res
  106. } catch (e) {
  107. // Use defaults if API fails
  108. }
  109. loading.value = false
  110. })
  111. async function onPay() {
  112. paying.value = true
  113. try {
  114. const totalFee = currentPrice.value
  115. const productType = product.value
  116. await payApi.create({ totalFee, payType: 'wxpay', productType })
  117. uni.showToast({ title: '开通成功!', icon: 'success' })
  118. setTimeout(() => uni.navigateBack(), 1500)
  119. } catch (e) {
  120. uni.showToast({ title: '支付失败,请重试', icon: 'none' })
  121. }
  122. paying.value = false
  123. }
  124. </script>
  125. <style scoped lang="scss">
  126. .page-payment {
  127. padding: 20px;
  128. min-height: 100vh;
  129. background: linear-gradient(180deg, #0c0a1a 0%, #120d28 60%, #0f0c1e 100%);
  130. }
  131. .header {
  132. text-align: center;
  133. margin-bottom: 20px;
  134. }
  135. .header-title {
  136. font-size: 22px;
  137. font-weight: 700;
  138. color: rgba(255,255,255,0.9);
  139. display: block;
  140. }
  141. .header-desc {
  142. font-size: 13px;
  143. color: rgba(255,255,255,0.4);
  144. margin-top: 6px;
  145. display: block;
  146. }
  147. .loading-state {
  148. padding: 60px 0;
  149. text-align: center;
  150. }
  151. .loading-text {
  152. font-size: 14px;
  153. color: rgba(255,255,255,0.3);
  154. }
  155. /* Plan Cards */
  156. .plan-card {
  157. position: relative;
  158. background: rgba(255,255,255,0.03);
  159. border: 1px solid rgba(255,255,255,0.08);
  160. border-radius: 16px;
  161. padding: 22px 18px 18px;
  162. margin-bottom: 12px;
  163. }
  164. .plan-card.selected {
  165. border-color: #fbbf24;
  166. background: rgba(251,191,36,0.06);
  167. }
  168. .plan-card.plan-pro.selected {
  169. border-color: #a78bfa;
  170. background: rgba(167,139,250,0.06);
  171. }
  172. .plan-badge {
  173. position: absolute;
  174. top: -1px;
  175. right: 20px;
  176. font-size: 11px;
  177. font-weight: 600;
  178. padding: 3px 14px;
  179. border-radius: 0 0 8px 8px;
  180. }
  181. .plan-badge.popular {
  182. background: #f59e0b;
  183. color: #fff;
  184. }
  185. .plan-badge.pro {
  186. background: #7c3aed;
  187. color: #fff;
  188. }
  189. .plan-top { text-align: center; }
  190. .plan-name {
  191. font-size: 17px;
  192. font-weight: 600;
  193. color: rgba(255,255,255,0.85);
  194. display: block;
  195. margin-bottom: 10px;
  196. }
  197. .plan-price-row {
  198. display: flex;
  199. align-items: baseline;
  200. justify-content: center;
  201. }
  202. .price-symbol {
  203. font-size: 20px;
  204. color: #fbbf24;
  205. font-weight: 600;
  206. }
  207. .price {
  208. font-size: 38px;
  209. font-weight: 700;
  210. color: #fbbf24;
  211. margin: 0 2px;
  212. }
  213. .plan-pro .price-symbol,
  214. .plan-pro .price {
  215. color: #a78bfa;
  216. }
  217. .per {
  218. font-size: 14px;
  219. color: rgba(255,255,255,0.4);
  220. }
  221. .price-daily {
  222. display: block;
  223. font-size: 12px;
  224. color: rgba(255,255,255,0.3);
  225. margin-top: 4px;
  226. }
  227. .seed-badge {
  228. display: inline-block;
  229. margin-top: 6px;
  230. font-size: 11px;
  231. color: #fbbf24;
  232. background: rgba(251,191,36,0.12);
  233. padding: 2px 12px;
  234. border-radius: 4px;
  235. }
  236. .standard-label {
  237. display: inline-block;
  238. margin-top: 6px;
  239. font-size: 11px;
  240. color: rgba(255,255,255,0.35);
  241. padding: 2px 12px;
  242. border-radius: 4px;
  243. border: 1px solid rgba(255,255,255,0.1);
  244. }
  245. .plan-features {
  246. margin-top: 16px;
  247. }
  248. .feature {
  249. display: block;
  250. padding: 5px 0;
  251. font-size: 13px;
  252. color: rgba(255,255,255,0.6);
  253. line-height: 1.5;
  254. }
  255. .plan-card.selected .feature {
  256. color: rgba(255,255,255,0.8);
  257. }
  258. .pay-btn {
  259. width: 100%;
  260. padding: 16px;
  261. background: linear-gradient(135deg, #f59e0b, #d97706);
  262. color: #fff;
  263. border: none;
  264. border-radius: 14px;
  265. font-size: 17px;
  266. font-weight: 600;
  267. letter-spacing: 2px;
  268. margin-bottom: 8px;
  269. }
  270. .pay-btn.pro-btn {
  271. background: linear-gradient(135deg, #7c3aed, #6d28d9);
  272. }
  273. .pay-btn[disabled] { opacity: 0.4; }
  274. .note {
  275. display: block;
  276. text-align: center;
  277. font-size: 12px;
  278. color: rgba(255,255,255,0.25);
  279. }
  280. </style>