index.vue 47 KB

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