index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. <!-- US-4.4 Upgrade breakdown -->
  50. <view v-if="isUpgrade" class="upgrade-info">
  51. <view class="upgrade-row">
  52. <text class="upgrade-label">原年费金额</text>
  53. <text class="upgrade-value">¥{{ formatYuan(pricing.originalPaidAmount) }}</text>
  54. </view>
  55. <view class="upgrade-row">
  56. <text class="upgrade-label">年费剩余价值</text>
  57. <text class="upgrade-value minus">-¥{{ formatYuan(pricing.remainingValue) }}</text>
  58. </view>
  59. <view class="upgrade-row total">
  60. <text class="upgrade-label">应付差价</text>
  61. <text class="upgrade-value highlight">¥{{ formatYuan(pricing.upgradePrice) }}</text>
  62. </view>
  63. </view>
  64. <text class="price-daily">每天仅 ¥{{ (currentPrice / 100 / 365).toFixed(2) }}</text>
  65. </view>
  66. <view class="plan-features">
  67. <text class="feature">✦ 包含 C 端全部权益</text>
  68. <text class="feature">✦ 无限命盘生成</text>
  69. <text class="feature">✦ AI 五区完整解读,随问随答</text>
  70. <text class="feature">✦ 全部历史记录永久保存</text>
  71. <text class="feature">✦ 推广佣金 — 固定 ¥500/人 + 二级 ¥100/人</text>
  72. </view>
  73. </view>
  74. <button class="pay-btn pro-btn" @click="onPay" :disabled="paying">
  75. {{ paying ? '处理中...' : `立即开通 · 能量师 ${priceLabel} ¥${formatYuan(currentPrice)}/年` }}
  76. </button>
  77. </template>
  78. <text class="note">支付即表示同意《订阅协议》</text>
  79. </view>
  80. </template>
  81. <script setup>
  82. import { ref, computed, onMounted } from 'vue'
  83. import { useUserStore } from '@/stores/user'
  84. import { payApi, pricingApi } from '@/utils/api'
  85. const userStore = useUserStore()
  86. const paying = ref(false)
  87. const loading = ref(true)
  88. const product = ref('annual')
  89. const isUpgrade = ref(false)
  90. const pricing = ref({
  91. seedPrice: 131400,
  92. standardPrice: 198600,
  93. annualFee: 13100,
  94. isSeedPrice: true,
  95. remainingSeats: 300,
  96. seedLimit: 300
  97. })
  98. const pageTitle = computed(() => {
  99. return product.value === 'annual' ? 'C端会员' : '能量师专业版'
  100. })
  101. const pageDesc = computed(() => {
  102. return product.value === 'annual' ? '解锁无限AI解读,获取推广佣金' : '获取完整命盘分析、AI解读与分销推广权限'
  103. })
  104. const currentPrice = computed(() => {
  105. if (product.value === 'annual') return pricing.value.annualFee
  106. if (isUpgrade.value) return pricing.value.upgradePrice
  107. return pricing.value.isSeedPrice ? pricing.value.seedPrice : pricing.value.standardPrice
  108. })
  109. const priceLabel = computed(() => {
  110. if (isUpgrade.value) return '升级价'
  111. return pricing.value.isSeedPrice ? '种子价' : '标准价'
  112. })
  113. function formatYuan(cents) {
  114. if (cents == null) return '0'
  115. return (cents / 100).toLocaleString()
  116. }
  117. onMounted(async () => {
  118. // Ensure user profile is loaded (vipType, etc.)
  119. try {
  120. await userStore.fetchProfile()
  121. } catch (e) {
  122. // ignore, use cached
  123. }
  124. // Read product param from URL
  125. const pages = getCurrentPages()
  126. const page = pages[pages.length - 1]
  127. const params = page?.options || {}
  128. product.value = params.product || 'annual'
  129. // Determine upgrade scenario: annual member upgrading to practitioner
  130. if (product.value === 'practitioner' && userStore.vipType === 'annual') {
  131. isUpgrade.value = true
  132. try {
  133. const res = await pricingApi.upgrade()
  134. if (res) pricing.value = { ...pricing.value, ...res }
  135. } catch (e) {
  136. // Fallback to normal pricing on error
  137. isUpgrade.value = false
  138. }
  139. }
  140. if (!isUpgrade.value) {
  141. try {
  142. const res = await pricingApi.current()
  143. if (res) pricing.value = res
  144. } catch (e) {
  145. // Use defaults if API fails
  146. }
  147. }
  148. loading.value = false
  149. })
  150. async function onPay() {
  151. paying.value = true
  152. try {
  153. const totalFee = currentPrice.value
  154. const productType = product.value
  155. await payApi.create({
  156. totalFee,
  157. payType: 'wxpay',
  158. productType,
  159. isUpgrade: isUpgrade.value
  160. })
  161. uni.showToast({ title: '开通成功!', icon: 'success' })
  162. setTimeout(() => uni.navigateBack(), 1500)
  163. } catch (e) {
  164. uni.showToast({ title: '支付失败,请重试', icon: 'none' })
  165. }
  166. paying.value = false
  167. }
  168. </script>
  169. <style scoped lang="scss">
  170. .page-payment {
  171. padding: 20px;
  172. min-height: 100vh;
  173. background: linear-gradient(180deg, #0c0a1a 0%, #120d28 60%, #0f0c1e 100%);
  174. }
  175. .header {
  176. text-align: center;
  177. margin-bottom: 20px;
  178. }
  179. .header-title {
  180. font-size: 22px;
  181. font-weight: 700;
  182. color: rgba(255,255,255,0.9);
  183. display: block;
  184. }
  185. .header-desc {
  186. font-size: 13px;
  187. color: rgba(255,255,255,0.4);
  188. margin-top: 6px;
  189. display: block;
  190. }
  191. .loading-state {
  192. padding: 60px 0;
  193. text-align: center;
  194. }
  195. .loading-text {
  196. font-size: 14px;
  197. color: rgba(255,255,255,0.3);
  198. }
  199. /* Plan Cards */
  200. .plan-card {
  201. position: relative;
  202. background: rgba(255,255,255,0.03);
  203. border: 1px solid rgba(255,255,255,0.08);
  204. border-radius: 16px;
  205. padding: 22px 18px 18px;
  206. margin-bottom: 12px;
  207. }
  208. .plan-card.selected {
  209. border-color: #fbbf24;
  210. background: rgba(251,191,36,0.06);
  211. }
  212. .plan-card.plan-pro.selected {
  213. border-color: #a78bfa;
  214. background: rgba(167,139,250,0.06);
  215. }
  216. .plan-badge {
  217. position: absolute;
  218. top: -1px;
  219. right: 20px;
  220. font-size: 11px;
  221. font-weight: 600;
  222. padding: 3px 14px;
  223. border-radius: 0 0 8px 8px;
  224. }
  225. .plan-badge.popular {
  226. background: #f59e0b;
  227. color: #fff;
  228. }
  229. .plan-badge.pro {
  230. background: #7c3aed;
  231. color: #fff;
  232. }
  233. .plan-top { text-align: center; }
  234. .plan-name {
  235. font-size: 17px;
  236. font-weight: 600;
  237. color: rgba(255,255,255,0.85);
  238. display: block;
  239. margin-bottom: 10px;
  240. }
  241. .plan-price-row {
  242. display: flex;
  243. align-items: baseline;
  244. justify-content: center;
  245. }
  246. .price-symbol {
  247. font-size: 20px;
  248. color: #fbbf24;
  249. font-weight: 600;
  250. }
  251. .price {
  252. font-size: 38px;
  253. font-weight: 700;
  254. color: #fbbf24;
  255. margin: 0 2px;
  256. }
  257. .plan-pro .price-symbol,
  258. .plan-pro .price {
  259. color: #a78bfa;
  260. }
  261. .per {
  262. font-size: 14px;
  263. color: rgba(255,255,255,0.4);
  264. }
  265. .price-daily {
  266. display: block;
  267. font-size: 12px;
  268. color: rgba(255,255,255,0.3);
  269. margin-top: 4px;
  270. }
  271. .seed-badge {
  272. display: inline-block;
  273. margin-top: 6px;
  274. font-size: 11px;
  275. color: #fbbf24;
  276. background: rgba(251,191,36,0.12);
  277. padding: 2px 12px;
  278. border-radius: 4px;
  279. }
  280. .standard-label {
  281. display: inline-block;
  282. margin-top: 6px;
  283. font-size: 11px;
  284. color: rgba(255,255,255,0.35);
  285. padding: 2px 12px;
  286. border-radius: 4px;
  287. border: 1px solid rgba(255,255,255,0.1);
  288. }
  289. /* US-4.4 Upgrade breakdown */
  290. .upgrade-info {
  291. margin-top: 12px;
  292. padding: 10px 12px;
  293. background: rgba(255,255,255,0.04);
  294. border-radius: 8px;
  295. border: 1px dashed rgba(255,255,255,0.15);
  296. }
  297. .upgrade-row {
  298. display: flex;
  299. justify-content: space-between;
  300. align-items: center;
  301. font-size: 13px;
  302. margin-bottom: 6px;
  303. }
  304. .upgrade-row:last-child {
  305. margin-bottom: 0;
  306. }
  307. .upgrade-row.total {
  308. margin-top: 6px;
  309. padding-top: 6px;
  310. border-top: 1px solid rgba(255,255,255,0.1);
  311. }
  312. .upgrade-label {
  313. color: rgba(255,255,255,0.5);
  314. }
  315. .upgrade-value {
  316. color: rgba(255,255,255,0.9);
  317. font-weight: 500;
  318. }
  319. .upgrade-value.minus {
  320. color: #fbbf24;
  321. }
  322. .upgrade-value.highlight {
  323. color: #a78bfa;
  324. font-weight: 600;
  325. }
  326. .plan-features {
  327. margin-top: 16px;
  328. }
  329. .feature {
  330. display: block;
  331. padding: 5px 0;
  332. font-size: 13px;
  333. color: rgba(255,255,255,0.6);
  334. line-height: 1.5;
  335. }
  336. .plan-card.selected .feature {
  337. color: rgba(255,255,255,0.8);
  338. }
  339. .pay-btn {
  340. width: 100%;
  341. padding: 16px;
  342. background: linear-gradient(135deg, #f59e0b, #d97706);
  343. color: #fff;
  344. border: none;
  345. border-radius: 14px;
  346. font-size: 17px;
  347. font-weight: 600;
  348. letter-spacing: 2px;
  349. margin-bottom: 8px;
  350. }
  351. .pay-btn.pro-btn {
  352. background: linear-gradient(135deg, #7c3aed, #6d28d9);
  353. }
  354. .pay-btn[disabled] { opacity: 0.4; }
  355. .note {
  356. display: block;
  357. text-align: center;
  358. font-size: 12px;
  359. color: rgba(255,255,255,0.25);
  360. }
  361. </style>