index.vue 46 KB

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