index.vue 47 KB

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