index.vue 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825
  1. <template>
  2. <view class="home-page">
  3. <!-- 顶部状态栏 -->
  4. <view class="top-bar">
  5. <view class="logo">婚恋</view>
  6. <view class="top-right-icons">
  7. <!-- 红娘工作台切换按钮 - 根据数据库查询结果动态显示 -->
  8. <view v-if="showMatchmakerButton"
  9. class="matchmaker-btn" @click="openMatchmakerPopup">
  10. <text class="switch-icon">🔄</text>
  11. <text class="switch-text">切换工作台</text>
  12. </view>
  13. <!-- 消息通知图标 -->
  14. <view class="msg-icon" @click="goToMessages">
  15. <text class="icon">🔔</text>
  16. <view v-if="unreadCount > 0" class="badge">{{ unreadCount }}</view>
  17. </view>
  18. </view>
  19. </view>
  20. <!-- 个性化欢迎语 -->
  21. <!-- <view class="welcome-card" v-if="userInfo.nickname">
  22. <view class="welcome-content">
  23. <text class="welcome-text">你好,{{ userInfo.nickname }}!</text>
  24. <text class="match-info">今天有 <text class="highlight">{{ matchCount }}</text> 位新嘉宾和你匹配哦 ❤️</text>
  25. </view>
  26. </view> -->
  27. <!-- 轮播图 -->
  28. <view class="banner-section" v-if="bannerList && bannerList.length > 0">
  29. <swiper class="banner-swiper" :indicator-dots="true" :autoplay="true" :interval="4000" :duration="1000"
  30. :circular="true" indicator-color="rgba(255, 255, 255, 0.5)" indicator-active-color="#E91E63">
  31. <swiper-item v-for="(banner, index) in bannerList" :key="index">
  32. <view class="banner-item" @click="handleBannerClick(banner)">
  33. <image :src="banner.cover_image || banner.coverImage" class="banner-image" mode="aspectFill"
  34. :data-section="'banner'" :data-index="index"
  35. @error="handleImageError" @load="handleImageLoad"></image>
  36. <view class="banner-mask">
  37. <view class="banner-title">{{ banner.name }}</view>
  38. <view class="banner-subtitle" v-if="banner.subtitle">{{ banner.subtitle }}</view>
  39. <view class="banner-btn">查看更多</view>
  40. </view>
  41. </view>
  42. </swiper-item>
  43. </swiper>
  44. </view>
  45. <!-- 小喇叭公告栏 -->
  46. <view class="notice-bar" v-if="noticeList && noticeList.length > 0">
  47. <text class="notice-icon">📢</text>
  48. <swiper class="notice-swiper" vertical :autoplay="true" :interval="3000" :duration="500"
  49. :circular="true">
  50. <swiper-item v-for="(notice, index) in noticeList" :key="index">
  51. <view class="notice-text">{{ notice.content }}</view>
  52. </swiper-item>
  53. </swiper>
  54. </view>
  55. <!-- 核心功能入口 -->
  56. <view class="function-grid">
  57. <view class="grid-item" v-for="(item, index) in functionList" :key="index" @click="handleFunctionClick(item)">
  58. <view class="grid-icon-wrapper" :style="{ background: item.gradient || item.bgColor || '#FFE5F1' }">
  59. <text class="grid-icon" :style="{ color: item.iconColor || '#333333' }">{{ item.icon }}</text>
  60. </view>
  61. <text class="grid-text">{{ item.name }}</text>
  62. </view>
  63. </view>
  64. <!-- 成功案例 -->
  65. <view class="section success-case-section" v-if="successCases && successCases.length > 0">
  66. <view class="section-header">
  67. <text class="section-title">💕 成功案例</text>
  68. <text class="section-more" @click="goToSuccessCaseList">查看更多 ></text>
  69. </view>
  70. <view class="success-case-grid">
  71. <view class="case-card" v-for="(caseItem, index) in successCases.slice(0, 2)" :key="index"
  72. @click="handleSuccessCaseClick(caseItem)">
  73. <view class="case-image-wrapper">
  74. <image :src="caseItem.imageUrl" class="case-image" mode="aspectFill"
  75. :data-section="'successCase'" :data-index="index"
  76. @error="handleImageError" @load="handleImageLoad"></image>
  77. </view>
  78. <view class="case-content">
  79. <view class="couple-names">{{ caseItem.maleUserNickname || '先生' }}&{{ caseItem.femaleUserNickname || '女士' }}</view>
  80. <view class="case-quote">{{ caseItem.quote || '我们通过平台找到了彼此❤️' }}</view>
  81. <view class="case-meta">
  82. <text class="marriage-date">相识于{{ formatMarriageDate(caseItem.marriageDate) }}</text>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <!-- 平台活动 -->
  89. <view class="section activity-recommend-section" v-if="hotActivities && hotActivities.length > 0">
  90. <view class="section-header">
  91. <text class="section-title">🎉 平台活动</text>
  92. <text class="section-more" @click="goToActivityList">查看更多 ></text>
  93. </view>
  94. <view class="activity-scroll-container">
  95. <view class="activity-scroll-wrapper">
  96. <view class="activity-scroll-content">
  97. <!-- 第一组活动 -->
  98. <view class="activity-card-scroll" v-for="(activity, index) in hotActivities" :key="index"
  99. @click="handleActivityClick(activity)">
  100. <view class="activity-image-wrapper">
  101. <image :src="activity.cover_image" class="activity-image" mode="aspectFill"
  102. :data-section="'activity'" :data-index="index"
  103. @error="handleImageError" @load="handleImageLoad"></image>
  104. <view class="activity-status" v-if="activity.status === 1">报名中</view>
  105. </view>
  106. <view class="activity-info-static">
  107. <view class="activity-name-static">{{ activity.name }}</view>
  108. <view class="activity-time-static">{{ formatActivityTime(activity.startTime, activity.endTime) }}</view>
  109. </view>
  110. </view>
  111. <!-- 第二组活动(用于无缝滚动) -->
  112. <view class="activity-card-scroll" v-for="(activity, index) in hotActivities" :key="index + 100"
  113. @click="handleActivityClick(activity)">
  114. <view class="activity-image-wrapper">
  115. <image :src="activity.coverImage" class="activity-image" mode="aspectFill"
  116. :data-section="'activity'" :data-index="index + 100"
  117. @error="handleImageError" @load="handleImageLoad"></image>
  118. <view class="activity-status" v-if="activity.status === 1">报名中</view>
  119. </view>
  120. <view class="activity-info-static">
  121. <view class="activity-name-static">{{ activity.name }}</view>
  122. <view class="activity-time-static">{{ formatActivityTime(activity.startTime, activity.endTime) }}</view>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. <!-- 今日缘分推荐 -->
  130. <!-- <view class="section fate-recommend-section" v-if="todayRecommendUsers && todayRecommendUsers.length > 0">
  131. <view class="section-header">
  132. <text class="section-title">🌟 今日缘分</text>
  133. <text class="section-more" @click="goToRecommend">查看更多 ></text>
  134. </view>
  135. <view class="fate-cards">
  136. <view class="fate-card" v-for="(user, index) in todayRecommendUsers" :key="index"
  137. @click="handleUserClick(user)">
  138. <view class="user-avatar-wrapper">
  139. <image :src="user.avatarUrl || user.avatar" class="user-avatar" mode="aspectFill"
  140. :data-section="'todayRecommend'" :data-index="index"
  141. @error="handleImageError" @load="handleImageLoad"></image>
  142. <view class="online-status" v-if="user.isOnline"></view>
  143. </view>
  144. <view class="user-basic-info">
  145. <text class="user-nickname">{{ user.nickname }}</text>
  146. <text class="user-age-location">{{ user.age }}岁 · {{ user.location || user.city }}</text>
  147. </view>
  148. <view class="match-score">
  149. <text class="match-text">匹配度</text>
  150. <text class="match-percentage">{{ formatMatchScore(user.compatibilityScore) }}%</text>
  151. </view>
  152. <view class="user-tags">
  153. <text class="user-tag" v-for="(tag, tagIndex) in parseUserTags(user).slice(0, 2)" :key="tagIndex">
  154. {{ tag }}
  155. </text>
  156. </view>
  157. </view>
  158. </view>
  159. </view> -->
  160. <!-- 个人魅力指数 -->
  161. <view class="section charm-index-section" v-if="userInfo.userId">
  162. <view class="charm-card">
  163. <view class="charm-header">
  164. <text class="charm-title">💖 个人魅力指数</text>
  165. <text class="charm-score">{{ charmIndex.totalScore }}</text>
  166. </view>
  167. <view class="charm-progress">
  168. <view class="progress-bar">
  169. <view class="progress-fill" :style="{ width: charmIndex.totalScore + '%' }"></view>
  170. </view>
  171. <text class="progress-text">超越了{{ charmIndex.beatPercentage }}%的用户</text>
  172. </view>
  173. <view class="charm-items">
  174. <view class="charm-item" v-for="(item, index) in charmIndex.items" :key="index">
  175. <text class="charm-item-label">{{ item.label }}</text>
  176. <view class="charm-item-progress">
  177. <view class="item-progress-bar">
  178. <view class="item-progress-fill" :style="{ width: item.score + '%' }"></view>
  179. </view>
  180. <text class="charm-item-score">{{ item.score }}%</text>
  181. </view>
  182. </view>
  183. </view>
  184. <view class="charm-tip">
  185. <text class="tip-text">💡 {{ charmIndex.tip }}</text>
  186. </view>
  187. </view>
  188. </view>
  189. <!-- 底部占位 -->
  190. <view class="bottom-placeholder"></view>
  191. <!-- 底部导航栏 -->
  192. <view class="tabbar">
  193. <view class="tabbar-item active" @click="switchTab('index')">
  194. <text class="tabbar-icon">🏠</text>
  195. <text class="tabbar-text">首页</text>
  196. </view>
  197. <view class="tabbar-item" @click="switchTab('plaza')">
  198. <text class="tabbar-icon">💕</text>
  199. <text class="tabbar-text">动态</text>
  200. </view>
  201. <view class="tabbar-item" @click="switchTab('recommend')">
  202. <text class="tabbar-icon">👍</text>
  203. <text class="tabbar-text">推荐</text>
  204. </view>
  205. <view class="tabbar-item" @click="switchTab('message')">
  206. <text class="tabbar-icon">💬</text>
  207. <text class="tabbar-text">消息</text>
  208. <view v-if="unreadCount >= 1" class="tabbar-badge">{{ unreadCount }}</view>
  209. </view>
  210. <view class="tabbar-item" @click="switchTab('mine')">
  211. <text class="tabbar-icon">👤</text>
  212. <text class="tabbar-text">我的</text>
  213. </view>
  214. </view>
  215. <!-- 红娘提示弹框 -->
  216. <uni-popup ref="matchmakerPopup" type="dialog">
  217. <uni-popup-dialog
  218. type="confirm"
  219. title="红娘工作台"
  220. content="您是平台认证红娘,是否前往红娘工作台?"
  221. confirmText="前往工作台"
  222. cancelText="取消"
  223. @confirm="goToMatchmakerWorkspace"
  224. @cancel="closeMatchmakerPopup">
  225. </uni-popup-dialog>
  226. </uni-popup>
  227. </view>
  228. </template>
  229. <script>
  230. import api, { request } from '@/utils/api.js'
  231. import { formatTime, formatCountdown, isLoggedIn, goToLogin } from '@/utils/util.js'
  232. import { DEFAULT_IMAGES, ACTIVITY_TYPES } from '@/config/index.js'
  233. import timManager from '@/utils/tim-manager.js'
  234. export default {
  235. data() {
  236. return {
  237. // 用户信息
  238. userInfo: {},
  239. matchCount: 3,
  240. // 是否显示红娘工作台按钮(根据数据库查询结果)
  241. showMatchmakerButton: false,
  242. // 轮播图数据
  243. bannerList: [],
  244. // 公告数据
  245. noticeList: [],
  246. // 功能入口
  247. functionList: [],
  248. // 热门活动
  249. hotActivities: [],
  250. // 成功案例
  251. successCases: [],
  252. // VIP特权(保留但不在首页显示)
  253. vipPrivileges: [
  254. { icon: '💎', text: '专属红娘服务' },
  255. { icon: '⚡', text: '优先匹配推荐' },
  256. { icon: '👑', text: '贵族身份标识' },
  257. { icon: '🔒', text: '隐身访问模式' }
  258. ],
  259. // 今日推荐用户
  260. todayRecommendUsers: [],
  261. // 个人魅力指数
  262. charmIndex: {
  263. totalScore: 75,
  264. beatPercentage: 68,
  265. items: [
  266. { label: '资料完整度', score: 80 },
  267. { label: '活跃度', score: 70 },
  268. { label: '互动质量', score: 75 },
  269. { label: '形象分数', score: 72 }
  270. ],
  271. tip: '完善更多个人信息可提升魅力指数'
  272. },
  273. // 倒计时定时器
  274. countdownTimer: null,
  275. // 图片加载错误计数
  276. imageErrorCount: 0,
  277. // 是否已经显示过红娘弹框(避免重复显示)
  278. hasShownMatchmakerPopup: false
  279. }
  280. },
  281. computed: {
  282. // 从Vuex获取全局未读数
  283. unreadCount() {
  284. return this.$store.getters.getTotalUnread || 0;
  285. }
  286. },
  287. onLoad() {
  288. this.loadUserInfo()
  289. this.loadBannerData()
  290. this.loadNoticeData()
  291. this.loadFunctionGridData()
  292. // this.loadTodayRecommend()
  293. this.loadCharmIndex()
  294. this.loadHotActivities()
  295. this.loadSuccessCases()
  296. // 监听未读消息数更新事件
  297. uni.$on('conversationUnreadUpdate', (totalUnread) => {
  298. console.log('📬 首页收到未读数更新:', totalUnread);
  299. this.$store.dispatch('updateTotalUnread', totalUnread);
  300. });
  301. },
  302. onUnload() {
  303. // 清理资源
  304. uni.$off('conversationUnreadUpdate');
  305. },
  306. onShow() {
  307. console.log('📱 页面onShow触发')
  308. // 页面显示时重新加载用户信息(确保登录后能更新)
  309. this.loadUserInfo()
  310. // 页面显示时查询数据库检查是否为红娘
  311. this.checkMatchmakerStatusFromDB()
  312. },
  313. methods: {
  314. // 从数据库查询用户是否为红娘
  315. async checkMatchmakerStatusFromDB() {
  316. try {
  317. const userId = uni.getStorageSync('userId')
  318. if (!userId) {
  319. console.log('⚠️ 用户未登录,不显示红娘按钮')
  320. this.showMatchmakerButton = false
  321. return
  322. }
  323. console.log('🔍 查询用户红娘状态,userId:', userId)
  324. // 调用API查询用户的is_matchmaker字段
  325. const result = await api.user.getMatchmakerStatus(userId)
  326. if (result && result.isMatchmaker !== undefined) {
  327. const isMatchmaker = parseInt(result.isMatchmaker)
  328. console.log('✅ 查询成功,isMatchmaker:', isMatchmaker)
  329. // 根据查询结果设置按钮显示状态
  330. this.showMatchmakerButton = (isMatchmaker === 1)
  331. // 同时更新本地存储的用户信息
  332. const userInfo = uni.getStorageSync('userInfo') || {}
  333. userInfo.isMatchmaker = isMatchmaker
  334. uni.setStorageSync('userInfo', userInfo)
  335. this.userInfo.isMatchmaker = isMatchmaker
  336. console.log('🎯 红娘按钮显示状态:', this.showMatchmakerButton ? '显示' : '隐藏')
  337. } else {
  338. console.log('⚠️ 查询结果异常,不显示红娘按钮')
  339. this.showMatchmakerButton = false
  340. }
  341. } catch (error) {
  342. console.error('❌ 查询红娘状态失败:', error)
  343. this.showMatchmakerButton = false
  344. }
  345. },
  346. // 前往红娘工作台
  347. async goToMatchmakerWorkspace() {
  348. console.log('🚀 前往红娘工作台')
  349. this.$refs.matchmakerPopup.close()
  350. try {
  351. const userId = uni.getStorageSync('userId')
  352. if (!userId) {
  353. uni.showToast({ title: '请先登录', icon: 'none' })
  354. return
  355. }
  356. if (!timManager.tim) {
  357. try {
  358. timManager.init(1600109674)
  359. console.log('✅ TIM SDK 初始化完成(首页)')
  360. } catch (e) {
  361. console.error('❌ TIM 初始化失败(首页):', e)
  362. }
  363. }
  364. const res = await uni.request({
  365. url: 'http://localhost:8081/api/matchmaker/current',
  366. method: 'GET',
  367. data: { userId }
  368. })
  369. if (!res[1] || res[1].data.code !== 200) {
  370. uni.showToast({ title: '获取红娘信息失败', icon: 'none' })
  371. return
  372. }
  373. const matchmakerInfo = res[1].data.data || {}
  374. const imUserId = matchmakerInfo.imUserId
  375. if (!imUserId) {
  376. uni.showToast({ title: '红娘IM账号缺失', icon: 'none' })
  377. return
  378. }
  379. // 获取UserSig时使用原始imUserId(包含m_前缀)
  380. const sigRes = await uni.request({
  381. url: `http://localhost:8083/api/im/getUserSig?userId=${encodeURIComponent(imUserId)}`,
  382. method: 'GET'
  383. })
  384. if (!sigRes[1] || sigRes[1].data.code !== 200) {
  385. uni.showToast({ title: '获取UserSig失败', icon: 'none' })
  386. return
  387. }
  388. const userSig = sigRes[1].data.data.userSig
  389. console.log('✅ 首页获取 UserSig:', userSig ? '成功' : '失败')
  390. try {
  391. await timManager.logout()
  392. console.log('✅ 已登出之前的IM账号(首页)')
  393. } catch (e) {
  394. console.log('⚠️ 登出失败或未登录(首页):', e.message)
  395. }
  396. await timManager.login(imUserId, userSig)
  397. console.log('✅ 红娘已在首页登录 IM:', imUserId)
  398. uni.$emit('matchmakerIMReady', { imUserId })
  399. } catch (error) {
  400. console.error('❌ 首页初始化红娘IM失败:', error)
  401. uni.showToast({ title: '红娘IM初始化失败', icon: 'none' })
  402. }
  403. uni.navigateTo({
  404. url: '/pages/matchmaker-workbench/index',
  405. fail: (err) => {
  406. console.error('❌ 跳转红娘工作台失败:', err)
  407. uni.showToast({ title: '跳转失败', icon: 'none' })
  408. }
  409. })
  410. },
  411. // 关闭红娘弹框
  412. closeMatchmakerPopup() {
  413. console.log('🚫 用户选择不前往红娘工作台')
  414. this.$refs.matchmakerPopup.close()
  415. },
  416. // 加载用户信息
  417. loadUserInfo() {
  418. // 从本地存储或接口获取用户信息
  419. const userInfo = uni.getStorageSync('userInfo')
  420. if (userInfo) {
  421. this.userInfo = userInfo
  422. this.matchCount = Math.floor(Math.random() * 10) + 1
  423. }
  424. },
  425. // 加载轮播图数据
  426. async loadBannerData() {
  427. try {
  428. // 调用 API 获取轮播图数据
  429. const data = await api.home.getBanners()
  430. if (data && data.length > 0) {
  431. // 处理轮播图数据,确保字段格式正确
  432. this.bannerList = data.map(banner => ({
  433. ...banner,
  434. cover_image: banner.cover_image || banner.coverImage || DEFAULT_IMAGES.banner,
  435. name: banner.name || banner.title || '',
  436. subtitle: banner.subtitle || '',
  437. type: banner.type || 'activity',
  438. targetId: banner.targetId || banner.id
  439. }))
  440. }
  441. } catch (error) {
  442. console.error('获取轮播图失败:', error)
  443. // 使用默认数据
  444. }
  445. },
  446. // 加载金刚区功能列表
  447. async loadFunctionGridData() {
  448. try {
  449. // 调用 API 获取金刚区功能数据
  450. const data = await api.home.getFunctionGrid()
  451. if (data && data.length > 0) {
  452. // 处理金刚区数据,确保字段格式正确
  453. this.functionList = data.map(item => ({
  454. ...item,
  455. // 确保渐变背景色格式正确
  456. gradient: item.gradient || `linear-gradient(135deg, ${item.bgColor} 0%, ${this.lightenColor(item.bgColor, 10)} 100%)`
  457. }))
  458. }
  459. } catch (error) {
  460. console.error('获取金刚区功能列表失败:', error)
  461. // 使用默认数据作为降级方案
  462. this.functionList = [
  463. { id: 1, name: '星命测算', icon: '💖', path: '/pages/astrology/index', bgColor: '#FF6B9D', iconColor: '#FFFFFF', gradient: 'linear-gradient(135deg, #FF6B9D 0%, #FF8EAB 100%)' },
  464. { id: 2, name: '红娘列表', icon: '👤', path: '/pages/matchmakers/list', bgColor: '#6BC5F8', iconColor: '#FFFFFF', gradient: 'linear-gradient(135deg, #6BC5F8 0%, #87CEEB 100%)' },
  465. { id: 4, name: '精品课程', icon: '📚', path: '/pages/courses/list', bgColor: '#FF8C42', iconColor: '#FFFFFF', gradient: 'linear-gradient(135deg, #FF8C42 0%, #FFA366 100%)' },
  466. { id: 5, name: '今日缘分', icon: '💝', path: '/pages/recommend/index', bgColor: '#FF69B4', iconColor: '#FFFFFF', gradient: 'linear-gradient(135deg, #FF69B4 0%, #FF8CC8 100%)', needLogin: true }
  467. ]
  468. }
  469. },
  470. // 颜色提亮函数(用于生成渐变背景色)
  471. lightenColor(color, percent) {
  472. // 移除#号
  473. color = color.replace('#', '')
  474. // 转换为RGB
  475. let r = parseInt(color.substring(0, 2), 16)
  476. let g = parseInt(color.substring(2, 4), 16)
  477. let b = parseInt(color.substring(4, 6), 16)
  478. // 提亮颜色
  479. r = Math.min(255, Math.round(r + (255 - r) * percent / 100))
  480. g = Math.min(255, Math.round(g + (255 - g) * percent / 100))
  481. b = Math.min(255, Math.round(b + (255 - b) * percent / 100))
  482. // 转换回十六进制
  483. return '#' + ((r << 16) | (g << 8) | b).toString(16).padStart(6, '0')
  484. },
  485. // 加载公告数据
  486. async loadNoticeData() {
  487. try {
  488. // 调用 API 获取公告数据
  489. const data = await api.home.getNotices()
  490. if (data && data.length > 0) {
  491. this.noticeList = data
  492. }
  493. } catch (error) {
  494. console.error('获取公告失败:', error)
  495. // 使用默认数据
  496. }
  497. },
  498. // 加载今日推荐
  499. async loadTodayRecommend() {
  500. try {
  501. const userId = this.userInfo.userId || parseInt(uni.getStorageSync('userId'))
  502. if (!userId) {
  503. console.log('用户未登录,跳过今日推荐加载')
  504. return
  505. }
  506. // 调用推荐API获取推荐用户列表
  507. const data = await api.recommend.getUsers({
  508. userId: userId,
  509. oppoOnly: 1, // 只推荐异性
  510. limit: 20 // 获取20个用户用于筛选
  511. })
  512. if (data && data.length > 0) {
  513. // 按匹配度降序排序,取前3个匹配度最高的用户
  514. const sortedUsers = data
  515. .filter(user => user.compatibilityScore && user.compatibilityScore > 0)
  516. .sort((a, b) => (b.compatibilityScore || 0) - (a.compatibilityScore || 0))
  517. .slice(0, 3)
  518. // 处理用户数据
  519. this.todayRecommendUsers = sortedUsers.map(user => ({
  520. ...user,
  521. avatarUrl: this.validateImageUrl(user.avatarUrl || DEFAULT_IMAGES.avatar),
  522. age: user.age || 0,
  523. location: this.formatLocation(user),
  524. isOnline: false // 可以根据实际情况设置
  525. }))
  526. console.log('今日缘分推荐加载成功,匹配度最高的用户:', this.todayRecommendUsers)
  527. }
  528. } catch (error) {
  529. console.error('获取推荐用户失败:', error)
  530. this.todayRecommendUsers = []
  531. }
  532. },
  533. // 格式化位置信息
  534. formatLocation(user) {
  535. const parts = []
  536. if (user.provinceName) parts.push(user.provinceName)
  537. if (user.cityName) parts.push(user.cityName)
  538. if (parts.length === 0 && user.location) return user.location
  539. if (parts.length === 0 && user.city) return user.city
  540. return parts.join(' ')
  541. },
  542. // 格式化匹配度分数
  543. formatMatchScore(score) {
  544. if (!score) return '0.0'
  545. return Number(score).toFixed(1)
  546. },
  547. // 解析用户标签
  548. parseUserTags(user) {
  549. const tags = []
  550. if (user.star) tags.push(user.star)
  551. if (user.jobTitle) tags.push(user.jobTitle)
  552. if (user.hobby) {
  553. try {
  554. const hobbies = typeof user.hobby === 'string' ? JSON.parse(user.hobby) : user.hobby
  555. if (Array.isArray(hobbies)) {
  556. tags.push(...hobbies.slice(0, 2))
  557. }
  558. } catch (e) {
  559. console.error('解析兴趣爱好失败:', e)
  560. }
  561. }
  562. return tags
  563. },
  564. // 加载魅力指数
  565. async loadCharmIndex() {
  566. try {
  567. if (this.userInfo.userId) {
  568. // 调用 API 获取魅力指数
  569. // const data = await api.user.getCharmIndex(this.userInfo.userId)
  570. // if (data) {
  571. // this.charmIndex = data
  572. // }
  573. }
  574. } catch (error) {
  575. console.error('获取魅力指数失败:', error)
  576. }
  577. },
  578. // 加载热门活动
  579. async loadHotActivities() {
  580. try {
  581. // 调用 API 获取活动列表(获取所有状态为1的活动,而不是只获取热门活动)
  582. const data = await api.activity.getList({
  583. status: 1,
  584. limit: 10
  585. })
  586. if (data && data.length > 0) {
  587. this.hotActivities = data.map((activity, index) => {
  588. const rawCover = this.validateImageUrl(activity.cover_image || activity.coverImage || activity.imageUrl || activity.image_url)
  589. return {
  590. ...activity,
  591. coverImage: this.ensureRomanticCover(rawCover, index),
  592. name: activity.name || activity.title || '',
  593. startTime: activity.startTime || activity.start_time || activity.startDate || '',
  594. endTime: activity.endTime || activity.end_time || activity.endDate || '',
  595. status: activity.status || 0
  596. }})
  597. }
  598. } catch (error) {
  599. console.error('获取热门活动失败:', error)
  600. }
  601. },
  602. // 格式化活动时间(支持开始和结束时间)
  603. formatActivityTime(startTime, endTime) {
  604. if (!startTime) return '时间待定'
  605. try {
  606. const start = new Date(startTime)
  607. const startMonth = start.getMonth() + 1
  608. const startDay = start.getDate()
  609. const startHour = start.getHours().toString().padStart(2, '0')
  610. const startMinute = start.getMinutes().toString().padStart(2, '0')
  611. let timeStr = `${startMonth}月${startDay}日 ${startHour}:${startMinute}`
  612. // 如果有结束时间,添加结束时间
  613. if (endTime) {
  614. const end = new Date(endTime)
  615. const endMonth = end.getMonth() + 1
  616. const endDay = end.getDate()
  617. const endHour = end.getHours().toString().padStart(2, '0')
  618. const endMinute = end.getMinutes().toString().padStart(2, '0')
  619. timeStr += ` - ${endMonth}月${endDay}日 ${endHour}:${endMinute}`
  620. }
  621. return timeStr
  622. } catch (error) {
  623. return '时间待定'
  624. }
  625. },
  626. // 加载成功案例
  627. async loadSuccessCases() {
  628. try {
  629. // 调用 API 获取成功案例列表
  630. const data = await api.successCase.getList({
  631. pageNum: 1,
  632. pageSize: 5
  633. })
  634. if (data && data.length > 0) {
  635. this.successCases = data.map(caseItem => ({
  636. ...caseItem,
  637. maleUserNickname: caseItem.maleUserNickname || caseItem.male_user_nickname || '先生',
  638. femaleUserNickname: caseItem.femaleUserNickname || caseItem.female_user_nickname || '女士',
  639. imageUrl: this.validateImageUrl(caseItem.imageUrl || caseItem.image_url || DEFAULT_IMAGES.couple),
  640. quote: caseItem.quote || '我们通过平台找到了彼此❤️',
  641. marriageDate: caseItem.marriageDate || caseItem.marriage_date || ''
  642. }))
  643. } else {
  644. // 使用默认数据
  645. this.successCases = []
  646. }
  647. } catch (error) {
  648. console.error('获取成功案例失败:', error)
  649. }
  650. },
  651. // 格式化结婚日期
  652. formatMarriageDate(dateStr) {
  653. if (!dateStr) return '佳音渐近'
  654. try {
  655. const date = new Date(dateStr)
  656. const year = date.getFullYear()
  657. const month = date.getMonth() + 1
  658. const day = date.getDate()
  659. return `${year}年${month}月${day}日`
  660. } catch (error) {
  661. return '佳音渐近'
  662. }
  663. },
  664. // 跳转到VIP页面
  665. goToVip() {
  666. uni.navigateTo({
  667. url: '/pages/vip/index'
  668. })
  669. },
  670. // 跳转到活动列表
  671. goToActivityList() {
  672. uni.navigateTo({
  673. url: '/pages/activities/list'
  674. })
  675. },
  676. // 处理活动点击
  677. handleActivityClick(activity) {
  678. uni.navigateTo({
  679. url: `/pages/activities/detail?id=${activity.id}`
  680. })
  681. },
  682. // 跳转到成功案例列表
  683. goToSuccessCaseList() {
  684. uni.navigateTo({
  685. url: '/pages/success-case/list'
  686. })
  687. },
  688. // 处理成功案例点击
  689. handleSuccessCaseClick(caseItem) {
  690. const caseNo = caseItem.caseNo || caseItem.case_no
  691. uni.navigateTo({
  692. url: `/pages/success-case/detail?caseNo=${caseNo}`
  693. })
  694. },
  695. // 处理图片加载错误并回退到默认图
  696. handleImageError(e) {
  697. const failedSrc = e.detail ? e.detail.errMsg : '未知错误'
  698. const dataset = (e && e.target && e.target.dataset) ? e.target.dataset : {}
  699. const section = dataset.section
  700. const index = dataset.index
  701. console.warn('图片加载失败:', failedSrc, 'section:', section, 'index:', index)
  702. const fallbackMap = {
  703. banner: DEFAULT_IMAGES.banner,
  704. activity: DEFAULT_IMAGES.activity,
  705. successCase: DEFAULT_IMAGES.couple,
  706. todayRecommend: DEFAULT_IMAGES.avatar
  707. }
  708. const setFallback = (list, targetIndex, key, fallback, extraKeys = []) => {
  709. if (!Array.isArray(list) || list.length === 0) return
  710. const numIndex = Number(targetIndex)
  711. if (Number.isNaN(numIndex)) return
  712. const normalizedIndex = ((numIndex % list.length) + list.length) % list.length
  713. if (!list[normalizedIndex]) return
  714. this.$set(list[normalizedIndex], key, fallback)
  715. extraKeys.forEach(extraKey => this.$set(list[normalizedIndex], extraKey, fallback))
  716. }
  717. switch (section) {
  718. case 'banner':
  719. setFallback(this.bannerList, index, 'cover_image', fallbackMap.banner)
  720. setFallback(this.bannerList, index, 'coverImage', fallbackMap.banner)
  721. break
  722. case 'activity':
  723. setFallback(this.hotActivities, index, 'coverImage', this.getRomanticImage(index))
  724. break
  725. case 'successCase':
  726. setFallback(this.successCases, index, 'imageUrl', fallbackMap.successCase)
  727. break
  728. case 'todayRecommend':
  729. setFallback(this.todayRecommendUsers, index, 'avatar', fallbackMap.todayRecommend)
  730. break
  731. default:
  732. break
  733. }
  734. },
  735. // 处理图片加载成功
  736. handleImageLoad(e) {
  737. // 图片加载成功,重置错误计数
  738. this.imageErrorCount = 0
  739. },
  740. // 验证和处理图片URL
  741. validateImageUrl(url) {
  742. if (!url || url === 'null' || url === 'undefined') {
  743. return DEFAULT_IMAGES.activity || DEFAULT_IMAGES.banner || 'http://115.190.125.125:9001/static-images/login-bg.png'
  744. }
  745. let cleanedUrl = String(url).trim()
  746. const httpIndex = cleanedUrl.indexOf('http')
  747. if (httpIndex > 0) {
  748. cleanedUrl = cleanedUrl.slice(httpIndex)
  749. }
  750. if (!cleanedUrl) {
  751. return DEFAULT_IMAGES.activity || DEFAULT_IMAGES.banner || 'http://115.190.125.125:9001/static-images/login-bg.png'
  752. }
  753. // 如果是相对路径,添加协议和域名
  754. if (cleanedUrl.startsWith('/')) {
  755. // 检查是否是完整的服务器路径
  756. if (cleanedUrl.startsWith('/banners/') || cleanedUrl.startsWith('/activities/') || cleanedUrl.startsWith('/images/')) {
  757. return `http://115.190.125.125:9000${cleanedUrl}`
  758. }
  759. return `http://115.190.125.125:9000${cleanedUrl}`
  760. }
  761. // 如果已经是完整URL,直接返回
  762. if (cleanedUrl.startsWith('http://') || cleanedUrl.startsWith('https://')) {
  763. return cleanedUrl
  764. }
  765. // 其他情况返回默认图片
  766. return DEFAULT_IMAGES.activity || DEFAULT_IMAGES.banner || 'http://115.190.125.125:9001/static-images/login-bg.png'
  767. },
  768. getRomanticImage(index = 0) {
  769. if (!this.romanticImages || this.romanticImages.length === 0) {
  770. return DEFAULT_IMAGES.activity || DEFAULT_IMAGES.banner || 'http://115.190.125.125:9001/static-images/login-bg.png'
  771. }
  772. const idx = Math.abs(Number(index) || 0) % this.romanticImages.length
  773. return this.romanticImages[idx]
  774. },
  775. ensureRomanticCover(url, index = 0) {
  776. if (!url || url === DEFAULT_IMAGES.activity || url === DEFAULT_IMAGES.banner || url === 'http://115.190.125.125:9001/static-images/login-bg.png') {
  777. return this.getRomanticImage(index)
  778. }
  779. return url
  780. },
  781. // 跳转到推荐页面
  782. goToRecommend() {
  783. uni.navigateTo({
  784. url: '/pages/recommend/index'
  785. })
  786. },
  787. // 处理用户点击
  788. handleUserClick(user) {
  789. const userId = user.userId || user.id
  790. if (!userId) {
  791. uni.showToast({
  792. title: '用户信息错误',
  793. icon: 'none'
  794. })
  795. return
  796. }
  797. uni.navigateTo({
  798. url: `/pages/recommend/user-detail?userId=${userId}`
  799. })
  800. },
  801. // 格式化时间
  802. formatTime,
  803. // Banner点击
  804. handleBannerClick(banner) {
  805. if (banner.type === 'activity') {
  806. uni.navigateTo({
  807. url: `/pages/activities/detail?id=${banner.targetId}`
  808. })
  809. } else if (banner.type === 'course') {
  810. uni.navigateTo({
  811. url: `/pages/courses/detail?id=${banner.targetId}`
  812. })
  813. } else if (banner.type === 'case') {
  814. uni.navigateTo({
  815. url: '/pages/success-case/list'
  816. })
  817. }
  818. },
  819. // 功能入口点击
  820. handleFunctionClick(item) {
  821. // 今日缘分:直接跳转到专门的推荐页面
  822. if (item && (item.id === 5 || item.name === '今日缘分' || item.name === '今日推荐')) {
  823. console.log('点击今日缘分,跳转到专门页面')
  824. uni.navigateTo({
  825. url: '/pages/today-recommend/index',
  826. success: () => {
  827. console.log('跳转今日缘分页面成功')
  828. },
  829. fail: (err) => {
  830. console.error('跳转今日缘分页面失败:', err)
  831. uni.showToast({
  832. title: '页面跳转失败',
  833. icon: 'none'
  834. })
  835. }
  836. })
  837. return
  838. }
  839. // 检查是否需要登录
  840. if (item.needLogin && !isLoggedIn()) {
  841. uni.navigateTo({
  842. url: '/pages/page3/page3'
  843. })
  844. return
  845. }
  846. if (item.path) {
  847. let url = item.path
  848. if (item.query) {
  849. const queryStr = Object.keys(item.query).map(key => `${key}=${item.query[key]}`).join('&')
  850. url += '?' + queryStr
  851. }
  852. uni.navigateTo({
  853. url: url,
  854. fail: () => {
  855. uni.showToast({
  856. title: '功能开发中',
  857. icon: 'none'
  858. })
  859. }
  860. })
  861. }
  862. },
  863. // 跳转到消息中心
  864. goToMessages() {
  865. uni.navigateTo({
  866. url: '/pages/message/index',
  867. fail: () => {
  868. uni.showToast({
  869. title: '功能开发中',
  870. icon: 'none'
  871. })
  872. }
  873. })
  874. },
  875. // 打开红娘工作台弹框
  876. openMatchmakerPopup() {
  877. // 删除检查处理标记的逻辑,每次点击都显示弹框
  878. if (this.$refs.matchmakerPopup) {
  879. this.$refs.matchmakerPopup.open()
  880. }
  881. },
  882. // 切换Tab
  883. switchTab(tab) {
  884. if (tab === 'index') return
  885. const tabPages = {
  886. plaza: '/pages/plaza/index',
  887. recommend: '/pages/recommend/index',
  888. message: '/pages/message/index',
  889. mine: '/pages/mine/index'
  890. }
  891. if (tabPages[tab]) {
  892. uni.redirectTo({
  893. url: tabPages[tab]
  894. })
  895. }
  896. }
  897. }
  898. }
  899. </script>
  900. <style lang="scss" scoped>
  901. .home-page {
  902. min-height: 100vh;
  903. background: #F5F5F5;
  904. padding-bottom: 120rpx;
  905. }
  906. /* 顶部状态栏 */
  907. .top-bar {
  908. display: flex;
  909. justify-content: space-between;
  910. align-items: center;
  911. padding: 25rpx 35rpx;
  912. background: #FFFFFF;
  913. border-bottom: 2rpx solid #E0E0E0;
  914. .logo {
  915. font-size: 38rpx;
  916. font-weight: 800;
  917. color: #E91E63;
  918. }
  919. .top-right-icons {
  920. display: flex;
  921. align-items: center;
  922. gap: 20rpx;
  923. }
  924. .matchmaker-btn {
  925. position: relative;
  926. width: auto;
  927. height: auto;
  928. display: flex;
  929. align-items: center;
  930. justify-content: center;
  931. background: transparent;
  932. border-radius: 0;
  933. transition: all 0.3s ease;
  934. padding: 10rpx 20rpx;
  935. color: #E91E63;
  936. font-weight: 600;
  937. border: 2rpx solid #E91E63;
  938. border-radius: 25rpx;
  939. &:active {
  940. opacity: 0.8;
  941. transform: scale(0.98);
  942. background: rgba(233, 30, 99, 0.1);
  943. }
  944. .switch-icon {
  945. font-size: 28rpx;
  946. margin-right: 8rpx;
  947. }
  948. .switch-text {
  949. font-size: 26rpx;
  950. color: #E91E63;
  951. font-weight: 600;
  952. }
  953. }
  954. .msg-icon {
  955. position: relative;
  956. width: 68rpx;
  957. height: 68rpx;
  958. display: flex;
  959. align-items: center;
  960. justify-content: center;
  961. background: #FFE5F1;
  962. border-radius: 50%;
  963. transition: all 0.2s ease;
  964. &:active {
  965. opacity: 0.8;
  966. transform: scale(0.95);
  967. }
  968. .icon {
  969. font-size: 44rpx;
  970. }
  971. .badge {
  972. position: absolute;
  973. top: -5rpx;
  974. right: -5rpx;
  975. min-width: 36rpx;
  976. height: 36rpx;
  977. line-height: 36rpx;
  978. padding: 0 8rpx;
  979. background: #FF6B6B;
  980. color: #FFFFFF;
  981. font-size: 20rpx;
  982. font-weight: bold;
  983. border-radius: 18rpx;
  984. text-align: center;
  985. }
  986. }
  987. }
  988. /* 个性化欢迎语 */
  989. .welcome-card {
  990. margin: 25rpx 35rpx;
  991. padding: 35rpx;
  992. background: #FFFFFF;
  993. border-radius: 16rpx;
  994. border: 2rpx solid #E0E0E0;
  995. .welcome-content {
  996. display: flex;
  997. flex-direction: column;
  998. gap: 16rpx;
  999. .welcome-text {
  1000. font-size: 34rpx;
  1001. font-weight: 700;
  1002. color: #333333;
  1003. line-height: 1.3;
  1004. }
  1005. .match-info {
  1006. font-size: 28rpx;
  1007. color: #666666;
  1008. line-height: 1.4;
  1009. .highlight {
  1010. color: #E91E63;
  1011. font-weight: 800;
  1012. font-size: 36rpx;
  1013. }
  1014. }
  1015. }
  1016. }
  1017. /* 轮播图 */
  1018. .banner-section {
  1019. margin: 10rpx 10rpx;
  1020. .banner-swiper {
  1021. height: 480rpx;
  1022. border-radius: 16rpx;
  1023. overflow: hidden;
  1024. border: 2rpx solid #E0E0E0;
  1025. .banner-item {
  1026. position: relative;
  1027. width: 100%;
  1028. height: 100%;
  1029. overflow: hidden;
  1030. .banner-image {
  1031. width: 100%;
  1032. height: 100%;
  1033. }
  1034. .banner-mask {
  1035. position: absolute;
  1036. bottom: 0;
  1037. left: 0;
  1038. right: 0;
  1039. padding: 35rpx;
  1040. background: rgba(0, 0, 0, 0.6);
  1041. color: #FFFFFF;
  1042. .banner-title {
  1043. font-size: 38rpx;
  1044. font-weight: 800;
  1045. margin-bottom: 12rpx;
  1046. line-height: 1.2;
  1047. }
  1048. .banner-subtitle {
  1049. font-size: 26rpx;
  1050. margin-bottom: 24rpx;
  1051. }
  1052. .banner-btn {
  1053. display: inline-block;
  1054. padding: 12rpx 32rpx;
  1055. background: #E91E63;
  1056. border-radius: 8rpx;
  1057. font-size: 26rpx;
  1058. font-weight: 600;
  1059. transition: all 0.2s ease;
  1060. &:active {
  1061. opacity: 0.8;
  1062. }
  1063. }
  1064. }
  1065. }
  1066. }
  1067. }
  1068. /* 公告栏 */
  1069. .notice-bar {
  1070. display: flex;
  1071. align-items: center;
  1072. margin: 25rpx 35rpx;
  1073. padding: 24rpx 30rpx;
  1074. background: #FFF8E1;
  1075. border-radius: 8rpx;
  1076. border: 2rpx solid #FFD54F;
  1077. border-left: 6rpx solid #FFC107;
  1078. .notice-icon {
  1079. font-size: 34rpx;
  1080. margin-right: 24rpx;
  1081. }
  1082. .notice-swiper {
  1083. flex: 1;
  1084. height: 44rpx;
  1085. .notice-text {
  1086. font-size: 28rpx;
  1087. color: #795548;
  1088. line-height: 44rpx;
  1089. white-space: nowrap;
  1090. overflow: hidden;
  1091. text-overflow: ellipsis;
  1092. font-weight: 500;
  1093. }
  1094. }
  1095. }
  1096. /* 功能入口 */
  1097. .function-grid {
  1098. display: grid;
  1099. grid-template-columns: repeat(4, 1fr);
  1100. gap: 24rpx;
  1101. margin: 20rpx 1rpx;
  1102. padding: 30rpx;
  1103. background: #FFFFFF;
  1104. border-radius: 16rpx;
  1105. border: 2rpx solid #E0E0E0;
  1106. .grid-item {
  1107. display: flex;
  1108. flex-direction: column;
  1109. align-items: center;
  1110. gap: 14rpx;
  1111. padding: 20rpx 12rpx;
  1112. transition: all 0.3s ease;
  1113. border-radius: 12rpx;
  1114. &:active {
  1115. transform: scale(0.95);
  1116. opacity: 0.9;
  1117. }
  1118. .grid-icon-wrapper {
  1119. width: 140rpx;
  1120. height: 140rpx;
  1121. display: flex;
  1122. align-items: center;
  1123. justify-content: center;
  1124. border-radius: 20rpx;
  1125. position: relative;
  1126. overflow: hidden;
  1127. /* 外阴影 + 内阴影 - 增强立体感和深度感 */
  1128. box-shadow: inset 0 2rpx 8rpx rgba(255, 255, 255, 0.3),
  1129. 0 10rpx 30rpx rgba(0, 0, 0, 0.2),
  1130. 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
  1131. transition: all 0.3s ease;
  1132. /* 光泽效果 - 左上角强烈高光,模拟图片中的光泽 */
  1133. &::before {
  1134. content: '';
  1135. position: absolute;
  1136. top: -60%;
  1137. left: -60%;
  1138. width: 220%;
  1139. height: 220%;
  1140. background: linear-gradient(135deg,
  1141. rgba(255, 255, 255, 0.6) 0%,
  1142. rgba(255, 255, 255, 0.4) 15%,
  1143. rgba(255, 255, 255, 0.2) 30%,
  1144. rgba(255, 255, 255, 0.05) 50%,
  1145. transparent 70%);
  1146. transform: rotate(45deg);
  1147. pointer-events: none;
  1148. z-index: 1;
  1149. border-radius: 50%;
  1150. }
  1151. /* 底部深度阴影 - 增强立体感 */
  1152. &::after {
  1153. content: '';
  1154. position: absolute;
  1155. bottom: 0;
  1156. left: 0;
  1157. right: 0;
  1158. height: 40%;
  1159. background: linear-gradient(to top,
  1160. rgba(0, 0, 0, 0.15) 0%,
  1161. rgba(0, 0, 0, 0.08) 50%,
  1162. transparent 100%);
  1163. pointer-events: none;
  1164. z-index: 1;
  1165. border-radius: 0 0 20rpx 20rpx;
  1166. }
  1167. &:active {
  1168. transform: scale(0.92);
  1169. box-shadow: inset 0 2rpx 8rpx rgba(255, 255, 255, 0.2),
  1170. 0 6rpx 20rpx rgba(0, 0, 0, 0.25);
  1171. }
  1172. .grid-icon {
  1173. font-size: 70rpx;
  1174. position: relative;
  1175. z-index: 2;
  1176. /* 图标阴影 - 让图标更突出 */
  1177. filter: drop-shadow(0 3rpx 8rpx rgba(0, 0, 0, 0.2));
  1178. text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
  1179. }
  1180. }
  1181. .grid-text {
  1182. font-size: 24rpx;
  1183. font-weight: 600;
  1184. color: #333333;
  1185. text-align: center;
  1186. line-height: 1.2;
  1187. }
  1188. }
  1189. }
  1190. /* 区块样式 */
  1191. .section {
  1192. margin: 40rpx 0;
  1193. .section-header {
  1194. display: flex;
  1195. justify-content: space-between;
  1196. align-items: center;
  1197. padding: 0 35rpx;
  1198. margin-bottom: 25rpx;
  1199. .section-title {
  1200. font-size: 36rpx;
  1201. font-weight: 800;
  1202. color: #333333;
  1203. border-left: 6rpx solid #E91E63;
  1204. padding-left: 16rpx;
  1205. }
  1206. .section-more {
  1207. font-size: 26rpx;
  1208. color: #E91E63;
  1209. font-weight: 600;
  1210. transition: all 0.2s ease;
  1211. &:active {
  1212. opacity: 0.6;
  1213. }
  1214. }
  1215. }
  1216. }
  1217. /* 平台活动展示区 */
  1218. .activity-recommend-section {
  1219. .activity-scroll-container {
  1220. margin: 0 35rpx;
  1221. overflow: hidden;
  1222. position: relative;
  1223. .activity-scroll-wrapper {
  1224. width: 100%;
  1225. overflow: hidden;
  1226. .activity-scroll-content {
  1227. display: flex;
  1228. animation: activityScroll 30s linear infinite;
  1229. gap: 20rpx;
  1230. width: fit-content;
  1231. &:hover {
  1232. animation-play-state: paused;
  1233. }
  1234. .activity-card-scroll {
  1235. flex-shrink: 0;
  1236. width: 500rpx;
  1237. background: #FFFFFF;
  1238. border-radius: 16rpx;
  1239. overflow: hidden;
  1240. border: 2rpx solid #E0E0E0;
  1241. transition: all 0.3s ease;
  1242. &:active {
  1243. transform: scale(0.98);
  1244. opacity: 0.9;
  1245. }
  1246. .activity-image-wrapper {
  1247. position: relative;
  1248. width: 100%;
  1249. height: 280rpx;
  1250. overflow: hidden;
  1251. .activity-image {
  1252. width: 100%;
  1253. height: 100%;
  1254. }
  1255. .activity-status {
  1256. position: absolute;
  1257. top: 15rpx;
  1258. right: 15rpx;
  1259. padding: 6rpx 12rpx;
  1260. background: #4CAF50;
  1261. color: #FFFFFF;
  1262. font-size: 22rpx;
  1263. font-weight: 600;
  1264. border-radius: 8rpx;
  1265. }
  1266. }
  1267. .activity-info-static {
  1268. padding: 20rpx;
  1269. .activity-name-static {
  1270. font-size: 28rpx;
  1271. font-weight: 700;
  1272. color: #333333;
  1273. margin-bottom: 8rpx;
  1274. line-height: 1.3;
  1275. }
  1276. .activity-time-static {
  1277. font-size: 24rpx;
  1278. color: #666666;
  1279. line-height: 1.4;
  1280. }
  1281. }
  1282. }
  1283. }
  1284. }
  1285. }
  1286. }
  1287. @keyframes activityScroll {
  1288. 0% {
  1289. transform: translateX(0);
  1290. }
  1291. 100% {
  1292. transform: translateX(-50%);
  1293. }
  1294. }
  1295. /* 今日缘分推荐 */
  1296. .fate-recommend-section {
  1297. .fate-cards {
  1298. display: flex;
  1299. gap: 20rpx;
  1300. padding: 0 35rpx;
  1301. overflow-x: auto;
  1302. scrollbar-width: none;
  1303. &::-webkit-scrollbar {
  1304. display: none;
  1305. }
  1306. .fate-card {
  1307. min-width: 320rpx;
  1308. background: #FFFFFF;
  1309. border-radius: 16rpx;
  1310. padding: 25rpx;
  1311. border: 2rpx solid #E0E0E0;
  1312. display: flex;
  1313. flex-direction: column;
  1314. align-items: center;
  1315. gap: 15rpx;
  1316. position: relative;
  1317. transition: all 0.2s ease;
  1318. &:active {
  1319. background: #F5F5F5;
  1320. }
  1321. .user-avatar-wrapper {
  1322. position: relative;
  1323. .user-avatar {
  1324. width: 100rpx;
  1325. height: 100rpx;
  1326. border-radius: 50%;
  1327. border: 3rpx solid #E0E0E0;
  1328. }
  1329. .online-status {
  1330. position: absolute;
  1331. bottom: 5rpx;
  1332. right: 5rpx;
  1333. width: 20rpx;
  1334. height: 20rpx;
  1335. background: #4CAF50;
  1336. border-radius: 50%;
  1337. border: 3rpx solid white;
  1338. }
  1339. }
  1340. .user-basic-info {
  1341. text-align: center;
  1342. .user-nickname {
  1343. font-size: 28rpx;
  1344. font-weight: 700;
  1345. color: #333333;
  1346. display: block;
  1347. margin-bottom: 5rpx;
  1348. }
  1349. .user-age-location {
  1350. font-size: 24rpx;
  1351. color: #666666;
  1352. }
  1353. }
  1354. .match-score {
  1355. display: flex;
  1356. align-items: center;
  1357. gap: 8rpx;
  1358. padding: 8rpx 16rpx;
  1359. background: #FFE5F1;
  1360. border-radius: 8rpx;
  1361. .match-text {
  1362. font-size: 22rpx;
  1363. color: #666666;
  1364. }
  1365. .match-percentage {
  1366. font-size: 26rpx;
  1367. font-weight: 700;
  1368. color: #E91E63;
  1369. }
  1370. }
  1371. .user-tags {
  1372. display: flex;
  1373. gap: 8rpx;
  1374. flex-wrap: wrap;
  1375. justify-content: center;
  1376. .user-tag {
  1377. font-size: 20rpx;
  1378. color: #666666;
  1379. background: #F5F5F5;
  1380. padding: 6rpx 12rpx;
  1381. border-radius: 8rpx;
  1382. border: 1rpx solid #E0E0E0;
  1383. }
  1384. }
  1385. }
  1386. }
  1387. }
  1388. /* 个人魅力指数 */
  1389. .charm-index-section {
  1390. margin: 25rpx 35rpx;
  1391. .charm-card {
  1392. background: #FFFFFF;
  1393. border-radius: 16rpx;
  1394. padding: 35rpx;
  1395. border: 2rpx solid #E0E0E0;
  1396. .charm-header {
  1397. display: flex;
  1398. justify-content: space-between;
  1399. align-items: center;
  1400. margin-bottom: 25rpx;
  1401. .charm-title {
  1402. font-size: 32rpx;
  1403. font-weight: 800;
  1404. color: #333333;
  1405. }
  1406. .charm-score {
  1407. font-size: 48rpx;
  1408. font-weight: 800;
  1409. color: #E91E63;
  1410. }
  1411. }
  1412. .charm-progress {
  1413. margin-bottom: 30rpx;
  1414. .progress-bar {
  1415. width: 100%;
  1416. height: 12rpx;
  1417. background: #FFE5F1;
  1418. border-radius: 6rpx;
  1419. overflow: hidden;
  1420. margin-bottom: 10rpx;
  1421. .progress-fill {
  1422. height: 100%;
  1423. background: #E91E63;
  1424. border-radius: 6rpx;
  1425. transition: width 1s ease;
  1426. }
  1427. }
  1428. .progress-text {
  1429. font-size: 24rpx;
  1430. color: #666666;
  1431. text-align: center;
  1432. display: block;
  1433. }
  1434. }
  1435. .charm-items {
  1436. display: flex;
  1437. flex-direction: column;
  1438. gap: 20rpx;
  1439. margin-bottom: 25rpx;
  1440. .charm-item {
  1441. display: flex;
  1442. justify-content: space-between;
  1443. align-items: center;
  1444. .charm-item-label {
  1445. font-size: 26rpx;
  1446. color: #666666;
  1447. font-weight: 500;
  1448. }
  1449. .charm-item-progress {
  1450. display: flex;
  1451. align-items: center;
  1452. gap: 12rpx;
  1453. flex: 1;
  1454. margin-left: 20rpx;
  1455. .item-progress-bar {
  1456. flex: 1;
  1457. height: 8rpx;
  1458. background: #FFE5F1;
  1459. border-radius: 4rpx;
  1460. overflow: hidden;
  1461. .item-progress-fill {
  1462. height: 100%;
  1463. background: #E91E63;
  1464. border-radius: 4rpx;
  1465. transition: width 1s ease;
  1466. }
  1467. }
  1468. .charm-item-score {
  1469. font-size: 24rpx;
  1470. color: #E91E63;
  1471. font-weight: 600;
  1472. min-width: 60rpx;
  1473. text-align: right;
  1474. }
  1475. }
  1476. }
  1477. }
  1478. .charm-tip {
  1479. padding: 20rpx;
  1480. background: #FFF8E1;
  1481. border-radius: 8rpx;
  1482. border: 2rpx solid #FFD54F;
  1483. .tip-text {
  1484. font-size: 24rpx;
  1485. color: #666666;
  1486. line-height: 1.5;
  1487. }
  1488. }
  1489. }
  1490. }
  1491. /* 底部占位 */
  1492. .bottom-placeholder {
  1493. height: 30rpx;
  1494. }
  1495. /* 底部导航栏 */
  1496. .tabbar {
  1497. position: fixed;
  1498. bottom: 0;
  1499. left: 0;
  1500. right: 0;
  1501. display: flex;
  1502. background-color: #FFFFFF;
  1503. border-top: 1rpx solid #F0F0F0;
  1504. padding-bottom: constant(safe-area-inset-bottom);
  1505. padding-bottom: env(safe-area-inset-bottom);
  1506. z-index: 999;
  1507. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  1508. .tabbar-item {
  1509. flex: 1;
  1510. display: flex;
  1511. flex-direction: column;
  1512. align-items: center;
  1513. justify-content: center;
  1514. padding: 15rpx 0;
  1515. position: relative;
  1516. .tabbar-icon {
  1517. font-size: 44rpx;
  1518. margin-bottom: 5rpx;
  1519. }
  1520. .tabbar-text {
  1521. font-size: 22rpx;
  1522. color: #666666;
  1523. }
  1524. &.active {
  1525. .tabbar-text {
  1526. color: #E91E63;
  1527. font-weight: bold;
  1528. }
  1529. }
  1530. }
  1531. }
  1532. /* 成功案例 */
  1533. .success-case-section {
  1534. .success-case-grid {
  1535. display: grid;
  1536. grid-template-columns: repeat(2, 1fr);
  1537. gap: 20rpx;
  1538. margin: 0 35rpx;
  1539. .case-card {
  1540. background: #FFFFFF;
  1541. border-radius: 16rpx;
  1542. overflow: hidden;
  1543. border: 2rpx solid #E0E0E0;
  1544. transition: all 0.3s ease;
  1545. &:active {
  1546. transform: scale(0.98);
  1547. opacity: 0.9;
  1548. }
  1549. .case-image-wrapper {
  1550. width: 100%;
  1551. height: 320rpx;
  1552. position: relative;
  1553. overflow: hidden;
  1554. .case-image {
  1555. width: 100%;
  1556. height: 100%;
  1557. }
  1558. }
  1559. .case-content {
  1560. padding: 20rpx;
  1561. .couple-names {
  1562. font-size: 28rpx;
  1563. font-weight: 700;
  1564. color: #333333;
  1565. margin-bottom: 10rpx;
  1566. line-height: 1.3;
  1567. }
  1568. .case-quote {
  1569. font-size: 24rpx;
  1570. color: #666666;
  1571. line-height: 1.5;
  1572. margin-bottom: 12rpx;
  1573. display: -webkit-box;
  1574. -webkit-box-orient: vertical;
  1575. -webkit-line-clamp: 2;
  1576. overflow: hidden;
  1577. }
  1578. .case-meta {
  1579. .marriage-date {
  1580. font-size: 22rpx;
  1581. color: #999999;
  1582. line-height: 1.4;
  1583. }
  1584. }
  1585. }
  1586. }
  1587. }
  1588. }
  1589. @keyframes marquee {
  1590. 0% {
  1591. transform: translateX(0);
  1592. }
  1593. 100% {
  1594. transform: translateX(-50%);
  1595. }
  1596. }
  1597. .tabbar-badge {
  1598. position: absolute;
  1599. top: 8rpx;
  1600. right: 50%;
  1601. margin-right: -40rpx;
  1602. min-width: 32rpx;
  1603. height: 32rpx;
  1604. line-height: 32rpx;
  1605. padding: 0 6rpx;
  1606. background-color: #FA5151;
  1607. border-radius: 16rpx;
  1608. font-size: 20rpx;
  1609. color: #FFFFFF;
  1610. text-align: center;
  1611. }
  1612. </style>