| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522 |
- <template>
- <view class="constellation-match-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"></view>
- </view>
- <!-- 星座选择区域 -->
- <view class="constellation-selection-section" v-if="!hasResult">
- <view class="selection-card">
- <view class="card-title">💕 星座配对测试</view>
- <view class="card-subtitle">看看你们的星座匹配度有多高</view>
-
- <!-- 我的星座选择 -->
- <view class="constellation-picker-wrapper">
- <view class="picker-label">我的星座</view>
- <picker mode="selector" :range="constellationNames" :value="myConstellationIndex" @change="onMyConstellationChange">
- <view class="constellation-display">
- <text class="constellation-emoji">{{ myConstellationEmoji }}</text>
- <text class="constellation-text">{{ myConstellation || '请选择' }}</text>
- </view>
- </picker>
- </view>
- <!-- 对方星座选择 -->
- <view class="constellation-picker-wrapper">
- <view class="picker-label">TA的星座</view>
- <picker mode="selector" :range="constellationNames" :value="targetConstellationIndex" @change="onTargetConstellationChange">
- <view class="constellation-display">
- <text class="constellation-emoji">{{ targetConstellationEmoji }}</text>
- <text class="constellation-text">{{ targetConstellation || '请选择' }}</text>
- </view>
- </picker>
- </view>
- <button class="submit-btn" @click="handleSubmit" :disabled="!myConstellation || !targetConstellation">
- 开始配对
- </button>
- </view>
- <!-- 装饰性星座图标 -->
- <view class="constellation-icons">
- <text class="constellation-icon" v-for="(constellation, index) in allConstellations" :key="index">
- {{ constellation.emoji }}
- </text>
- </view>
- </view>
- <!-- 配对结果 -->
- <view class="result-section" v-if="hasResult">
- <!-- 配对标题卡片 -->
- <view class="match-title-card">
- <view class="match-header">
- <view class="constellation-pair">
- <text class="constellation-emoji-large">{{ myConstellationEmoji }}</text>
- <text class="vs-text">💕</text>
- <text class="constellation-emoji-large">{{ targetConstellationEmoji }}</text>
- </view>
- <view class="match-title">{{ myConstellation }} 💕 {{ targetConstellation }}</view>
- <view class="match-subtitle">{{ matchResult.title || '配对分析' }}</view>
- </view>
- </view>
- <!-- 配对分数 -->
- <view class="score-section">
- <view class="section-title">💯 配对分数</view>
- <view class="score-card">
- <view class="score-main">
- <view class="score-circle" :style="{background: matchResult.scoreColor}">
- <text class="score-number">{{ matchResult.totalScore }}</text>
- <text class="score-unit">分</text>
- </view>
- <view class="score-level" :style="{background: matchResult.levelColor}">
- {{ matchResult.level }}
- </view>
- </view>
- <view class="score-breakdown">
- <view class="score-item" v-for="(item, index) in matchResult.scoreDetails" :key="index">
- <view class="score-item-header">
- <text class="score-item-icon">{{ item.icon }}</text>
- <text class="score-item-label">{{ item.label }}</text>
- </view>
- <view class="score-progress">
- <view class="progress-bar">
- <view class="progress-fill" :style="{width: item.score + '%', background: item.color}"></view>
- </view>
- <text class="progress-text">{{ item.score }}%</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- API专业分析 -->
- <view class="api-analysis-section" v-if="matchResult.apiGrade || matchResult.apiContent">
- <view class="section-title">🎯 专业分析</view>
- <view class="api-analysis-card">
- <!-- API评级 -->
- <view class="api-grade-item" v-if="matchResult.apiGrade">
- <view class="grade-header">
- <text class="grade-icon">⭐</text>
- <text class="grade-title">专业评级</text>
- </view>
- <text class="grade-content">{{ matchResult.apiGrade }}</text>
- </view>
-
- <!-- API详细内容 -->
- <view class="api-content-item" v-if="matchResult.apiContent">
- <view class="content-header">
- <text class="content-icon">📝</text>
- <text class="content-title">详细分析</text>
- </view>
- <text class="content-text">{{ matchResult.apiContent }}</text>
- </view>
- </view>
- </view>
- <!-- 配对分析 -->
- <view class="match-analysis-section">
- <view class="section-title">💝 深度解析</view>
- <view class="analysis-card">
- <!-- 优势分析 -->
- <view class="analysis-item" v-if="matchResult.advantages">
- <view class="analysis-header">
- <text class="analysis-icon">✨</text>
- <text class="analysis-title">配对优势</text>
- </view>
- <text class="analysis-content">{{ matchResult.advantages }}</text>
- </view>
-
- <!-- 挑战分析 -->
- <view class="analysis-item" v-if="matchResult.challenges">
- <view class="analysis-header">
- <text class="analysis-icon">⚠️</text>
- <text class="analysis-title">潜在挑战</text>
- </view>
- <text class="analysis-content">{{ matchResult.challenges }}</text>
- </view>
-
- <!-- 建议 -->
- <view class="analysis-item" v-if="matchResult.suggestions">
- <view class="analysis-header">
- <text class="analysis-icon">💡</text>
- <text class="analysis-title">相处建议</text>
- </view>
- <text class="analysis-content">{{ matchResult.suggestions }}</text>
- </view>
-
- <!-- 总结 -->
- <view class="analysis-item" v-if="matchResult.summary">
- <view class="analysis-header">
- <text class="analysis-icon">💖</text>
- <text class="analysis-title">配对总结</text>
- </view>
- <text class="analysis-content">{{ matchResult.summary }}</text>
- </view>
- </view>
- </view>
- <!-- 元素分析 -->
- <view class="element-analysis-section">
- <view class="section-title">🔥 元素分析</view>
- <view class="element-card">
- <view class="element-pair">
- <view class="element-item">
- <text class="element-name">{{ myConstellationInfo.element }}</text>
- <text class="element-desc">{{ getElementDescription(myConstellationInfo.element) }}</text>
- </view>
- <text class="element-vs">VS</text>
- <view class="element-item">
- <text class="element-name">{{ targetConstellationInfo.element }}</text>
- <text class="element-desc">{{ getElementDescription(targetConstellationInfo.element) }}</text>
- </view>
- </view>
- <view class="element-compatibility">
- <text class="compatibility-label">元素相容性</text>
- <text class="compatibility-result">{{ matchResult.elementCompatibility }}</text>
- </view>
- </view>
- </view>
- <!-- 星座特质对比 -->
- <view class="traits-comparison-section">
- <view class="section-title">🌟 特质对比</view>
- <view class="traits-card">
- <view class="traits-comparison">
- <view class="traits-column">
- <view class="traits-header">
- <text class="traits-emoji">{{ myConstellationEmoji }}</text>
- <text class="traits-name">{{ myConstellation }}</text>
- </view>
- <view class="trait-tag" v-for="(trait, index) in myConstellationInfo.traits" :key="index">
- {{ trait }}
- </view>
- </view>
- <view class="traits-column">
- <view class="traits-header">
- <text class="traits-emoji">{{ targetConstellationEmoji }}</text>
- <text class="traits-name">{{ targetConstellation }}</text>
- </view>
- <view class="trait-tag" v-for="(trait, index) in targetConstellationInfo.traits" :key="index">
- {{ trait }}
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- 爱情指数预测 -->
- <view class="love-prediction-section">
- <view class="section-title">💕 爱情指数预测</view>
- <view class="prediction-grid">
- <view class="prediction-item" v-for="(item, index) in matchResult.lovePrediction" :key="index">
- <view class="prediction-icon-wrapper" :style="{background: item.bgColor}">
- <text class="prediction-icon">{{ item.icon }}</text>
- </view>
- <text class="prediction-label">{{ item.label }}</text>
- <text class="prediction-value">{{ item.value }}</text>
- </view>
- </view>
- </view>
- <!-- 重新配对 -->
- <view class="retest-btn" @click="handleRetest">
- 重新配对
- </view>
- <!-- 数据来源说明 -->
- <view class="data-source" :class="{'api-source': matchResult.source === 'tianapi'}">
- <text class="source-icon">{{ matchResult.source === 'tianapi' ? '✓' : 'ℹ️' }}</text>
- <view class="source-content">
- <text class="source-text">数据来源:{{ matchResult.dataFrom || '星座占星学理论' }}</text>
- <text class="source-time">更新时间:{{ updateTime }}</text>
- </view>
- </view>
- <!-- 免责声明 -->
- <view class="disclaimer">
- <view class="disclaimer-title">⚠️ 免责声明</view>
- <view class="disclaimer-text">
- 本星座配对结果基于传统占星学理论,仅供娱乐参考,不作为感情决策依据。
- 真正的爱情需要双方的理解、包容和努力经营。
- 每个人都是独特的个体,不要被星座标签所限制。
- </view>
- </view>
- </view>
- <!-- 底部占位 -->
- <view class="bottom-placeholder"></view>
- </view>
- </template>
- <script>
- import constellationUtil from '@/utils/constellation.js'
- export default {
- data() {
- return {
- // 星座配对相关数据
- myConstellation: '',
- targetConstellation: '',
- myConstellationIndex: -1,
- targetConstellationIndex: -1,
- hasResult: false,
- matchResult: null,
- updateTime: '',
-
- // 星座信息
- myConstellationInfo: null,
- targetConstellationInfo: null,
-
- // 所有星座数据
- allConstellations: constellationUtil.getAllConstellations(),
-
- // 星座名称列表
- constellationNames: constellationUtil.getAllConstellations().map(c => c.name)
- }
- },
- computed: {
- // 我的星座emoji
- myConstellationEmoji() {
- return this.myConstellation ? constellationUtil.getConstellationEmoji(this.myConstellation) : '🔮'
- },
-
- // 对方星座emoji
- targetConstellationEmoji() {
- return this.targetConstellation ? constellationUtil.getConstellationEmoji(this.targetConstellation) : '🔮'
- }
- },
- onLoad() {
- this.initData()
- },
- methods: {
- initData() {
- // 设置更新时间
- const date = new Date()
- const year = date.getFullYear()
- const month = parseInt(date.getMonth() + 1)
- const day = parseInt(date.getDate())
- this.updateTime = `${year}年${month}月${day}日`
- },
- // 我的星座选择
- onMyConstellationChange(e) {
- const index = e.detail.value
- this.myConstellationIndex = index
- this.myConstellation = this.constellationNames[index]
- this.myConstellationInfo = constellationUtil.getConstellationInfo(this.myConstellation)
-
- },
-
- // 对方星座选择
- onTargetConstellationChange(e) {
- const index = e.detail.value
- this.targetConstellationIndex = index
- this.targetConstellation = this.constellationNames[index]
- this.targetConstellationInfo = constellationUtil.getConstellationInfo(this.targetConstellation)
-
- },
- // 提交配对
- async handleSubmit() {
- if (!this.myConstellation || !this.targetConstellation) {
- uni.showToast({
- title: '请选择双方星座',
- icon: 'none'
- })
- return
- }
- // 显示加载中
- uni.showLoading({
- title: '配对分析中...',
- mask: true
- })
- try {
-
-
- // 生成配对结果
- this.matchResult = await this.generateMatchResult()
-
- this.hasResult = true
-
- // 保存到本地存储
- uni.setStorageSync('constellationMatch', {
- myConstellation: this.myConstellation,
- targetConstellation: this.targetConstellation,
- result: this.matchResult,
- lastUpdate: new Date().getTime()
- })
- } catch (error) {
-
-
- uni.showToast({
- title: '分析异常,请重试',
- icon: 'none',
- duration: 2000
- })
- } finally {
- uni.hideLoading()
- }
- },
- // 生成配对结果
- async generateMatchResult() {
- try {
- // 调用星座配对API(优先API,失败时使用本地数据)
- const matchData = await constellationUtil.getDetailedConstellationMatch(
- this.myConstellation,
- this.targetConstellation
- )
-
- if (!matchData) {
- throw new Error('获取配对数据失败')
- }
-
- // 生成评分详情
- const scoreDetails = this.generateScoreDetails(matchData.totalScore)
-
- // 生成总结
- const summary = this.generateMatchSummary(matchData)
-
- return {
- title: matchData.title || `${this.myConstellation} × ${this.targetConstellation}`,
- totalScore: matchData.totalScore,
- level: matchData.level,
- levelColor: matchData.levelColor,
- scoreColor: matchData.scoreColor,
- scoreDetails: scoreDetails,
- advantages: matchData.advantages,
- challenges: matchData.challenges,
- suggestions: matchData.suggestions,
- summary: summary,
- elementCompatibility: matchData.elementCompatibility,
- lovePrediction: matchData.lovePrediction,
- // API特有数据
- apiGrade: matchData.apiGrade || '',
- apiContent: matchData.apiContent || '',
- source: matchData.source,
- dataFrom: matchData.dataFrom
- }
-
- } catch (error) {
-
- // 异常时使用本地算法
- return this.generateLocalMatchResult()
- }
- },
-
- // 生成本地配对结果(备用方案)
- generateLocalMatchResult() {
- const myInfo = this.myConstellationInfo
- const targetInfo = this.targetConstellationInfo
-
- // 计算基础匹配度
- const baseScore = this.calculateBaseScore(myInfo, targetInfo)
-
- // 生成详细分析
- const analysis = this.generateDetailedAnalysis(myInfo, targetInfo, baseScore)
-
- return {
- title: `${this.myConstellation} × ${this.targetConstellation}`,
- totalScore: baseScore.total,
- level: baseScore.level,
- levelColor: baseScore.levelColor,
- scoreColor: baseScore.scoreColor,
- scoreDetails: baseScore.details,
- advantages: analysis.advantages,
- challenges: analysis.challenges,
- suggestions: analysis.suggestions,
- summary: analysis.summary,
- elementCompatibility: analysis.elementCompatibility,
- lovePrediction: analysis.lovePrediction,
- apiGrade: '',
- apiContent: '',
- source: 'local',
- dataFrom: '星座占星学理论'
- }
- },
-
- // 生成评分详情
- generateScoreDetails(totalScore) {
- return [
- {
- label: '情感默契',
- icon: '💕',
- score: Math.min(totalScore + Math.floor(Math.random() * 10) - 5, 100),
- color: 'linear-gradient(135deg, #E91E63 0%, #FF6B9D 100%)'
- },
- {
- label: '性格互补',
- icon: '🤝',
- score: Math.min(totalScore + Math.floor(Math.random() * 8) - 4, 100),
- color: 'linear-gradient(135deg, #2196F3 0%, #64B5F6 100%)'
- },
- {
- label: '沟通理解',
- icon: '💬',
- score: Math.min(totalScore + Math.floor(Math.random() * 12) - 6, 100),
- color: 'linear-gradient(135deg, #4CAF50 0%, #81C784 100%)'
- },
- {
- label: '长期发展',
- icon: '🌱',
- score: Math.min(totalScore + Math.floor(Math.random() * 6) - 3, 100),
- color: 'linear-gradient(135deg, #9C27B0 0%, #CE93D8 100%)'
- }
- ]
- },
-
- // 生成配对总结
- generateMatchSummary(matchData) {
- const totalScore = matchData.totalScore
- const constellation1 = this.myConstellation
- const constellation2 = this.targetConstellation
-
- // 如果有API内容,优先使用
- if (matchData.apiContent) {
- return matchData.apiContent
- }
-
- // 否则使用本地生成的总结
- if (totalScore >= 90) {
- return `${constellation1}与${constellation2}的组合堪称天作之合,你们在各个方面都有着很好的默契,是令人羡慕的一对。只要继续保持这份美好,未来充满无限可能。`
- } else if (totalScore >= 80) {
- return `${constellation1}与${constellation2}是非常匹配的组合,你们能够互相理解和支持。虽然偶尔会有小摩擦,但总体来说是和谐美好的一对。`
- } else if (totalScore >= 70) {
- return `${constellation1}与${constellation2}的组合比较合适,需要双方多一些耐心和理解。通过磨合和沟通,你们能够建立稳定的关系。`
- } else if (totalScore >= 60) {
- return `${constellation1}与${constellation2}的组合需要更多努力,但这并不意味着不可能。只要双方都愿意为这份感情付出,就能克服困难。`
- } else {
- return `${constellation1}与${constellation2}的组合面临较大挑战,需要极大的包容和理解。不过,真爱面前没有不可能,关键在于是否愿意为对方改变。`
- }
- },
- // 计算基础匹配分数
- calculateBaseScore(myInfo, targetInfo) {
- // 元素相容性得分
- const elementScore = this.getElementCompatibilityScore(myInfo.element, targetInfo.element)
-
- // 性格互补性得分
- const personalityScore = this.getPersonalityCompatibilityScore(myInfo, targetInfo)
-
- // 传统匹配度得分
- const traditionalScore = this.getTraditionalCompatibilityScore(myInfo.name, targetInfo.name)
-
- // 综合计算
- const total = Math.round((elementScore * 0.3 + personalityScore * 0.4 + traditionalScore * 0.3))
-
- // 确定等级和颜色
- let level, levelColor, scoreColor
-
- if (total >= 90) {
- level = '天作之合'
- levelColor = 'linear-gradient(135deg, #FF6B9D 0%, #FFA5C6 100%)'
- scoreColor = 'linear-gradient(135deg, #FF6B9D 0%, #FFA5C6 100%)'
- } else if (total >= 80) {
- level = '非常匹配'
- levelColor = 'linear-gradient(135deg, #4CAF50 0%, #81C784 100%)'
- scoreColor = 'linear-gradient(135deg, #4CAF50 0%, #81C784 100%)'
- } else if (total >= 70) {
- level = '比较合适'
- levelColor = 'linear-gradient(135deg, #2196F3 0%, #64B5F6 100%)'
- scoreColor = 'linear-gradient(135deg, #2196F3 0%, #64B5F6 100%)'
- } else if (total >= 60) {
- level = '需要努力'
- levelColor = 'linear-gradient(135deg, #FF9800 0%, #FFB74D 100%)'
- scoreColor = 'linear-gradient(135deg, #FF9800 0%, #FFB74D 100%)'
- } else {
- level = '挑战较大'
- levelColor = 'linear-gradient(135deg, #9E9E9E 0%, #BDBDBD 100%)'
- scoreColor = 'linear-gradient(135deg, #9E9E9E 0%, #BDBDBD 100%)'
- }
-
- return {
- total: total,
- level: level,
- levelColor: levelColor,
- scoreColor: scoreColor,
- details: [
- {
- label: '情感默契',
- icon: '💕',
- score: Math.min(elementScore + 10, 100),
- color: 'linear-gradient(135deg, #E91E63 0%, #FF6B9D 100%)'
- },
- {
- label: '性格互补',
- icon: '🤝',
- score: personalityScore,
- color: 'linear-gradient(135deg, #2196F3 0%, #64B5F6 100%)'
- },
- {
- label: '沟通理解',
- icon: '💬',
- score: Math.min(traditionalScore + 5, 100),
- color: 'linear-gradient(135deg, #4CAF50 0%, #81C784 100%)'
- },
- {
- label: '长期发展',
- icon: '🌱',
- score: Math.min(total - 5, 100),
- color: 'linear-gradient(135deg, #9C27B0 0%, #CE93D8 100%)'
- }
- ]
- }
- },
- // 获取元素相容性得分
- getElementCompatibilityScore(element1, element2) {
- const compatibilityMatrix = {
- '火象': { '火象': 85, '土象': 65, '风象': 90, '水象': 45 },
- '土象': { '火象': 65, '土象': 80, '风象': 55, '水象': 95 },
- '风象': { '火象': 90, '土象': 55, '风象': 75, '水象': 70 },
- '水象': { '火象': 45, '土象': 95, '风象': 70, '水象': 85 }
- }
-
- return compatibilityMatrix[element1]?.[element2] || 70
- },
- // 获取性格相容性得分
- getPersonalityCompatibilityScore(myInfo, targetInfo) {
- // 基于传统星座配对理论的得分
- const isInBestList = myInfo.compatibility.best.includes(targetInfo.name)
- const isInGoodList = myInfo.compatibility.good.includes(targetInfo.name)
- const isInAvoidList = myInfo.compatibility.avoid.includes(targetInfo.name)
-
- if (isInBestList) return 95
- if (isInGoodList) return 80
- if (isInAvoidList) return 50
-
- return 70 // 中性匹配
- },
- // 获取传统配对得分
- getTraditionalCompatibilityScore(constellation1, constellation2) {
- // 反向查找,确保双向匹配
- const info1 = constellationUtil.getConstellationInfo(constellation1)
- const info2 = constellationUtil.getConstellationInfo(constellation2)
-
- let score1 = 70, score2 = 70
-
- if (info1.compatibility.best.includes(constellation2)) score1 = 95
- else if (info1.compatibility.good.includes(constellation2)) score1 = 80
- else if (info1.compatibility.avoid.includes(constellation2)) score1 = 50
-
- if (info2.compatibility.best.includes(constellation1)) score2 = 95
- else if (info2.compatibility.good.includes(constellation1)) score2 = 80
- else if (info2.compatibility.avoid.includes(constellation1)) score2 = 50
-
- return Math.round((score1 + score2) / 2)
- },
- // 生成详细分析
- generateDetailedAnalysis(myInfo, targetInfo, baseScore) {
- const myElement = myInfo.element
- const targetElement = targetInfo.element
- const totalScore = baseScore.total
-
- // 生成优势分析
- const advantages = this.generateAdvantages(myInfo, targetInfo, myElement, targetElement)
-
- // 生成挑战分析
- const challenges = this.generateChallenges(myInfo, targetInfo, myElement, targetElement)
-
- // 生成建议
- const suggestions = this.generateSuggestions(myInfo, targetInfo, totalScore)
-
- // 生成总结
- const summary = this.generateSummary(myInfo, targetInfo, totalScore)
-
- // 元素相容性描述
- const elementCompatibility = this.getElementCompatibilityDescription(myElement, targetElement)
-
- // 爱情指数预测
- const lovePrediction = this.generateLovePrediction(myInfo, targetInfo, totalScore)
-
- return {
- advantages,
- challenges,
- suggestions,
- summary,
- elementCompatibility,
- lovePrediction
- }
- },
- // 生成优势分析
- generateAdvantages(myInfo, targetInfo, myElement, targetElement) {
- const advantages = []
-
- // 基于元素的优势
- if (myElement === targetElement) {
- advantages.push('你们属于同一元素,有着相似的价值观和生活节奏')
- } else if (
- (myElement === '火象' && targetElement === '风象') ||
- (myElement === '风象' && targetElement === '火象')
- ) {
- advantages.push('火象与风象的组合充满激情与创意,能够互相激发潜能')
- } else if (
- (myElement === '土象' && targetElement === '水象') ||
- (myElement === '水象' && targetElement === '土象')
- ) {
- advantages.push('土象与水象的结合稳定而温馨,能够建立深厚的情感基础')
- }
-
- // 基于性格特质的优势
- const commonTraits = myInfo.traits.filter(trait => targetInfo.traits.includes(trait))
- if (commonTraits.length > 0) {
- advantages.push(`你们都具有${commonTraits.join('、')}的特质,容易产生共鸣`)
- }
-
- // 基于星座特性的优势
- if (myInfo.compatibility.best.includes(targetInfo.name)) {
- advantages.push('从传统占星学角度来看,你们是非常理想的配对组合')
- }
-
- return advantages.join(';') || '你们的组合有着独特的魅力,能够在相处中发现彼此的闪光点。'
- },
- // 生成挑战分析
- generateChallenges(myInfo, targetInfo, myElement, targetElement) {
- const challenges = []
-
- // 基于元素的挑战
- if (
- (myElement === '火象' && targetElement === '水象') ||
- (myElement === '水象' && targetElement === '火象')
- ) {
- challenges.push('火象与水象的组合可能在表达方式上存在差异,需要更多理解')
- } else if (
- (myElement === '土象' && targetElement === '风象') ||
- (myElement === '风象' && targetElement === '土象')
- ) {
- challenges.push('土象的稳重与风象的多变可能产生摩擦,需要找到平衡点')
- }
-
- // 基于避免列表的挑战
- if (myInfo.compatibility.avoid.includes(targetInfo.name)) {
- challenges.push('你们的性格差异较大,需要更多的耐心和包容来磨合')
- }
-
- // 通用挑战
- challenges.push('任何关系都需要双方的努力和妥协,保持开放的沟通很重要')
-
- return challenges.join(';')
- },
- // 生成建议
- generateSuggestions(myInfo, targetInfo, totalScore) {
- const suggestions = []
-
- if (totalScore >= 80) {
- suggestions.push('你们的匹配度很高,要珍惜这份缘分,在相处中保持真诚和理解')
- } else if (totalScore >= 60) {
- suggestions.push('通过增进了解和有效沟通,你们的关系会更加稳固')
- } else {
- suggestions.push('虽然挑战较大,但只要双方都愿意努力,任何困难都可以克服')
- }
-
- // 基于星座特性的建议
- suggestions.push(`理解${myInfo.name}的${myInfo.personality}和${targetInfo.name}的${targetInfo.personality},互相欣赏对方的独特之处`)
-
- suggestions.push('记住,星座只是参考,真正的爱情需要用心经营')
-
- return suggestions.join(';')
- },
- // 生成总结
- generateSummary(myInfo, targetInfo, totalScore) {
- if (totalScore >= 90) {
- return `${myInfo.name}与${targetInfo.name}的组合堪称天作之合,你们在各个方面都有着很好的默契,是令人羡慕的一对。只要继续保持这份美好,未来充满无限可能。`
- } else if (totalScore >= 80) {
- return `${myInfo.name}与${targetInfo.name}是非常匹配的组合,你们能够互相理解和支持。虽然偶尔会有小摩擦,但总体来说是和谐美好的一对。`
- } else if (totalScore >= 70) {
- return `${myInfo.name}与${targetInfo.name}的组合比较合适,需要双方多一些耐心和理解。通过磨合和沟通,你们能够建立稳定的关系。`
- } else if (totalScore >= 60) {
- return `${myInfo.name}与${targetInfo.name}的组合需要更多努力,但这并不意味着不可能。只要双方都愿意为这份感情付出,就能克服困难。`
- } else {
- return `${myInfo.name}与${targetInfo.name}的组合面临较大挑战,需要极大的包容和理解。不过,真爱面前没有不可能,关键在于是否愿意为对方改变。`
- }
- },
- // 获取元素相容性描述
- getElementCompatibilityDescription(element1, element2) {
- const descriptions = {
- '火象火象': '同为火象星座,你们都充满激情和活力,能够互相理解对方的冲动和热情',
- '火象土象': '火象的激情与土象的稳重形成互补,但需要找到节奏的平衡点',
- '火象风象': '火象与风象的结合如同火遇风,能够互相激发,创造出更大的能量',
- '火象水象': '火象与水象的组合对比强烈,需要更多的理解和包容',
- '土象土象': '同为土象星座,你们都追求稳定和安全感,能够建立坚实的关系基础',
- '土象风象': '土象的踏实与风象的灵活可能产生分歧,需要相互学习和适应',
- '土象水象': '土象与水象的组合非常和谐,既有稳定性又有情感深度',
- '风象风象': '同为风象星座,你们都重视精神交流,思维活跃,有很多共同话题',
- '风象水象': '风象的理性与水象的感性形成有趣的对比,能够互相学习',
- '水象水象': '同为水象星座,你们情感丰富,能够深度理解彼此的内心世界'
- }
-
- const key = element1 + element2
- return descriptions[key] || descriptions[element2 + element1] || '你们的元素组合有着独特的化学反应'
- },
- // 生成爱情指数预测
- generateLovePrediction(myInfo, targetInfo, totalScore) {
- const baseScore = totalScore
-
- return [
- {
- label: '初见印象',
- icon: '👀',
- value: Math.min(baseScore + Math.floor(Math.random() * 10) - 5, 100) + '%',
- bgColor: 'linear-gradient(135deg, #FFB6C1 0%, #FFE4E1 100%)'
- },
- {
- label: '恋爱甜蜜度',
- icon: '🍯',
- value: Math.min(baseScore + Math.floor(Math.random() * 15) - 7, 100) + '%',
- bgColor: 'linear-gradient(135deg, #FF6B9D 0%, #FFA5C6 100%)'
- },
- {
- label: '长期稳定性',
- icon: '🏠',
- value: Math.min(baseScore + Math.floor(Math.random() * 8) - 4, 100) + '%',
- bgColor: 'linear-gradient(135deg, #4CAF50 0%, #81C784 100%)'
- },
- {
- label: '婚姻契合度',
- icon: '💍',
- value: Math.min(baseScore + Math.floor(Math.random() * 12) - 6, 100) + '%',
- bgColor: 'linear-gradient(135deg, #9C27B0 0%, #CE93D8 100%)'
- }
- ]
- },
- // 获取元素描述
- getElementDescription(element) {
- const descriptions = {
- '火象': '热情、积极、冲动',
- '土象': '稳重、务实、踏实',
- '风象': '理智、灵活、善变',
- '水象': '感性、直觉、温柔'
- }
- return descriptions[element] || element
- },
- // 重新配对
- handleRetest() {
- this.hasResult = false
- this.myConstellation = ''
- this.targetConstellation = ''
- this.myConstellationIndex = -1
- this.targetConstellationIndex = -1
- this.matchResult = null
- this.myConstellationInfo = null
- this.targetConstellationInfo = null
- },
- // 返回
- goBack() {
- uni.navigateBack({
- delta: 1
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .constellation-match-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;
- }
- }
- /* 星座选择区域 */
- .constellation-selection-section {
- padding: 60rpx 30rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- .selection-card {
- width: 100%;
- background-color: #FFFFFF;
- border-radius: 30rpx;
- padding: 60rpx 40rpx;
- box-shadow: 0 8rpx 30rpx rgba(233, 30, 99, 0.1);
- text-align: center;
- .card-title {
- font-size: 40rpx;
- font-weight: bold;
- color: #333333;
- margin-bottom: 15rpx;
- }
- .card-subtitle {
- font-size: 26rpx;
- color: #999999;
- margin-bottom: 50rpx;
- }
- .constellation-picker-wrapper {
- margin-bottom: 30rpx;
- text-align: left;
-
- .picker-label {
- font-size: 28rpx;
- color: #666666;
- margin-bottom: 15rpx;
- }
- .constellation-display {
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #F8F8F8;
- border-radius: 20rpx;
- padding: 25rpx 30rpx;
- border: 2rpx solid #E91E63;
- transition: all 0.3s;
- .constellation-emoji {
- font-size: 40rpx;
- margin-right: 15rpx;
- }
- .constellation-text {
- font-size: 32rpx;
- color: #333333;
- font-weight: 500;
- }
- }
-
- &:active .constellation-display {
- background-color: #FFE5EE;
- transform: scale(0.98);
- }
- }
- .submit-btn {
- width: 100%;
- height: 90rpx;
- background: linear-gradient(135deg, #E91E63 0%, #FF6B9D 100%);
- color: #FFFFFF;
- font-size: 32rpx;
- font-weight: 600;
- border-radius: 45rpx;
- border: none;
- box-shadow: 0 8rpx 20rpx rgba(233, 30, 99, 0.3);
- &:disabled {
- opacity: 0.5;
- }
- &:active:not(:disabled) {
- opacity: 0.9;
- }
- }
- }
- .constellation-icons {
- display: flex;
- flex-wrap: wrap;
- justify-content: center;
- gap: 20rpx;
- margin-top: 50rpx;
- opacity: 0.3;
- .constellation-icon {
- font-size: 48rpx;
- animation: float 3s ease-in-out infinite;
- &:nth-child(2n) {
- animation-delay: 0.5s;
- }
- &:nth-child(3n) {
- animation-delay: 1s;
- }
- }
- }
- }
- @keyframes float {
- 0%, 100% {
- transform: translateY(0);
- }
- 50% {
- transform: translateY(-10rpx);
- }
- }
- /* 结果区域 */
- .result-section {
- padding: 30rpx 25rpx 40rpx 25rpx;
- }
- /* 配对标题卡片 */
- .match-title-card {
- background: linear-gradient(135deg, #FF6B9D 0%, #FFA5C6 100%);
- border-radius: 32rpx;
- padding: 60rpx 40rpx;
- text-align: center;
- box-shadow: 0 12rpx 40rpx rgba(233, 30, 99, 0.25);
- margin-bottom: 40rpx;
- .match-header {
- text-align: center;
-
- .constellation-pair {
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 30rpx;
-
- .constellation-emoji-large {
- font-size: 120rpx;
- }
-
- .vs-text {
- font-size: 70rpx;
- margin: 0 30rpx;
- }
- }
- .match-title {
- font-size: 42rpx;
- font-weight: bold;
- color: #FFFFFF;
- margin-bottom: 15rpx;
- letter-spacing: 2rpx;
- }
- .match-subtitle {
- font-size: 28rpx;
- color: rgba(255, 255, 255, 0.9);
- }
- }
- }
- /* 通用标题 */
- .section-title {
- font-size: 36rpx;
- font-weight: 600;
- color: #333333;
- margin-bottom: 25rpx;
- padding: 0 10rpx;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- }
- /* 配对分数 */
- .score-section {
- margin-bottom: 40rpx;
-
- .score-card {
- background-color: #FFFFFF;
- border-radius: 24rpx;
- padding: 40rpx 30rpx;
- box-shadow: 0 6rpx 24rpx rgba(0, 0, 0, 0.08);
-
- .score-main {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 40rpx;
- padding-bottom: 30rpx;
- border-bottom: 1rpx solid #F0F0F0;
- .score-circle {
- width: 150rpx;
- height: 150rpx;
- border-radius: 50%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- color: #FFFFFF;
- .score-number {
- font-size: 48rpx;
- font-weight: bold;
- line-height: 1;
- }
- .score-unit {
- font-size: 24rpx;
- margin-top: 5rpx;
- }
- }
- .score-level {
- padding: 15rpx 40rpx;
- border-radius: 30rpx;
- font-size: 32rpx;
- color: #FFFFFF;
- font-weight: 600;
- }
- }
- .score-breakdown {
- .score-item {
- margin-bottom: 25rpx;
- &:last-child {
- margin-bottom: 0;
- }
- .score-item-header {
- display: flex;
- align-items: center;
- margin-bottom: 12rpx;
- .score-item-icon {
- font-size: 28rpx;
- margin-right: 12rpx;
- }
- .score-item-label {
- font-size: 28rpx;
- color: #333333;
- font-weight: 500;
- }
- }
- .score-progress {
- display: flex;
- align-items: center;
- .progress-bar {
- flex: 1;
- height: 12rpx;
- background-color: #F0F0F0;
- border-radius: 6rpx;
- overflow: hidden;
- margin-right: 15rpx;
- .progress-fill {
- height: 100%;
- border-radius: 6rpx;
- transition: width 0.6s ease;
- }
- }
- .progress-text {
- font-size: 24rpx;
- color: #E91E63;
- font-weight: 600;
- min-width: 60rpx;
- text-align: right;
- }
- }
- }
- }
- }
- }
- /* API专业分析 */
- .api-analysis-section {
- margin-bottom: 40rpx;
-
- .api-analysis-card {
- background: linear-gradient(135deg, #E8F5E9 0%, #F1F8E9 100%);
- border-radius: 24rpx;
- padding: 0;
- box-shadow: 0 6rpx 24rpx rgba(76, 175, 80, 0.15);
- overflow: hidden;
- border-left: 6rpx solid #4CAF50;
-
- .api-grade-item, .api-content-item {
- padding: 30rpx;
- border-bottom: 1rpx solid rgba(76, 175, 80, 0.1);
-
- &:last-child {
- border-bottom: none;
- }
-
- .grade-header, .content-header {
- display: flex;
- align-items: center;
- margin-bottom: 15rpx;
-
- .grade-icon, .content-icon {
- font-size: 32rpx;
- margin-right: 15rpx;
- }
-
- .grade-title, .content-title {
- font-size: 30rpx;
- color: #2E7D32;
- font-weight: 600;
- }
- }
-
- .grade-content, .content-text {
- font-size: 28rpx;
- color: #333333;
- line-height: 1.8;
- text-align: justify;
- margin-left: 47rpx;
- }
-
- .grade-content {
- color: #4CAF50;
- font-weight: 500;
- }
- }
- }
- }
- /* 配对分析 */
- .match-analysis-section {
- margin-bottom: 40rpx;
-
- .analysis-card {
- background-color: #FFFFFF;
- border-radius: 24rpx;
- padding: 0;
- box-shadow: 0 6rpx 24rpx rgba(0, 0, 0, 0.08);
- overflow: hidden;
-
- .analysis-item {
- padding: 30rpx;
- border-bottom: 1rpx solid #F5F5F5;
-
- &:last-child {
- border-bottom: none;
- }
-
- .analysis-header {
- display: flex;
- align-items: center;
- margin-bottom: 15rpx;
-
- .analysis-icon {
- font-size: 32rpx;
- margin-right: 15rpx;
- }
-
- .analysis-title {
- font-size: 30rpx;
- color: #E91E63;
- font-weight: 600;
- }
- }
-
- .analysis-content {
- font-size: 28rpx;
- color: #333333;
- line-height: 1.8;
- text-align: justify;
- margin-left: 47rpx;
- }
- }
- }
- }
- /* 元素分析 */
- .element-analysis-section {
- margin-bottom: 40rpx;
-
- .element-card {
- background-color: #FFFFFF;
- border-radius: 24rpx;
- padding: 40rpx 30rpx;
- box-shadow: 0 6rpx 24rpx rgba(0, 0, 0, 0.08);
-
- .element-pair {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 30rpx;
-
- .element-item {
- flex: 1;
- text-align: center;
-
- .element-name {
- display: block;
- font-size: 32rpx;
- color: #E91E63;
- font-weight: 600;
- margin-bottom: 10rpx;
- }
-
- .element-desc {
- font-size: 24rpx;
- color: #666666;
- }
- }
-
- .element-vs {
- font-size: 28rpx;
- color: #999999;
- font-weight: 600;
- margin: 0 20rpx;
- }
- }
-
- .element-compatibility {
- background: linear-gradient(135deg, #F3E5F5 0%, #FFEEF5 100%);
- border-radius: 15rpx;
- padding: 25rpx;
- text-align: center;
-
- .compatibility-label {
- display: block;
- font-size: 24rpx;
- color: #9C27B0;
- margin-bottom: 10rpx;
- }
-
- .compatibility-result {
- font-size: 28rpx;
- color: #333333;
- line-height: 1.6;
- }
- }
- }
- }
- /* 特质对比 */
- .traits-comparison-section {
- margin-bottom: 40rpx;
-
- .traits-card {
- background-color: #FFFFFF;
- border-radius: 24rpx;
- padding: 40rpx 30rpx;
- box-shadow: 0 6rpx 24rpx rgba(0, 0, 0, 0.08);
-
- .traits-comparison {
- display: flex;
- gap: 30rpx;
-
- .traits-column {
- flex: 1;
-
- .traits-header {
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 20rpx;
-
- .traits-emoji {
- font-size: 40rpx;
- margin-right: 10rpx;
- }
-
- .traits-name {
- font-size: 28rpx;
- color: #333333;
- font-weight: 600;
- }
- }
-
- .trait-tag {
- display: inline-block;
- background: linear-gradient(135deg, #E3F2FD 0%, #F0F8FF 100%);
- color: #2196F3;
- font-size: 22rpx;
- padding: 8rpx 16rpx;
- border-radius: 20rpx;
- margin: 5rpx;
- border: 1rpx solid #2196F3;
- }
- }
- }
- }
- }
- /* 爱情指数预测 */
- .love-prediction-section {
- margin-bottom: 40rpx;
- .prediction-grid {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 20rpx;
- .prediction-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- background-color: #FFFFFF;
- border-radius: 15rpx;
- padding: 30rpx 20rpx;
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
- .prediction-icon-wrapper {
- width: 80rpx;
- height: 80rpx;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 15rpx;
- .prediction-icon {
- font-size: 40rpx;
- }
- }
- .prediction-label {
- font-size: 24rpx;
- color: #999999;
- margin-bottom: 8rpx;
- }
- .prediction-value {
- font-size: 28rpx;
- color: #333333;
- font-weight: 600;
- }
- }
- }
- }
- /* 重新配对 */
- .retest-btn {
- text-align: center;
- padding: 30rpx 40rpx;
- font-size: 30rpx;
- color: #666666;
- background-color: #F8F8F8;
- border-radius: 25rpx;
- margin: 20rpx 20rpx 30rpx 20rpx;
- border: 2rpx solid #E0E0E0;
- &:active {
- color: #E91E63;
- background-color: #FFF0F5;
- border-color: #E91E63;
- }
- }
- /* 数据来源说明 */
- .data-source {
- display: flex;
- align-items: center;
- background-color: #E3F2FD;
- border-radius: 20rpx;
- padding: 25rpx 30rpx;
- margin-bottom: 30rpx;
- transition: all 0.3s;
- .source-icon {
- font-size: 32rpx;
- margin-right: 15rpx;
- }
- .source-content {
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 8rpx;
- .source-text {
- font-size: 28rpx;
- color: #1976D2;
- font-weight: 500;
- }
- .source-time {
- font-size: 24rpx;
- color: #64B5F6;
- }
- }
-
- // API数据特殊样式
- &.api-source {
- background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
- border-left: 6rpx solid #4CAF50;
- .source-icon {
- color: #4CAF50;
- }
- .source-text {
- color: #2E7D32;
- }
- .source-time {
- color: #66BB6A;
- }
- }
- }
- /* 免责声明 */
- .disclaimer {
- background-color: #FFF3E0;
- border-radius: 20rpx;
- padding: 30rpx;
- border-left: 6rpx solid #FF9800;
- margin: 0 10rpx;
- .disclaimer-title {
- font-size: 30rpx;
- font-weight: 600;
- color: #F57C00;
- margin-bottom: 20rpx;
- }
- .disclaimer-text {
- font-size: 26rpx;
- color: #666666;
- line-height: 2.0;
- text-align: justify;
- }
- }
- /* 底部占位 */
- .bottom-placeholder {
- height: 60rpx;
- }
- </style>
|