index.vue 46 KB

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