index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. <template>
  2. <view class="astrology-page">
  3. <!-- 自定义顶部导航栏 -->
  4. <view class="custom-nav">
  5. <view class="nav-left" @click="goBack">
  6. <text class="back-icon">←</text>
  7. </view>
  8. <view class="nav-title">星命运算</view>
  9. <view class="nav-right">
  10. <text class="menu-icon">⋯</text>
  11. </view>
  12. </view>
  13. <!-- 测算卡片区域 -->
  14. <view class="cards-section">
  15. <view class="card-item" v-for="(card, index) in cardList" :key="index" @click="handleCardClick(card)">
  16. <view class="card-icon">{{ card.icon }}</view>
  17. <view class="card-name">{{ card.name }}</view>
  18. <view class="card-desc">{{ card.desc }}</view>
  19. </view>
  20. </view>
  21. <!-- 星座配对测试 -->
  22. <view class="match-test-banner" @click="handleConstellationMatch">
  23. <view class="match-banner-content">
  24. <view class="match-icon-group">
  25. <text class="match-icon">💫</text>
  26. </view>
  27. <view class="match-text-group">
  28. <view class="match-title">星座配对测试</view>
  29. <view class="match-subtitle">测测你们的星座匹配度有多高</view>
  30. </view>
  31. <view class="match-arrow">→</view>
  32. </view>
  33. <view class="match-stats">
  34. <text class="match-stats-text">💕 今日已有 {{ matchTestCount }} 对情侣测试</text>
  35. </view>
  36. </view>
  37. <!-- 我的爱情运势 -->
  38. <view class="love-fortune">
  39. <view class="section-title">
  40. <text class="title-text">❤️ 我的爱情运势</text>
  41. <text class="title-date">{{ todayDate }}</text>
  42. </view>
  43. <view class="fortune-cards">
  44. <view class="fortune-card" v-for="(item, index) in loveFortune" :key="index">
  45. <view class="fortune-icon" :style="{background: item.color}">
  46. <text class="fortune-emoji">{{ item.icon }}</text>
  47. </view>
  48. <view class="fortune-info">
  49. <text class="fortune-label">{{ item.label }}</text>
  50. <view class="fortune-score">
  51. <view class="score-bar">
  52. <view class="score-fill" :style="{width: item.score + '%', background: item.color}"></view>
  53. </view>
  54. <text class="score-text">{{ item.score }}%</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 本周脱单指数 -->
  61. <view class="single-index">
  62. <view class="section-title">
  63. <text class="title-text">📊 本周脱单指数</text>
  64. </view>
  65. <view class="index-card">
  66. <view class="index-header">
  67. <view class="index-score-wrapper">
  68. <text class="index-score">{{ singleIndex.score }}</text>
  69. <text class="index-unit">分</text>
  70. </view>
  71. <view class="index-level" :style="{background: singleIndex.levelColor}">
  72. {{ singleIndex.level }}
  73. </view>
  74. </view>
  75. <view class="index-tips">
  76. <view class="tip-item" v-for="(tip, index) in singleIndex.tips" :key="index">
  77. <text class="tip-icon">{{ tip.icon }}</text>
  78. <text class="tip-text">{{ tip.text }}</text>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <!-- 每日幸运推荐 -->
  84. <view class="lucky-recommend">
  85. <view class="section-title">
  86. <text class="title-text">🎁 今日幸运推荐</text>
  87. </view>
  88. <view class="lucky-grid">
  89. <view class="lucky-item" v-for="(item, index) in luckyRecommend" :key="index">
  90. <view class="lucky-icon-wrapper" :style="{background: item.bgColor}">
  91. <text class="lucky-icon">{{ item.icon }}</text>
  92. </view>
  93. <text class="lucky-label">{{ item.label }}</text>
  94. <text class="lucky-value">{{ item.value }}</text>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 热门测试榜单 -->
  99. <view class="hot-tests">
  100. <view class="section-title">
  101. <text class="title-text">🔥 热门测试榜单</text>
  102. <text class="title-more">查看全部 ></text>
  103. </view>
  104. <view class="test-list">
  105. <view class="test-item" v-for="(item, index) in hotTests" :key="index" @click="handleTestClick(item)">
  106. <view class="test-rank" :class="{'top-rank': index < 3}">{{ index + 1 }}</view>
  107. <view class="test-info">
  108. <text class="test-name">{{ item.name }}</text>
  109. <text class="test-count">{{ item.count }} 人已测</text>
  110. </view>
  111. <view class="test-tag" v-if="item.isNew">NEW</view>
  112. </view>
  113. </view>
  114. </view>
  115. <!-- 底部占位 -->
  116. <view class="bottom-placeholder"></view>
  117. </view>
  118. </template>
  119. <script>
  120. export default {
  121. data() {
  122. return {
  123. // 今日日期
  124. todayDate: '',
  125. // 测算卡片
  126. cardList: [
  127. {
  128. id: 1,
  129. name: '属相卡片',
  130. icon: '🐷',
  131. desc: '2.3万人测过',
  132. type: 'zodiac'
  133. },
  134. {
  135. id: 2,
  136. name: '星座卡片',
  137. icon: '♓',
  138. desc: '2.3万人测过',
  139. type: 'constellation'
  140. },
  141. {
  142. id: 3,
  143. name: '八字卡片',
  144. icon: '☯',
  145. desc: '2.3万人测过',
  146. type: 'bazi'
  147. },
  148. {
  149. id: 4,
  150. name: 'MBTI卡片',
  151. icon: '🧩',
  152. desc: '2.3万人测过',
  153. type: 'mbti'
  154. }
  155. ],
  156. // 缘分配对测试统计
  157. matchTestCount: 1234,
  158. // 我的爱情运势
  159. loveFortune: [
  160. {
  161. label: '桃花运',
  162. icon: '🌸',
  163. score: 85,
  164. color: 'linear-gradient(135deg, #FF6B9D 0%, #FFA5C6 100%)'
  165. },
  166. {
  167. label: '爱情指数',
  168. icon: '💕',
  169. score: 78,
  170. color: 'linear-gradient(135deg, #E91E63 0%, #FF6B9D 100%)'
  171. },
  172. {
  173. label: '魅力值',
  174. icon: '✨',
  175. score: 92,
  176. color: 'linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%)'
  177. }
  178. ],
  179. // 本周脱单指数
  180. singleIndex: {
  181. score: 88,
  182. level: '极佳',
  183. levelColor: 'linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%)',
  184. tips: [
  185. { icon: '📅', text: '最佳约会日:周六' },
  186. { icon: '⏰', text: '最佳时间:下午2-5点' },
  187. { icon: '📍', text: '推荐地点:咖啡厅、公园' }
  188. ]
  189. },
  190. // 每日幸运推荐
  191. luckyRecommend: [
  192. {
  193. label: '幸运色',
  194. icon: '🎨',
  195. value: '粉红色',
  196. bgColor: 'linear-gradient(135deg, #FFB6C1 0%, #FFE4E1 100%)'
  197. },
  198. {
  199. label: '幸运数字',
  200. icon: '🔢',
  201. value: '7',
  202. bgColor: 'linear-gradient(135deg, #9C27B0 0%, #CE93D8 100%)'
  203. },
  204. {
  205. label: '约会建议',
  206. icon: '💡',
  207. value: '浪漫晚餐',
  208. bgColor: 'linear-gradient(135deg, #FF9800 0%, #FFB74D 100%)'
  209. },
  210. {
  211. label: '穿搭风格',
  212. icon: '👗',
  213. value: '清新甜美',
  214. bgColor: 'linear-gradient(135deg, #4CAF50 0%, #81C784 100%)'
  215. }
  216. ],
  217. // 热门测试榜单
  218. hotTests: [
  219. {
  220. id: 1,
  221. name: '恋爱性格测试',
  222. count: '12.8万',
  223. isNew: false
  224. },
  225. {
  226. id: 2,
  227. name: '理想型匹配度',
  228. count: '10.5万',
  229. isNew: true
  230. },
  231. {
  232. id: 3,
  233. name: '爱情观测试',
  234. count: '9.2万',
  235. isNew: false
  236. },
  237. {
  238. id: 4,
  239. name: '婚姻契合度',
  240. count: '8.6万',
  241. isNew: false
  242. },
  243. {
  244. id: 5,
  245. name: '恋爱EQ测试',
  246. count: '7.3万',
  247. isNew: true
  248. }
  249. ]
  250. }
  251. },
  252. onLoad() {
  253. this.initData()
  254. },
  255. methods: {
  256. // 初始化数据
  257. initData() {
  258. // 设置今日日期
  259. const date = new Date()
  260. const month = date.getMonth() + 1
  261. const day = date.getDate()
  262. const weekDays = ['日', '一', '二', '三', '四', '五', '六']
  263. const weekDay = weekDays[date.getDay()]
  264. this.todayDate = `${month}月${day}日 周${weekDay}`
  265. },
  266. // 返回上一页
  267. goBack() {
  268. // 检查页面栈
  269. const pages = getCurrentPages()
  270. if (pages.length > 1) {
  271. // 有上一页,正常返回
  272. uni.navigateBack({
  273. delta: 1
  274. })
  275. } else {
  276. // 没有上一页,跳转到首页
  277. uni.switchTab({
  278. url: '/pages/index/index'
  279. })
  280. }
  281. },
  282. // 卡片点击
  283. handleCardClick(card) {
  284. // 根据不同类型跳转到不同页面
  285. const pageMap = {
  286. 'zodiac': '/pages/astrology/zodiac',
  287. 'constellation': '/pages/astrology/constellation',
  288. 'bazi': '/pages/astrology/bazi',
  289. 'mbti': '/pages/astrology/mbti'
  290. }
  291. const page = pageMap[card.type]
  292. if (page) {
  293. uni.navigateTo({
  294. url: page
  295. })
  296. } else {
  297. uni.showToast({
  298. title: `${card.name}功能开发中`,
  299. icon: 'none'
  300. })
  301. }
  302. },
  303. // 星座配对测试
  304. handleConstellationMatch() {
  305. uni.navigateTo({
  306. url: '/pages/astrology/constellation-match'
  307. })
  308. },
  309. // 测试项点击
  310. handleTestClick(test) {
  311. uni.showToast({
  312. title: `${test.name}功能开发中`,
  313. icon: 'none'
  314. })
  315. }
  316. }
  317. }
  318. </script>
  319. <style lang="scss" scoped>
  320. .astrology-page {
  321. min-height: 100vh;
  322. background: linear-gradient(180deg, #FFF9F9 0%, #FFFFFF 50%);
  323. padding-bottom: 40rpx;
  324. }
  325. /* 自定义导航栏 */
  326. .custom-nav {
  327. position: relative;
  328. display: flex;
  329. align-items: center;
  330. justify-content: space-between;
  331. height: 88rpx;
  332. padding: 0 30rpx;
  333. background-color: #FFFFFF;
  334. border-bottom: 1rpx solid #F0F0F0;
  335. .nav-left {
  336. width: 80rpx;
  337. .back-icon {
  338. font-size: 40rpx;
  339. color: #333333;
  340. }
  341. }
  342. .nav-title {
  343. position: absolute;
  344. left: 50%;
  345. transform: translateX(-50%);
  346. font-size: 34rpx;
  347. font-weight: 600;
  348. color: #333333;
  349. }
  350. .nav-right {
  351. width: 80rpx;
  352. text-align: right;
  353. .menu-icon {
  354. font-size: 40rpx;
  355. color: #333333;
  356. }
  357. }
  358. }
  359. /* 测算卡片区域 */
  360. .cards-section {
  361. display: flex;
  362. justify-content: space-around;
  363. padding: 40rpx 30rpx 30rpx;
  364. background-color: #FFFFFF;
  365. .card-item {
  366. display: flex;
  367. flex-direction: column;
  368. align-items: center;
  369. width: 160rpx;
  370. transition: transform 0.2s;
  371. &:active {
  372. transform: scale(0.95);
  373. }
  374. .card-icon {
  375. width: 120rpx;
  376. height: 120rpx;
  377. display: flex;
  378. align-items: center;
  379. justify-content: center;
  380. background: linear-gradient(135deg, #F3E5F5 0%, #E1BEE7 100%);
  381. border-radius: 20rpx;
  382. font-size: 60rpx;
  383. margin-bottom: 15rpx;
  384. box-shadow: 0 4rpx 12rpx rgba(156, 39, 176, 0.15);
  385. }
  386. .card-name {
  387. font-size: 28rpx;
  388. color: #333333;
  389. font-weight: 500;
  390. margin-bottom: 8rpx;
  391. }
  392. .card-desc {
  393. font-size: 22rpx;
  394. color: #999999;
  395. }
  396. }
  397. }
  398. /* 通用标题样式 */
  399. .section-title {
  400. display: flex;
  401. justify-content: space-between;
  402. align-items: center;
  403. margin-bottom: 20rpx;
  404. .title-text {
  405. font-size: 32rpx;
  406. font-weight: 600;
  407. color: #333333;
  408. }
  409. .title-date {
  410. font-size: 24rpx;
  411. color: #999999;
  412. }
  413. .title-more {
  414. font-size: 24rpx;
  415. color: #E91E63;
  416. }
  417. }
  418. /* 缘分配对测试 */
  419. .match-test-banner {
  420. margin: 30rpx;
  421. background: linear-gradient(135deg, #FF6B9D 0%, #FFA5C6 100%);
  422. border-radius: 20rpx;
  423. padding: 30rpx;
  424. box-shadow: 0 8rpx 20rpx rgba(233, 30, 99, 0.25);
  425. transition: transform 0.2s;
  426. &:active {
  427. transform: scale(0.98);
  428. }
  429. .match-banner-content {
  430. display: flex;
  431. align-items: center;
  432. margin-bottom: 15rpx;
  433. .match-icon-group {
  434. width: 80rpx;
  435. height: 80rpx;
  436. background-color: rgba(255, 255, 255, 0.3);
  437. border-radius: 50%;
  438. display: flex;
  439. align-items: center;
  440. justify-content: center;
  441. margin-right: 20rpx;
  442. .match-icon {
  443. font-size: 48rpx;
  444. }
  445. }
  446. .match-text-group {
  447. flex: 1;
  448. .match-title {
  449. font-size: 32rpx;
  450. font-weight: 600;
  451. color: #FFFFFF;
  452. margin-bottom: 8rpx;
  453. }
  454. .match-subtitle {
  455. font-size: 24rpx;
  456. color: rgba(255, 255, 255, 0.9);
  457. }
  458. }
  459. .match-arrow {
  460. font-size: 40rpx;
  461. color: #FFFFFF;
  462. font-weight: bold;
  463. }
  464. }
  465. .match-stats {
  466. .match-stats-text {
  467. font-size: 22rpx;
  468. color: rgba(255, 255, 255, 0.85);
  469. }
  470. }
  471. }
  472. /* 我的爱情运势 */
  473. .love-fortune {
  474. margin: 30rpx;
  475. .fortune-cards {
  476. display: flex;
  477. flex-direction: column;
  478. gap: 15rpx;
  479. .fortune-card {
  480. display: flex;
  481. align-items: center;
  482. background-color: #FFFFFF;
  483. border-radius: 15rpx;
  484. padding: 25rpx;
  485. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
  486. .fortune-icon {
  487. width: 70rpx;
  488. height: 70rpx;
  489. border-radius: 50%;
  490. display: flex;
  491. align-items: center;
  492. justify-content: center;
  493. margin-right: 20rpx;
  494. .fortune-emoji {
  495. font-size: 36rpx;
  496. }
  497. }
  498. .fortune-info {
  499. flex: 1;
  500. .fortune-label {
  501. font-size: 28rpx;
  502. color: #333333;
  503. font-weight: 500;
  504. margin-bottom: 12rpx;
  505. display: block;
  506. }
  507. .fortune-score {
  508. display: flex;
  509. align-items: center;
  510. .score-bar {
  511. flex: 1;
  512. height: 12rpx;
  513. background-color: #F0F0F0;
  514. border-radius: 6rpx;
  515. overflow: hidden;
  516. margin-right: 15rpx;
  517. .score-fill {
  518. height: 100%;
  519. border-radius: 6rpx;
  520. transition: width 0.6s ease;
  521. }
  522. }
  523. .score-text {
  524. font-size: 26rpx;
  525. color: #E91E63;
  526. font-weight: 600;
  527. min-width: 60rpx;
  528. text-align: right;
  529. }
  530. }
  531. }
  532. }
  533. }
  534. }
  535. /* 本周脱单指数 */
  536. .single-index {
  537. margin: 30rpx;
  538. .index-card {
  539. background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
  540. border-radius: 20rpx;
  541. padding: 30rpx;
  542. box-shadow: 0 4rpx 12rpx rgba(255, 152, 0, 0.15);
  543. .index-header {
  544. display: flex;
  545. justify-content: space-between;
  546. align-items: center;
  547. margin-bottom: 25rpx;
  548. .index-score-wrapper {
  549. display: flex;
  550. align-items: baseline;
  551. .index-score {
  552. font-size: 72rpx;
  553. font-weight: bold;
  554. color: #FF6B6B;
  555. line-height: 1;
  556. }
  557. .index-unit {
  558. font-size: 28rpx;
  559. color: #666666;
  560. margin-left: 8rpx;
  561. }
  562. }
  563. .index-level {
  564. padding: 10rpx 25rpx;
  565. border-radius: 30rpx;
  566. font-size: 28rpx;
  567. color: #FFFFFF;
  568. font-weight: 600;
  569. }
  570. }
  571. .index-tips {
  572. display: flex;
  573. flex-direction: column;
  574. gap: 12rpx;
  575. .tip-item {
  576. display: flex;
  577. align-items: center;
  578. background-color: rgba(255, 255, 255, 0.7);
  579. border-radius: 10rpx;
  580. padding: 15rpx 20rpx;
  581. .tip-icon {
  582. font-size: 28rpx;
  583. margin-right: 12rpx;
  584. }
  585. .tip-text {
  586. font-size: 26rpx;
  587. color: #333333;
  588. }
  589. }
  590. }
  591. }
  592. }
  593. /* 每日幸运推荐 */
  594. .lucky-recommend {
  595. margin: 30rpx;
  596. .lucky-grid {
  597. display: grid;
  598. grid-template-columns: repeat(2, 1fr);
  599. gap: 20rpx;
  600. .lucky-item {
  601. display: flex;
  602. flex-direction: column;
  603. align-items: center;
  604. background-color: #FFFFFF;
  605. border-radius: 15rpx;
  606. padding: 30rpx 20rpx;
  607. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
  608. .lucky-icon-wrapper {
  609. width: 80rpx;
  610. height: 80rpx;
  611. border-radius: 50%;
  612. display: flex;
  613. align-items: center;
  614. justify-content: center;
  615. margin-bottom: 15rpx;
  616. .lucky-icon {
  617. font-size: 40rpx;
  618. }
  619. }
  620. .lucky-label {
  621. font-size: 24rpx;
  622. color: #999999;
  623. margin-bottom: 8rpx;
  624. }
  625. .lucky-value {
  626. font-size: 28rpx;
  627. color: #333333;
  628. font-weight: 600;
  629. }
  630. }
  631. }
  632. }
  633. /* 热门测试榜单 */
  634. .hot-tests {
  635. margin: 30rpx;
  636. .test-list {
  637. background-color: #FFFFFF;
  638. border-radius: 20rpx;
  639. overflow: hidden;
  640. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
  641. .test-item {
  642. display: flex;
  643. align-items: center;
  644. padding: 25rpx 30rpx;
  645. border-bottom: 1rpx solid #F5F5F5;
  646. position: relative;
  647. transition: background-color 0.2s;
  648. &:last-child {
  649. border-bottom: none;
  650. }
  651. &:active {
  652. background-color: #F9F9F9;
  653. }
  654. .test-rank {
  655. width: 50rpx;
  656. height: 50rpx;
  657. background-color: #F0F0F0;
  658. border-radius: 10rpx;
  659. display: flex;
  660. align-items: center;
  661. justify-content: center;
  662. font-size: 26rpx;
  663. font-weight: bold;
  664. color: #666666;
  665. margin-right: 20rpx;
  666. &.top-rank {
  667. background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
  668. color: #FFFFFF;
  669. }
  670. }
  671. .test-info {
  672. flex: 1;
  673. .test-name {
  674. font-size: 28rpx;
  675. color: #333333;
  676. font-weight: 500;
  677. display: block;
  678. margin-bottom: 8rpx;
  679. }
  680. .test-count {
  681. font-size: 22rpx;
  682. color: #999999;
  683. }
  684. }
  685. .test-tag {
  686. position: absolute;
  687. top: 15rpx;
  688. right: 30rpx;
  689. padding: 4rpx 12rpx;
  690. background: linear-gradient(135deg, #E91E63 0%, #FF6B9D 100%);
  691. color: #FFFFFF;
  692. font-size: 20rpx;
  693. border-radius: 6rpx;
  694. font-weight: bold;
  695. }
  696. }
  697. }
  698. }
  699. /* 底部占位 */
  700. .bottom-placeholder {
  701. height: 40rpx;
  702. }
  703. </style>