index.vue 46 KB

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