index.vue 47 KB

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