index.vue 46 KB

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