index.vue 46 KB

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