index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <view class="page-relations">
  3. <!-- ========== Super Member Guard ========== -->
  4. <view v-if="!isSuperMember" class="locked-screen">
  5. <view class="locked-icon-wrap">
  6. <text class="locked-icon">🔒</text>
  7. </view>
  8. <text class="locked-title">超级会员专属</text>
  9. <text class="locked-desc">开通超级会员后可进行夫妻、亲子、同事等关系能量匹配分析</text>
  10. <view class="locked-features">
  11. <view class="locked-feature">🔗 关系能量合盘对比</view>
  12. <view class="locked-feature">🔢 八星号码能量解读</view>
  13. <view class="locked-feature">📊 AI 深度解读报告</view>
  14. </view>
  15. <view class="btn-upgrade" @click="goSubscribe">
  16. <text class="btn-upgrade-text">开通超级会员 ¥1,314/年</text>
  17. </view>
  18. <view class="btn-back" @click="goBack">
  19. <text class="btn-back-text">返回首页</text>
  20. </view>
  21. </view>
  22. <!-- ========== Authorized Content ========== -->
  23. <template v-else>
  24. <!-- Upsell banner: annual → super member upgrade -->
  25. <view v-if="showUpgradeBanner" class="upsell-banner">
  26. <text class="upsell-banner__text">升级超级会员,解锁关系能量 + 八星号码分析</text>
  27. <text class="upsell-banner__btn" @click="goSubscribe">升级</text>
  28. </view>
  29. <!-- Header bar -->
  30. <view class="header-bar">
  31. <text class="header-title">关系能量分析</text>
  32. <view class="btn-add" @click="goAddRelation">
  33. <text class="btn-add-text">+ 添加</text>
  34. </view>
  35. </view>
  36. <!-- Loading state -->
  37. <view v-if="loading" class="loading-state">
  38. <view v-for="i in 3" :key="i" class="skeleton-card" />
  39. </view>
  40. <!-- Empty state -->
  41. <view v-else-if="relations.length === 0" class="empty-state">
  42. <view class="empty-icon-wrap">
  43. <text class="empty-icon-symbol">+</text>
  44. </view>
  45. <text class="empty-text">暂无关系人</text>
  46. <text class="empty-desc">添加关系人后,可进行夫妻、亲子、同事等关系能量匹配分析</text>
  47. <view class="btn-empty-add" @click="goAddRelation">
  48. <text class="btn-empty-add-text">添加关系人</text>
  49. </view>
  50. </view>
  51. <!-- Relations list -->
  52. <view v-else class="relations-list">
  53. <text class="section-count">我的关系人 ({{ relations.length }})</text>
  54. <view
  55. v-for="item in relations"
  56. :key="item.id"
  57. class="relation-card"
  58. >
  59. <view class="card-header">
  60. <view class="type-tag">
  61. <text class="type-tag-text">{{ relationTypeLabel(item.relationType) }}</text>
  62. </view>
  63. </view>
  64. <view class="card-body">
  65. <text class="card-name">{{ item.name || '未知' }}</text>
  66. <text class="card-birth">{{ item.birthDate || '' }}</text>
  67. </view>
  68. <view class="card-footer">
  69. <view class="action-btn action-compare" @click="goCompare(item.id)">对比分析</view>
  70. <view class="action-btn action-edit" @click="goEdit(item.id)">编辑</view>
  71. <view class="action-btn action-delete" @click="handleDelete(item.id)">删除</view>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. </view>
  77. </template>
  78. <script setup>
  79. import { ref, computed } from 'vue'
  80. import { onShow } from '@dcloudio/uni-app'
  81. import { useUserStore } from '@/stores/user'
  82. import requestInstance from '@/utils/api'
  83. const userStore = useUserStore()
  84. const relations = ref([])
  85. const loading = ref(false)
  86. const isSuperMember = computed(() => {
  87. if (!userStore.isVip) return false
  88. return userStore.vipType === 'super_annual' || userStore.vipType === 'practitioner'
  89. })
  90. const showUpgradeBanner = computed(() => {
  91. // Show upgrade prompt for annual members who aren't super yet
  92. return userStore.isVip && userStore.vipType === 'annual'
  93. })
  94. const relationApi = {
  95. list: (data) => requestInstance.post('/relation/list', data),
  96. delete: (id) => requestInstance.post('/relation/delete', { id })
  97. }
  98. const relationTypeMap = {
  99. spouse: '夫妻',
  100. parent_child: '亲子',
  101. colleague: '同事',
  102. friend: '朋友',
  103. superior: '上下级'
  104. }
  105. function relationTypeLabel(type) {
  106. return relationTypeMap[type] || type || '未知'
  107. }
  108. onShow(() => {
  109. if (userStore.isLoggedIn) {
  110. userStore.fetchProfile()
  111. }
  112. if (isSuperMember.value) {
  113. fetchRelations()
  114. }
  115. })
  116. async function fetchRelations() {
  117. loading.value = true
  118. try {
  119. relations.value = await relationApi.list({})
  120. } catch (e) {
  121. relations.value = []
  122. } finally {
  123. loading.value = false
  124. }
  125. }
  126. function goAddRelation() {
  127. uni.navigateTo({ url: '/pages/relations/add-relation' })
  128. }
  129. function goCompare(id) {
  130. uni.navigateTo({ url: '/pages/relations/chart-compare?id=' + id })
  131. }
  132. function goEdit(id) {
  133. uni.navigateTo({ url: '/pages/relations/add-relation?id=' + id })
  134. }
  135. function goSubscribe() {
  136. uni.navigateTo({ url: '/pages/payment/index?product=super_member' })
  137. }
  138. function goBack() {
  139. uni.switchTab({ url: '/pages/index/index' })
  140. }
  141. function handleDelete(id) {
  142. uni.showModal({
  143. title: '确认删除',
  144. content: '删除后无法恢复,确定要删除该关系人吗?',
  145. success: async (res) => {
  146. if (res.confirm) {
  147. try {
  148. await relationApi.delete(id)
  149. uni.showToast({ title: '删除成功', icon: 'success' })
  150. fetchRelations()
  151. } catch (e) {
  152. uni.showToast({ title: '删除失败', icon: 'none' })
  153. }
  154. }
  155. }
  156. })
  157. }
  158. </script>
  159. <style scoped lang="scss">
  160. @import "@/styles/theme.scss";
  161. .page-relations {
  162. min-height: 100vh;
  163. background: var(--color-bg);
  164. padding: 16px;
  165. }
  166. /* Header */
  167. .header-bar {
  168. display: flex;
  169. align-items: center;
  170. justify-content: space-between;
  171. margin-bottom: 20px;
  172. }
  173. .header-title {
  174. font-size: 20px;
  175. font-weight: 700;
  176. color: var(--color-text-primary);
  177. letter-spacing: 0.5px;
  178. }
  179. .btn-add {
  180. background: var(--color-gold);
  181. border-radius: 999px;
  182. padding: 8px 18px;
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. }
  187. .btn-add:active {
  188. transform: scale(0.97);
  189. opacity: 0.9;
  190. }
  191. .btn-add-text {
  192. color: var(--color-bg-card);
  193. font-size: 14px;
  194. font-weight: 600;
  195. }
  196. /* Section count */
  197. .section-count {
  198. display: block;
  199. font-size: 13px;
  200. color: var(--color-text-secondary);
  201. margin-bottom: 12px;
  202. padding-left: 2px;
  203. }
  204. /* Loading skeleton */
  205. .loading-state {
  206. display: flex;
  207. flex-direction: column;
  208. gap: 12px;
  209. }
  210. .skeleton-card {
  211. height: 120px;
  212. background: linear-gradient(90deg, var(--color-bg-secondary) 25%, var(--color-bg) 50%, var(--color-bg-secondary) 75%);
  213. background-size: 400px 100%;
  214. animation: shimmer 1.5s ease-in-out infinite;
  215. border-radius: 16px;
  216. }
  217. @keyframes shimmer {
  218. 0% { background-position: -200px 0; }
  219. 100% { background-position: 200px 0; }
  220. }
  221. /* Empty state */
  222. .empty-state {
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. padding-top: 60px;
  227. }
  228. .empty-icon-wrap {
  229. width: 64px;
  230. height: 64px;
  231. border-radius: 50%;
  232. background: var(--color-bg-secondary);
  233. display: flex;
  234. align-items: center;
  235. justify-content: center;
  236. margin-bottom: 16px;
  237. }
  238. .empty-icon-symbol {
  239. font-size: 28px;
  240. color: var(--color-text-secondary);
  241. font-weight: 300;
  242. }
  243. .empty-text {
  244. font-size: 16px;
  245. font-weight: 600;
  246. color: var(--color-text-primary);
  247. margin-bottom: 8px;
  248. }
  249. .empty-desc {
  250. font-size: 13px;
  251. color: var(--color-text-secondary);
  252. text-align: center;
  253. line-height: 1.6;
  254. max-width: 260px;
  255. margin-bottom: 24px;
  256. }
  257. .btn-empty-add {
  258. background: var(--color-brand);
  259. border-radius: 12px;
  260. padding: 12px 32px;
  261. }
  262. .btn-empty-add:active {
  263. transform: scale(0.97);
  264. opacity: 0.9;
  265. }
  266. .btn-empty-add-text {
  267. color: var(--color-bg-card);
  268. font-size: 15px;
  269. font-weight: 600;
  270. }
  271. /* Relation cards */
  272. .relations-list {
  273. display: flex;
  274. flex-direction: column;
  275. }
  276. .relation-card {
  277. background: var(--color-bg-card);
  278. border-radius: 16px;
  279. padding: 16px;
  280. margin-bottom: 12px;
  281. box-shadow: var(--shadow-card);
  282. }
  283. .card-header {
  284. margin-bottom: 10px;
  285. }
  286. .type-tag {
  287. display: inline-flex;
  288. align-items: center;
  289. background: #EBF2FA;
  290. border-radius: 6px;
  291. padding: 3px 10px;
  292. }
  293. .type-tag-text {
  294. font-size: 12px;
  295. font-weight: 500;
  296. color: var(--color-brand);
  297. }
  298. .card-body {
  299. margin-bottom: 12px;
  300. }
  301. .card-name {
  302. display: block;
  303. font-size: 16px;
  304. font-weight: 600;
  305. color: var(--color-text-primary);
  306. margin-bottom: 4px;
  307. }
  308. .card-birth {
  309. display: block;
  310. font-size: 13px;
  311. color: var(--color-text-secondary);
  312. }
  313. .card-footer {
  314. display: flex;
  315. gap: 10px;
  316. border-top: 1px solid var(--color-border);
  317. padding-top: 12px;
  318. }
  319. .action-btn {
  320. font-size: 13px;
  321. font-weight: 500;
  322. padding: 6px 14px;
  323. border-radius: 8px;
  324. flex: 1;
  325. text-align: center;
  326. }
  327. .action-btn:active {
  328. transform: scale(0.97);
  329. opacity: 0.9;
  330. }
  331. .action-compare {
  332. background: var(--color-brand);
  333. color: var(--color-bg-card);
  334. }
  335. .action-edit {
  336. background: var(--color-bg-card);
  337. border: 1px solid var(--color-border);
  338. color: var(--color-text-secondary);
  339. }
  340. .action-delete {
  341. background: var(--color-bg-card);
  342. border: 1px solid var(--color-border);
  343. color: #D94A4A;
  344. }
  345. /* ========== Upsell Banner ========== */
  346. .upsell-banner {
  347. background: linear-gradient(135deg, var(--color-brand), darken(var(--color-brand), 4%));
  348. border-radius: 14px;
  349. padding: 14px 16px;
  350. margin-bottom: 16px;
  351. display: flex;
  352. align-items: center;
  353. justify-content: space-between;
  354. gap: 10px;
  355. }
  356. .upsell-banner__text {
  357. font-size: 13px;
  358. color: rgba(255, 255, 255, 0.85);
  359. flex: 1;
  360. line-height: 1.4;
  361. }
  362. .upsell-banner__btn {
  363. flex-shrink: 0;
  364. background: var(--color-gold);
  365. color: var(--color-brand);
  366. font-size: 13px;
  367. font-weight: 700;
  368. padding: 8px 16px;
  369. border-radius: 8px;
  370. }
  371. .upsell-banner__btn:active {
  372. transform: scale(0.97);
  373. }
  374. /* ========== Locked Screen ========== */
  375. .locked-screen {
  376. display: flex;
  377. flex-direction: column;
  378. align-items: center;
  379. padding-top: 80px;
  380. padding-bottom: 40px;
  381. }
  382. .locked-icon-wrap {
  383. width: 80px;
  384. height: 80px;
  385. border-radius: 50%;
  386. background: var(--color-bg-secondary);
  387. display: flex;
  388. align-items: center;
  389. justify-content: center;
  390. margin-bottom: 20px;
  391. }
  392. .locked-icon {
  393. font-size: 36px;
  394. }
  395. .locked-title {
  396. font-size: 20px;
  397. font-weight: 700;
  398. color: var(--color-text-primary);
  399. margin-bottom: 10px;
  400. }
  401. .locked-desc {
  402. font-size: 14px;
  403. color: var(--color-text-secondary);
  404. text-align: center;
  405. line-height: 1.6;
  406. max-width: 280px;
  407. margin-bottom: 28px;
  408. }
  409. .locked-features {
  410. display: flex;
  411. flex-direction: column;
  412. gap: 12px;
  413. margin-bottom: 32px;
  414. }
  415. .locked-feature {
  416. font-size: 15px;
  417. color: var(--color-text-secondary);
  418. }
  419. .btn-upgrade {
  420. width: 80%;
  421. height: 50px;
  422. background: linear-gradient(135deg, var(--color-brand), darken(var(--color-brand), 4%));
  423. border-radius: 14px;
  424. display: flex;
  425. align-items: center;
  426. justify-content: center;
  427. margin-bottom: 16px;
  428. }
  429. .btn-upgrade:active {
  430. transform: scale(0.97);
  431. opacity: 0.9;
  432. }
  433. .btn-upgrade-text {
  434. color: var(--color-bg-card);
  435. font-size: 17px;
  436. font-weight: 700;
  437. }
  438. .btn-back {
  439. padding: 10px 20px;
  440. }
  441. .btn-back:active {
  442. opacity: 0.7;
  443. }
  444. .btn-back-text {
  445. font-size: 14px;
  446. color: var(--color-text-secondary);
  447. }
  448. </style>