| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851 |
- <template>
- <view class="astrology-page">
- <!-- 自定义顶部导航栏 -->
- <view class="custom-nav">
- <view class="nav-left" @click="goBack">
- <text class="back-icon">←</text>
- </view>
- <view class="nav-title">星命运算</view>
- <view class="nav-right">
- <text class="menu-icon">⋯</text>
- </view>
- </view>
- <!-- 用户资料提示 -->
- <view class="profile-tip" v-if="!hasProfile" @click="goToProfile">
- <view class="tip-content">
- <text class="tip-icon">💫</text>
- <view class="tip-text-group">
- <text class="tip-title">完善资料,解锁专属运势</text>
- <text class="tip-desc">填写出生日期,获取更精准的运势分析</text>
- </view>
- <text class="tip-arrow">→</text>
- </view>
- </view>
-
- <!-- 用户信息卡片 -->
- <view class="user-profile-card" v-if="hasProfile" @click="goToProfile">
- <view class="user-avatar-wrapper">
- <image class="user-avatar" :src="userInfo.avatarUrl || userInfo.avatar || defaultAvatar" mode="aspectFill"></image>
- </view>
- <view class="user-info-content">
- <text class="user-nickname">{{ userInfo.nickname || '用户' }}</text>
- <view class="user-astro-tags">
- <view class="astro-tag" v-if="userConstellation">
- <text class="astro-icon">⭐</text>
- <text class="astro-text">{{ userConstellation }}</text>
- </view>
- <view class="astro-tag" v-if="userZodiac">
- <text class="astro-icon">🐲</text>
- <text class="astro-text">属{{ userZodiac }}</text>
- </view>
- </view>
- </view>
- <view class="edit-icon">
- <text>›</text>
- </view>
- </view>
- <!-- 测算卡片区域 -->
- <view class="cards-section">
- <view class="card-item" v-for="(card, index) in cardList" :key="index" @click="handleCardClick(card)">
- <view class="card-icon">{{ card.icon }}</view>
- <view class="card-name">{{ card.name }}</view>
- </view>
- </view>
- <!-- 我的爱情运势 -->
- <view class="love-fortune">
- <view class="section-title">
- <text class="title-text">❤️ 我的爱情运势</text>
- <text class="title-date">{{ todayDate }}</text>
- </view>
- <view class="fortune-cards">
- <view class="fortune-card" v-for="(item, index) in loveFortune" :key="index">
- <view class="fortune-icon" :style="{background: item.color}">
- <text class="fortune-emoji">{{ item.icon }}</text>
- </view>
- <view class="fortune-info">
- <text class="fortune-label">{{ item.label }}</text>
- <view class="fortune-score">
- <view class="score-bar">
- <view class="score-fill" :style="{width: item.score + '%', background: item.color}"></view>
- </view>
- <text class="score-text">{{ item.score }}%</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- 本周脱单指数 -->
- <view class="single-index">
- <view class="section-title">
- <text class="title-text">📊 本周脱单指数</text>
- </view>
- <view class="index-card">
- <view class="index-header">
- <view class="index-score-wrapper">
- <text class="index-score">{{ singleIndex.score }}</text>
- <text class="index-unit">分</text>
- </view>
- <view class="index-level" :style="{background: singleIndex.levelColor}">
- {{ singleIndex.level }}
- </view>
- </view>
- <view class="index-tips">
- <view class="tip-item" v-for="(tip, index) in singleIndex.tips" :key="index">
- <text class="tip-icon">{{ tip.icon }}</text>
- <text class="tip-text">{{ tip.text }}</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 每日幸运推荐 -->
- <view class="lucky-recommend">
- <view class="section-title">
- <text class="title-text">🎁 今日幸运推荐</text>
- </view>
- <view class="lucky-grid">
- <view class="lucky-item" v-for="(item, index) in luckyRecommend" :key="index">
- <view class="lucky-icon-wrapper" :style="{background: item.bgColor}">
- <text class="lucky-icon">{{ item.icon }}</text>
- </view>
- <text class="lucky-label">{{ item.label }}</text>
- <text class="lucky-value">{{ item.value }}</text>
- </view>
- </view>
- </view>
- <!-- 底部占位 -->
- <view class="bottom-placeholder"></view>
- </view>
- </template>
- <script>
- import fortuneUtil from '@/utils/fortune.js'
- import api from '@/utils/api.js'
- export default {
- data() {
- return {
- // 今日日期
- todayDate: '',
-
- // 用户信息
- userInfo: {},
-
- // 是否有完整资料
- hasProfile: false,
-
- // 用户星座和生肖
- userConstellation: '',
- userZodiac: '',
-
- // 默认头像
- defaultAvatar: 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI9FhqmIJtfQMh0LLicJxYS9xcd1u9YLnnvibALzycnOXLqm0JtmaNotzzSMyyibBtvBfzic6bg/0',
-
- // 测算卡片
- cardList: [
- { id: 1, name: '属相卡片', icon: '🐷', type: 'zodiac' },
- { id: 2, name: '星座卡片', icon: '♓', type: 'constellation' },
- { id: 3, name: '八字卡片', icon: '☯', type: 'bazi' },
- { id: 4, name: 'MBTI卡片', icon: '🧩', type: 'mbti' }
- ],
- // 我的爱情运势(动态计算)
- loveFortune: [],
- // 本周脱单指数(动态计算)
- singleIndex: {
- score: 75,
- level: '良好',
- levelColor: 'linear-gradient(135deg, #2196F3 0%, #03A9F4 100%)',
- tips: []
- },
- // 每日幸运推荐(动态计算)
- luckyRecommend: []
- }
- },
- onLoad() {
- this.initData()
- },
-
- onShow() {
- // 每次显示页面时重新加载用户信息和计算运势
- this.loadUserInfo()
- },
- methods: {
- // 初始化数据
- initData() {
- // 设置今日日期
- const date = new Date()
- const month = date.getMonth() + 1
- const day = date.getDate()
- const weekDays = ['日', '一', '二', '三', '四', '五', '六']
- const weekDay = weekDays[date.getDay()]
- this.todayDate = `${month}月${day}日 周${weekDay}`
-
- // 加载用户信息并计算运势
- this.loadUserInfo()
- },
-
- // 加载用户信息
- async loadUserInfo() {
- // 先从本地存储获取基础信息
- let userInfo = uni.getStorageSync('userInfo') || {}
- const userId = uni.getStorageSync('userId')
-
- // 如果有userId,从API获取最新用户信息
- if (userId) {
- try {
- const data = await api.user.getDetailInfo(userId)
- if (data) {
- // 合并API返回的数据
- userInfo = {
- ...userInfo,
- ...data,
- userId: userId
- }
- // 更新本地存储
- uni.setStorageSync('userInfo', userInfo)
-
- }
- } catch (error) {
-
- }
- }
-
- this.userInfo = userInfo
-
- // 计算运势
- this.calculateFortune()
- },
-
- // 计算运势数据
- calculateFortune() {
- const fortuneData = fortuneUtil.getFullFortuneData(this.userInfo)
-
- this.hasProfile = fortuneData.hasProfile
- this.userConstellation = fortuneData.constellation || ''
- this.userZodiac = fortuneData.zodiac || ''
- this.loveFortune = fortuneData.loveFortune
- this.singleIndex = fortuneData.singleIndex
- this.luckyRecommend = fortuneData.luckyRecommend
-
- },
- // 返回上一页
- goBack() {
- // 检查页面栈
- const pages = getCurrentPages()
- if (pages.length > 1) {
- // 有上一页,正常返回
- uni.navigateBack({
- delta: 1
- })
- } else {
- // 没有上一页,跳转到首页
- uni.switchTab({
- url: '/pages/index/index'
- })
- }
- },
- // 卡片点击
- handleCardClick(card) {
- // 根据不同类型跳转到不同页面
- const pageMap = {
- 'zodiac': '/pages/astrology/zodiac',
- 'constellation': '/pages/astrology/constellation',
- 'bazi': '/pages/astrology/bazi',
- 'mbti': '/pages/astrology/mbti'
- }
- const page = pageMap[card.type]
- if (page) {
- uni.navigateTo({
- url: page
- })
- } else {
- uni.showToast({
- title: `${card.name}功能开发中`,
- icon: 'none'
- })
- }
- },
- // 跳转到个人资料页面
- goToProfile() {
- uni.navigateTo({
- url: '/pages/profile/index'
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .astrology-page {
- min-height: 100vh;
- background: linear-gradient(180deg, #FFF9F9 0%, #FFFFFF 50%);
- padding-bottom: 40rpx;
- }
- /* 自定义导航栏 */
- .custom-nav {
- position: relative;
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 88rpx;
- padding: 0 30rpx;
- background-color: #FFFFFF;
- border-bottom: 1rpx solid #F0F0F0;
- .nav-left {
- width: 80rpx;
- .back-icon {
- font-size: 40rpx;
- color: #333333;
- }
- }
- .nav-title {
- position: absolute;
- left: 50%;
- transform: translateX(-50%);
- font-size: 34rpx;
- font-weight: 600;
- color: #333333;
- }
- .nav-right {
- width: 80rpx;
- text-align: right;
- .menu-icon {
- font-size: 40rpx;
- color: #333333;
- }
- }
- }
- /* 用户资料提示 */
- .profile-tip {
- margin: 20rpx 30rpx;
- background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
- border-radius: 16rpx;
- padding: 24rpx;
- box-shadow: 0 4rpx 12rpx rgba(255, 152, 0, 0.15);
-
- .tip-content {
- display: flex;
- align-items: center;
-
- .tip-icon {
- font-size: 40rpx;
- margin-right: 20rpx;
- }
-
- .tip-text-group {
- flex: 1;
-
- .tip-title {
- font-size: 28rpx;
- font-weight: 600;
- color: #E65100;
- display: block;
- margin-bottom: 6rpx;
- }
-
- .tip-desc {
- font-size: 24rpx;
- color: #FF8F00;
- }
- }
-
- .tip-arrow {
- font-size: 32rpx;
- color: #E65100;
- font-weight: bold;
- }
- }
- }
- /* 用户信息卡片 */
- .user-profile-card {
- display: flex;
- align-items: center;
- margin: 20rpx 30rpx;
- padding: 24rpx;
- background: linear-gradient(135deg, #FFFFFF 0%, #FFF9FB 100%);
- border-radius: 20rpx;
- box-shadow: 0 4rpx 16rpx rgba(233, 30, 99, 0.1);
- border: 1rpx solid rgba(233, 30, 99, 0.1);
-
- .user-avatar-wrapper {
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- overflow: hidden;
- margin-right: 24rpx;
- border: 4rpx solid #FFE4EC;
- box-shadow: 0 4rpx 12rpx rgba(233, 30, 99, 0.15);
-
- .user-avatar {
- width: 100%;
- height: 100%;
- }
- }
-
- .user-info-content {
- flex: 1;
-
- .user-nickname {
- font-size: 32rpx;
- font-weight: 600;
- color: #333333;
- display: block;
- margin-bottom: 12rpx;
- }
-
- .user-astro-tags {
- display: flex;
- gap: 16rpx;
-
- .astro-tag {
- display: flex;
- align-items: center;
- background: linear-gradient(135deg, #FCE4EC 0%, #F8BBD9 100%);
- padding: 8rpx 16rpx;
- border-radius: 20rpx;
-
- .astro-icon {
- font-size: 22rpx;
- margin-right: 6rpx;
- }
-
- .astro-text {
- font-size: 24rpx;
- color: #E91E63;
- font-weight: 500;
- }
- }
- }
- }
-
- .edit-icon {
- font-size: 40rpx;
- color: #CCCCCC;
- font-weight: 300;
- }
- }
- /* 测算卡片区域 */
- .cards-section {
- display: flex;
- justify-content: space-around;
- padding: 40rpx 30rpx 30rpx;
- background-color: #FFFFFF;
- .card-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 160rpx;
- transition: transform 0.2s;
- &:active {
- transform: scale(0.95);
- }
- .card-icon {
- width: 120rpx;
- height: 120rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- background: linear-gradient(135deg, #F3E5F5 0%, #E1BEE7 100%);
- border-radius: 20rpx;
- font-size: 60rpx;
- margin-bottom: 15rpx;
- box-shadow: 0 4rpx 12rpx rgba(156, 39, 176, 0.15);
- }
- .card-name {
- font-size: 28rpx;
- color: #333333;
- font-weight: 500;
- }
- }
- }
- /* 通用标题样式 */
- .section-title {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
- .title-text {
- font-size: 32rpx;
- font-weight: 600;
- color: #333333;
- }
- .title-date {
- font-size: 24rpx;
- color: #999999;
- }
- .title-more {
- font-size: 24rpx;
- color: #E91E63;
- }
- }
- /* 缘分配对测试 */
- .match-test-banner {
- margin: 30rpx;
- background: linear-gradient(135deg, #FF6B9D 0%, #FFA5C6 100%);
- border-radius: 20rpx;
- padding: 30rpx;
- box-shadow: 0 8rpx 20rpx rgba(233, 30, 99, 0.25);
- transition: transform 0.2s;
- &:active {
- transform: scale(0.98);
- }
- .match-banner-content {
- display: flex;
- align-items: center;
- margin-bottom: 15rpx;
- .match-icon-group {
- width: 80rpx;
- height: 80rpx;
- background-color: rgba(255, 255, 255, 0.3);
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 20rpx;
- .match-icon {
- font-size: 48rpx;
- }
- }
- .match-text-group {
- flex: 1;
- .match-title {
- font-size: 32rpx;
- font-weight: 600;
- color: #FFFFFF;
- margin-bottom: 8rpx;
- }
- .match-subtitle {
- font-size: 24rpx;
- color: rgba(255, 255, 255, 0.9);
- }
- }
- .match-arrow {
- font-size: 40rpx;
- color: #FFFFFF;
- font-weight: bold;
- }
- }
- .match-stats {
- .match-stats-text {
- font-size: 22rpx;
- color: rgba(255, 255, 255, 0.85);
- }
- }
- }
- /* 我的爱情运势 */
- .love-fortune {
- margin: 30rpx;
- .fortune-cards {
- display: flex;
- flex-direction: column;
- gap: 15rpx;
- .fortune-card {
- display: flex;
- align-items: center;
- background-color: #FFFFFF;
- border-radius: 15rpx;
- padding: 25rpx;
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
- .fortune-icon {
- width: 70rpx;
- height: 70rpx;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 20rpx;
- .fortune-emoji {
- font-size: 36rpx;
- }
- }
- .fortune-info {
- flex: 1;
- .fortune-label {
- font-size: 28rpx;
- color: #333333;
- font-weight: 500;
- margin-bottom: 12rpx;
- display: block;
- }
- .fortune-score {
- display: flex;
- align-items: center;
- .score-bar {
- flex: 1;
- height: 12rpx;
- background-color: #F0F0F0;
- border-radius: 6rpx;
- overflow: hidden;
- margin-right: 15rpx;
- .score-fill {
- height: 100%;
- border-radius: 6rpx;
- transition: width 0.6s ease;
- }
- }
- .score-text {
- font-size: 26rpx;
- color: #E91E63;
- font-weight: 600;
- min-width: 60rpx;
- text-align: right;
- }
- }
- }
- }
- }
- }
- /* 本周脱单指数 */
- .single-index {
- margin: 30rpx;
- .index-card {
- background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
- border-radius: 20rpx;
- padding: 30rpx;
- box-shadow: 0 4rpx 12rpx rgba(255, 152, 0, 0.15);
- .index-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 25rpx;
- .index-score-wrapper {
- display: flex;
- align-items: baseline;
- .index-score {
- font-size: 72rpx;
- font-weight: bold;
- color: #FF6B6B;
- line-height: 1;
- }
- .index-unit {
- font-size: 28rpx;
- color: #666666;
- margin-left: 8rpx;
- }
- }
- .index-level {
- padding: 10rpx 25rpx;
- border-radius: 30rpx;
- font-size: 28rpx;
- color: #FFFFFF;
- font-weight: 600;
- }
- }
- .index-tips {
- display: flex;
- flex-direction: column;
- gap: 12rpx;
- .tip-item {
- display: flex;
- align-items: center;
- background-color: rgba(255, 255, 255, 0.7);
- border-radius: 10rpx;
- padding: 15rpx 20rpx;
- .tip-icon {
- font-size: 28rpx;
- margin-right: 12rpx;
- }
- .tip-text {
- font-size: 26rpx;
- color: #333333;
- }
- }
- }
- }
- }
- /* 每日幸运推荐 */
- .lucky-recommend {
- margin: 30rpx;
- .lucky-grid {
- display: grid;
- grid-template-columns: repeat(4, 1fr);
- gap: 16rpx;
- .lucky-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- background-color: #FFFFFF;
- border-radius: 12rpx;
- padding: 20rpx 10rpx;
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
- .lucky-icon-wrapper {
- width: 60rpx;
- height: 60rpx;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 10rpx;
- .lucky-icon {
- font-size: 32rpx;
- }
- }
- .lucky-label {
- font-size: 22rpx;
- color: #999999;
- margin-bottom: 6rpx;
- }
- .lucky-value {
- font-size: 24rpx;
- color: #333333;
- font-weight: 600;
- text-align: center;
- word-break: break-all;
- }
- }
- }
- }
- /* 热门测试榜单 */
- .hot-tests {
- margin: 30rpx;
- .test-list {
- background-color: #FFFFFF;
- border-radius: 20rpx;
- overflow: hidden;
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
- .test-item {
- display: flex;
- align-items: center;
- padding: 25rpx 30rpx;
- border-bottom: 1rpx solid #F5F5F5;
- position: relative;
- transition: background-color 0.2s;
- &:last-child {
- border-bottom: none;
- }
- &:active {
- background-color: #F9F9F9;
- }
- .test-rank {
- width: 50rpx;
- height: 50rpx;
- background-color: #F0F0F0;
- border-radius: 10rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 26rpx;
- font-weight: bold;
- color: #666666;
- margin-right: 20rpx;
- &.top-rank {
- background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
- color: #FFFFFF;
- }
- }
- .test-info {
- flex: 1;
- .test-name {
- font-size: 28rpx;
- color: #333333;
- font-weight: 500;
- display: block;
- margin-bottom: 8rpx;
- }
- .test-count {
- font-size: 22rpx;
- color: #999999;
- }
- }
- .test-tag {
- position: absolute;
- top: 15rpx;
- right: 30rpx;
- padding: 4rpx 12rpx;
- background: linear-gradient(135deg, #E91E63 0%, #FF6B9D 100%);
- color: #FFFFFF;
- font-size: 20rpx;
- border-radius: 6rpx;
- font-weight: bold;
- }
- }
- }
- }
- /* 底部占位 */
- .bottom-placeholder {
- height: 40rpx;
- }
- </style>
|