index.vue 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895
  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. const status = uni.getStorageSync("userInfo").status
  604. if(status != 1){
  605. uni.showToast({
  606. title: '您的账户违反规定已被禁用',
  607. icon: 'none'
  608. })
  609. return
  610. }
  611. uni.navigateTo({
  612. url: '/pages/vip/index'
  613. })
  614. },
  615. // 跳转到活动列表
  616. goToActivityList() {
  617. const status = uni.getStorageSync("userInfo").status
  618. if(status != 1){
  619. uni.showToast({
  620. title: '您的账户违反规定已被禁用',
  621. icon: 'none'
  622. })
  623. return
  624. }
  625. uni.navigateTo({
  626. url: '/pages/activities/list'
  627. })
  628. },
  629. // 处理活动点击
  630. handleActivityClick(activity) {
  631. const status = uni.getStorageSync("userInfo").status
  632. if(status != 1){
  633. uni.showToast({
  634. title: '您的账户违反规定已被禁用',
  635. icon: 'none'
  636. })
  637. return
  638. }
  639. uni.navigateTo({
  640. url: `/pages/activities/detail?id=${activity.id}`
  641. })
  642. },
  643. // 跳转到成功案例列表
  644. goToSuccessCaseList() {
  645. const status = uni.getStorageSync("userInfo").status
  646. if(status != 1){
  647. uni.showToast({
  648. title: '您的账户违反规定已被禁用',
  649. icon: 'none'
  650. })
  651. return
  652. }
  653. uni.navigateTo({
  654. url: '/pages/success-case/list'
  655. })
  656. },
  657. // 处理成功案例点击
  658. handleSuccessCaseClick(caseItem) {
  659. const caseNo = caseItem.caseNo || caseItem.case_no
  660. uni.navigateTo({
  661. url: `/pages/success-case/detail?caseNo=${caseNo}`
  662. })
  663. },
  664. // 处理图片加载错误并回退到默认图
  665. handleImageError(e) {
  666. const failedSrc = e.detail ? e.detail.errMsg : '未知错误'
  667. const dataset = (e && e.target && e.target.dataset) ? e.target.dataset : {}
  668. const section = dataset.section
  669. const index = dataset.index
  670. const fallbackMap = {
  671. banner: DEFAULT_IMAGES.banner,
  672. activity: DEFAULT_IMAGES.activity,
  673. successCase: DEFAULT_IMAGES.couple,
  674. todayRecommend: DEFAULT_IMAGES.avatar
  675. }
  676. const setFallback = (list, targetIndex, key, fallback, extraKeys = []) => {
  677. if (!Array.isArray(list) || list.length === 0) return
  678. const numIndex = Number(targetIndex)
  679. if (Number.isNaN(numIndex)) return
  680. const normalizedIndex = ((numIndex % list.length) + list.length) % list.length
  681. if (!list[normalizedIndex]) return
  682. this.$set(list[normalizedIndex], key, fallback)
  683. extraKeys.forEach(extraKey => this.$set(list[normalizedIndex], extraKey, fallback))
  684. }
  685. switch (section) {
  686. case 'banner':
  687. setFallback(this.bannerList, index, 'cover_image', fallbackMap.banner)
  688. setFallback(this.bannerList, index, 'coverImage', fallbackMap.banner)
  689. break
  690. case 'activity':
  691. setFallback(this.hotActivities, index, 'coverImage', this.getRomanticImage(index))
  692. break
  693. case 'successCase':
  694. setFallback(this.successCases, index, 'imageUrl', fallbackMap.successCase)
  695. break
  696. case 'todayRecommend':
  697. setFallback(this.todayRecommendUsers, index, 'avatar', fallbackMap.todayRecommend)
  698. break
  699. default:
  700. break
  701. }
  702. },
  703. // 处理图片加载成功
  704. handleImageLoad(e) {
  705. // 图片加载成功,重置错误计数
  706. this.imageErrorCount = 0
  707. },
  708. // 验证和处理图片URL
  709. validateImageUrl(url) {
  710. if (!url || url === 'null' || url === 'undefined') {
  711. return DEFAULT_IMAGES.activity || DEFAULT_IMAGES.banner || ''
  712. }
  713. let cleanedUrl = String(url).trim()
  714. const httpIndex = cleanedUrl.indexOf('http')
  715. if (httpIndex > 0) {
  716. cleanedUrl = cleanedUrl.slice(httpIndex)
  717. }
  718. if (!cleanedUrl) {
  719. return DEFAULT_IMAGES.activity || DEFAULT_IMAGES.banner || ''
  720. }
  721. // 如果是相对路径,添加协议和域名
  722. if (cleanedUrl.startsWith('/')) {
  723. // 检查是否是完整的服务器路径
  724. if (cleanedUrl.startsWith('/banners/') || cleanedUrl.startsWith('/activities/') || cleanedUrl.startsWith('/images/')) {
  725. return `http://115.190.125.125:9000${cleanedUrl}`
  726. }
  727. return `http://115.190.125.125:9000${cleanedUrl}`
  728. }
  729. // 如果已经是完整URL,直接返回
  730. if (cleanedUrl.startsWith('http://') || cleanedUrl.startsWith('https://')) {
  731. return cleanedUrl
  732. }
  733. // 其他情况返回默认图片
  734. return DEFAULT_IMAGES.activity || DEFAULT_IMAGES.banner || ''
  735. },
  736. getRomanticImage(index = 0) {
  737. if (!this.romanticImages || this.romanticImages.length === 0) {
  738. return DEFAULT_IMAGES.activity || DEFAULT_IMAGES.banner || ''
  739. }
  740. const idx = Math.abs(Number(index) || 0) % this.romanticImages.length
  741. return this.romanticImages[idx]
  742. },
  743. ensureRomanticCover(url, index = 0) {
  744. if (!url || url === DEFAULT_IMAGES.activity || url === DEFAULT_IMAGES.banner || url === '') {
  745. return this.getRomanticImage(index)
  746. }
  747. return url
  748. },
  749. // 跳转到推荐页面
  750. goToRecommend() {
  751. uni.navigateTo({
  752. url: '/pages/recommend/index'
  753. })
  754. },
  755. // 处理用户点击
  756. handleUserClick(user) {
  757. const userId = user.userId || user.id
  758. if (!userId) {
  759. uni.showToast({
  760. title: '用户信息错误',
  761. icon: 'none'
  762. })
  763. return
  764. }
  765. uni.navigateTo({
  766. url: `/pages/recommend/user-detail?userId=${userId}`
  767. })
  768. },
  769. // 格式化时间
  770. formatTime,
  771. // Banner点击
  772. handleBannerClick(banner) {
  773. if (banner.type === 'activity') {
  774. uni.navigateTo({
  775. url: `/pages/activities/detail?id=${banner.targetId}`
  776. })
  777. } else if (banner.type === 'course') {
  778. uni.navigateTo({
  779. url: `/pages/courses/detail?id=${banner.targetId}`
  780. })
  781. } else if (banner.type === 'case') {
  782. uni.navigateTo({
  783. url: '/pages/success-case/list'
  784. })
  785. }
  786. },
  787. // 功能入口点击
  788. handleFunctionClick(item) {
  789. // 今日缘分:直接跳转到专门的推荐页面
  790. if (item && (item.id === 5 || item.name === '今日缘分' || item.name === '今日推荐')) {
  791. uni.navigateTo({
  792. url: '/pages/today-recommend/index',
  793. success: () => {
  794. },
  795. fail: (err) => {
  796. uni.showToast({
  797. title: '页面跳转失败',
  798. icon: 'none'
  799. })
  800. }
  801. })
  802. return
  803. }
  804. // 检查是否需要登录
  805. if (item.needLogin && !isLoggedIn()) {
  806. uni.navigateTo({
  807. url: '/pages/page3/page3'
  808. })
  809. return
  810. }
  811. if (item.path) {
  812. let url = item.path
  813. if (item.query) {
  814. const queryStr = Object.keys(item.query).map(key => `${key}=${item.query[key]}`).join('&')
  815. url += '?' + queryStr
  816. }
  817. uni.navigateTo({
  818. url: url,
  819. fail: () => {
  820. uni.showToast({
  821. title: '功能开发中',
  822. icon: 'none'
  823. })
  824. }
  825. })
  826. }
  827. },
  828. // 跳转到消息中心
  829. goToMessages() {
  830. uni.navigateTo({
  831. url: '/pages/message/index',
  832. fail: () => {
  833. uni.showToast({
  834. title: '功能开发中',
  835. icon: 'none'
  836. })
  837. }
  838. })
  839. },
  840. // 打开红娘工作台弹框
  841. openMatchmakerPopup() {
  842. // 删除检查处理标记的逻辑,每次点击都显示弹框
  843. if (this.$refs.matchmakerPopup) {
  844. this.$refs.matchmakerPopup.open()
  845. }
  846. },
  847. // 切换Tab
  848. switchTab(tab) {
  849. if (tab === 'index') return
  850. const tabPages = {
  851. plaza: '/pages/plaza/index',
  852. recommend: '/pages/recommend/index',
  853. message: '/subpkg-message/index/index',
  854. mine: '/pages/mine/index'
  855. }
  856. if (tabPages[tab]) {
  857. uni.redirectTo({
  858. url: tabPages[tab]
  859. })
  860. }
  861. }
  862. }
  863. }
  864. </script>
  865. <style lang="scss" scoped>
  866. .home-page {
  867. min-height: 100vh;
  868. background: #F5F5F5;
  869. padding-bottom: 120rpx;
  870. }
  871. /* 顶部状态栏 */
  872. .top-bar {
  873. display: flex;
  874. justify-content: space-between;
  875. align-items: center;
  876. padding: 25rpx 35rpx;
  877. background: #FFFFFF;
  878. border-bottom: 2rpx solid #E0E0E0;
  879. .logo {
  880. font-size: 38rpx;
  881. font-weight: 800;
  882. color: #E91E63;
  883. margin-top: 35px;
  884. }
  885. .back-icon{
  886. width: 20px;
  887. height: 20px;
  888. }
  889. .top-right-icons {
  890. display: flex;
  891. align-items: center;
  892. gap: 20rpx;
  893. margin-right: 80px;
  894. margin-top: 40px;
  895. }
  896. .matchmaker-btn {
  897. position: relative;
  898. display: flex;
  899. align-items: center;
  900. justify-content: center;
  901. padding: 16rpx 32rpx;
  902. background: linear-gradient(135deg, #9B7EDE 0%, #B19CD9 100%);
  903. border-radius: 30rpx;
  904. box-shadow: 0 8rpx 20rpx rgba(155, 126, 222, 0.3);
  905. transition: all 0.3s ease;
  906. border: none;
  907. &:active {
  908. transform: scale(0.95);
  909. box-shadow: 0 4rpx 12rpx rgba(155, 126, 222, 0.4);
  910. }
  911. .switch-text {
  912. font-size: 26rpx;
  913. color: #FFFFFF;
  914. font-weight: 700;
  915. letter-spacing: 0.5rpx;
  916. }
  917. }
  918. .msg-icon {
  919. position: relative;
  920. width: 68rpx;
  921. height: 68rpx;
  922. display: flex;
  923. align-items: center;
  924. justify-content: center;
  925. background: #FFE5F1;
  926. border-radius: 50%;
  927. transition: all 0.2s ease;
  928. &:active {
  929. opacity: 0.8;
  930. transform: scale(0.95);
  931. }
  932. .icon {
  933. font-size: 44rpx;
  934. }
  935. .badge {
  936. position: absolute;
  937. top: -5rpx;
  938. right: -5rpx;
  939. min-width: 36rpx;
  940. height: 36rpx;
  941. line-height: 36rpx;
  942. padding: 0 8rpx;
  943. background: #FF6B6B;
  944. color: #FFFFFF;
  945. font-size: 20rpx;
  946. font-weight: bold;
  947. border-radius: 18rpx;
  948. text-align: center;
  949. }
  950. }
  951. }
  952. /* 个性化欢迎语 */
  953. .welcome-card {
  954. margin: 25rpx 35rpx;
  955. padding: 35rpx;
  956. background: #FFFFFF;
  957. border-radius: 16rpx;
  958. border: 2rpx solid #E0E0E0;
  959. .welcome-content {
  960. display: flex;
  961. flex-direction: column;
  962. gap: 16rpx;
  963. .welcome-text {
  964. font-size: 34rpx;
  965. font-weight: 700;
  966. color: #333333;
  967. line-height: 1.3;
  968. }
  969. .match-info {
  970. font-size: 28rpx;
  971. color: #666666;
  972. line-height: 1.4;
  973. .highlight {
  974. color: #E91E63;
  975. font-weight: 800;
  976. font-size: 36rpx;
  977. }
  978. }
  979. }
  980. }
  981. /* 轮播图 */
  982. .banner-section {
  983. margin: 10rpx 10rpx;
  984. .banner-swiper {
  985. height: 480rpx;
  986. border-radius: 16rpx;
  987. overflow: hidden;
  988. border: 2rpx solid #E0E0E0;
  989. .banner-item {
  990. position: relative;
  991. width: 100%;
  992. height: 100%;
  993. overflow: hidden;
  994. .banner-image {
  995. width: 100%;
  996. height: 100%;
  997. }
  998. .banner-mask {
  999. position: absolute;
  1000. bottom: 0;
  1001. left: 0;
  1002. right: 0;
  1003. padding: 35rpx;
  1004. background: rgba(0, 0, 0, 0.6);
  1005. color: #FFFFFF;
  1006. .banner-title {
  1007. font-size: 38rpx;
  1008. font-weight: 800;
  1009. margin-bottom: 12rpx;
  1010. line-height: 1.2;
  1011. }
  1012. .banner-subtitle {
  1013. font-size: 26rpx;
  1014. margin-bottom: 24rpx;
  1015. }
  1016. .banner-btn {
  1017. display: inline-block;
  1018. padding: 12rpx 32rpx;
  1019. background: #E91E63;
  1020. border-radius: 8rpx;
  1021. font-size: 26rpx;
  1022. font-weight: 600;
  1023. transition: all 0.2s ease;
  1024. &:active {
  1025. opacity: 0.8;
  1026. }
  1027. }
  1028. }
  1029. }
  1030. }
  1031. }
  1032. .notice-bar {
  1033. display: flex;
  1034. align-items: center;
  1035. margin: 25rpx 35rpx;
  1036. padding: 24rpx 30rpx;
  1037. background: #FFF8E1;
  1038. border-radius: 8rpx;
  1039. border: 2rpx solid #FFD54F;
  1040. border-left: 6rpx solid #FFC107;
  1041. .notice-icon {
  1042. font-size: 34rpx;
  1043. margin-right: 24rpx;
  1044. flex-shrink: 0; /* 固定图标不被挤压 */
  1045. }
  1046. // 公告滚动容器 - 参考活动滚动容器结构
  1047. .notice-scroll-container {
  1048. flex: 1;
  1049. overflow: hidden;
  1050. position: relative;
  1051. height: 60rpx;
  1052. .notice-scroll-wrapper {
  1053. width: 100%;
  1054. overflow: hidden;
  1055. .notice-scroll-content {
  1056. display: flex;
  1057. animation: noticeScroll 20s linear infinite; /* 滚动动画,时长可调整 */
  1058. gap: 40rpx; /* 公告之间的间距 */
  1059. width: fit-content;
  1060. // 悬停暂停滚动(可选)
  1061. &:hover {
  1062. animation-play-state: paused;
  1063. }
  1064. .notice-item-scroll {
  1065. flex-shrink: 0; /* 固定宽度,不被挤压 */
  1066. white-space: nowrap; /* 禁止文字换行 */
  1067. display: flex;
  1068. align-items: center;
  1069. height: 60rpx;
  1070. .notice-text {
  1071. font-size: 28rpx;
  1072. color: #795548;
  1073. line-height: 60rpx;
  1074. font-weight: 500;
  1075. }
  1076. }
  1077. }
  1078. }
  1079. }
  1080. }
  1081. // 公告滚动动画 - 参考活动滚动动画逻辑
  1082. @keyframes noticeScroll {
  1083. 0% {
  1084. transform: translateX(0);
  1085. }
  1086. 100% {
  1087. transform: translateX(-50%); /* 滚动到第一组公告完全移出,第二组接上 */
  1088. }
  1089. }
  1090. /* 功能入口 */
  1091. .function-grid {
  1092. display: flex; /* 核心:改为flex布局 */
  1093. flex-wrap: wrap; /* 自动换行 */
  1094. gap: 25rpx; /* 保留间距(注意:低版本浏览器可能不兼容flex gap,需用margin替代) */
  1095. margin: 20rpx 1rpx;
  1096. padding: 30rpx 20rpx;
  1097. background: #fefeff;
  1098. border-radius: 20rpx;
  1099. border: 2rpx solid #f0f0f5;
  1100. box-shadow: 0 4rpx 16rpx rgba(220, 220, 240, 0.2);
  1101. /* 兼容低版本浏览器(无flex gap时):给子元素加margin,替代gap */
  1102. // > .grid-item {
  1103. // margin: 0 15rpx 30rpx 15rpx;
  1104. // }
  1105. // > .grid-item:nth-child(4n+1) {
  1106. // margin-left: 0;
  1107. // }
  1108. // > .grid-item:nth-child(n+5) {
  1109. // margin-top: 30rpx;
  1110. // }
  1111. }
  1112. .grid-item {
  1113. display: flex;
  1114. flex-direction: column;
  1115. align-items: center;
  1116. justify-content: center;
  1117. gap: 16rpx;
  1118. padding: 24rpx 12rpx;
  1119. transition: all 0.3s ease;
  1120. border-radius: 16rpx;
  1121. background: linear-gradient(180deg, #fff 0%, #fdfdff 100%);
  1122. box-shadow: 0 2rpx 8rpx rgba(220, 220, 240, 0.15);
  1123. /* 核心:保证4列均分,每列最小宽度限制 */
  1124. flex: 1;
  1125. min-width: calc(25% - 22.5rpx); /* 25% - 30rpx/2(gap的一半),适配4列 */
  1126. max-width: calc(25% - 22.5rpx);
  1127. box-sizing: border-box; /* 避免padding撑大宽度 */
  1128. &:hover,
  1129. &:active {
  1130. transform: translateY(-4rpx) scale(0.98);
  1131. background: linear-gradient(180deg, #fff 0%, #f8f8ff 100%);
  1132. box-shadow: 0 6rpx 18rpx rgba(200, 200, 230, 0.25);
  1133. }
  1134. }
  1135. /* 为不同功能定制图标容器底色(贴合功能主题) */
  1136. .grid-item:nth-child(1) .grid-icon-wrapper {
  1137. background: linear-gradient(135deg, #ff85a2 0%, #ff5d8f 100%);
  1138. }
  1139. .grid-item:nth-child(2) .grid-icon-wrapper {
  1140. background: linear-gradient(135deg, #85cfff 0%, #5daaff 100%);
  1141. }
  1142. .grid-item:nth-child(3) .grid-icon-wrapper {
  1143. background: linear-gradient(135deg, #ffc885 0%, #ffaa5d 100%);
  1144. }
  1145. .grid-item:nth-child(4) .grid-icon-wrapper {
  1146. background: linear-gradient(135deg, #ff85d2 0%, #ff5daa 100%);
  1147. }
  1148. .grid-icon-wrapper {
  1149. width: 150rpx;
  1150. height: 150rpx;
  1151. display: flex;
  1152. align-items: center;
  1153. justify-content: center;
  1154. border-radius: 24rpx;
  1155. position: relative;
  1156. overflow: hidden;
  1157. box-shadow: inset 0 3rpx 10rpx rgba(255, 255, 255, 0.4),
  1158. 0 8rpx 24rpx rgba(0, 0, 0, 0.12);
  1159. transition: all 0.3s ease;
  1160. }
  1161. .grid-icon-wrapper::before {
  1162. content: '';
  1163. position: absolute;
  1164. top: -50%;
  1165. left: -50%;
  1166. width: 200%;
  1167. height: 200%;
  1168. background: linear-gradient(135deg,
  1169. rgba(255, 255, 255, 0.7) 0%,
  1170. rgba(255, 255, 255, 0.3) 40%,
  1171. transparent 80%);
  1172. transform: rotate(45deg);
  1173. pointer-events: none;
  1174. z-index: 1;
  1175. }
  1176. .grid-icon {
  1177. font-size: 80rpx;
  1178. color: #fff;
  1179. position: relative;
  1180. z-index: 2;
  1181. filter: drop-shadow(0 4rpx 8rpx rgba(0, 0, 0, 0.15));
  1182. }
  1183. /* 功能图标装饰 */
  1184. .grid-item:nth-child(1) .grid-icon::after {
  1185. content: '⭐';
  1186. position: absolute;
  1187. top: 10rpx;
  1188. right: 10rpx;
  1189. font-size: 30rpx;
  1190. transform: rotate(15deg);
  1191. }
  1192. .grid-item:nth-child(4) .grid-icon::after {
  1193. content: '🎀';
  1194. position: absolute;
  1195. bottom: 10rpx;
  1196. right: 10rpx;
  1197. font-size: 30rpx;
  1198. }
  1199. .grid-text {
  1200. font-size: 26rpx;
  1201. font-weight: 600;
  1202. color: #2d2d46;
  1203. text-align: center;
  1204. line-height: 1.3;
  1205. text-shadow: 0 1rpx 3rpx rgba(0, 0, 0, 0.05);
  1206. }
  1207. /* 响应式适配:小屏自动改为2列 */
  1208. @media (max-width: 600rpx) {
  1209. .grid-item {
  1210. min-width: calc(50% - 15rpx);
  1211. max-width: calc(50% - 15rpx);
  1212. }
  1213. }
  1214. /* 区块样式 */
  1215. .section {
  1216. margin: 40rpx 0;
  1217. .section-header {
  1218. display: flex;
  1219. justify-content: space-between;
  1220. align-items: center;
  1221. padding: 0 35rpx;
  1222. margin-bottom: 25rpx;
  1223. .section-title {
  1224. font-size: 36rpx;
  1225. font-weight: 800;
  1226. color: #333333;
  1227. border-left: 6rpx solid #E91E63;
  1228. padding-left: 16rpx;
  1229. }
  1230. .section-more {
  1231. font-size: 26rpx;
  1232. color: #E91E63;
  1233. font-weight: 600;
  1234. transition: all 0.2s ease;
  1235. &:active {
  1236. opacity: 0.6;
  1237. }
  1238. }
  1239. }
  1240. }
  1241. /* 平台活动展示区 */
  1242. .activity-recommend-section {
  1243. .activity-scroll-container {
  1244. margin: 0 35rpx;
  1245. overflow: hidden;
  1246. position: relative;
  1247. .activity-scroll-wrapper {
  1248. width: 100%;
  1249. overflow: hidden;
  1250. .activity-scroll-content {
  1251. display: flex;
  1252. animation: activityScroll 30s linear infinite;
  1253. gap: 20rpx;
  1254. width: fit-content;
  1255. &:hover {
  1256. animation-play-state: paused;
  1257. }
  1258. .activity-card-scroll {
  1259. flex-shrink: 0;
  1260. width: 500rpx;
  1261. background: #FFFFFF;
  1262. border-radius: 16rpx;
  1263. overflow: hidden;
  1264. border: 2rpx solid #E0E0E0;
  1265. transition: all 0.3s ease;
  1266. &:active {
  1267. transform: scale(0.98);
  1268. opacity: 0.9;
  1269. }
  1270. .activity-image-wrapper {
  1271. position: relative;
  1272. width: 100%;
  1273. height: 280rpx;
  1274. overflow: hidden;
  1275. .activity-image {
  1276. width: 100%;
  1277. height: 100%;
  1278. }
  1279. .activity-status {
  1280. position: absolute;
  1281. top: 15rpx;
  1282. right: 15rpx;
  1283. padding: 6rpx 12rpx;
  1284. background: #4CAF50;
  1285. color: #FFFFFF;
  1286. font-size: 22rpx;
  1287. font-weight: 600;
  1288. border-radius: 8rpx;
  1289. }
  1290. }
  1291. .activity-info-static {
  1292. padding: 20rpx;
  1293. .activity-name-static {
  1294. font-size: 28rpx;
  1295. font-weight: 700;
  1296. color: #333333;
  1297. margin-bottom: 8rpx;
  1298. line-height: 1.3;
  1299. }
  1300. .activity-time-static {
  1301. font-size: 24rpx;
  1302. color: #666666;
  1303. line-height: 1.4;
  1304. }
  1305. }
  1306. }
  1307. }
  1308. }
  1309. }
  1310. }
  1311. @keyframes activityScroll {
  1312. 0% {
  1313. transform: translateX(0);
  1314. }
  1315. 100% {
  1316. transform: translateX(-50%);
  1317. }
  1318. }
  1319. /* 今日缘分推荐 */
  1320. .fate-recommend-section {
  1321. .fate-cards {
  1322. display: flex;
  1323. gap: 20rpx;
  1324. padding: 0 35rpx;
  1325. overflow-x: auto;
  1326. scrollbar-width: none;
  1327. &::-webkit-scrollbar {
  1328. display: none;
  1329. }
  1330. .fate-card {
  1331. min-width: 320rpx;
  1332. background: #FFFFFF;
  1333. border-radius: 16rpx;
  1334. padding: 25rpx;
  1335. border: 2rpx solid #E0E0E0;
  1336. display: flex;
  1337. flex-direction: column;
  1338. align-items: center;
  1339. gap: 15rpx;
  1340. position: relative;
  1341. transition: all 0.2s ease;
  1342. &:active {
  1343. background: #F5F5F5;
  1344. }
  1345. .user-avatar-wrapper {
  1346. position: relative;
  1347. .user-avatar {
  1348. width: 100rpx;
  1349. height: 100rpx;
  1350. border-radius: 50%;
  1351. border: 3rpx solid #E0E0E0;
  1352. }
  1353. .online-status {
  1354. position: absolute;
  1355. bottom: 5rpx;
  1356. right: 5rpx;
  1357. width: 20rpx;
  1358. height: 20rpx;
  1359. background: #4CAF50;
  1360. border-radius: 50%;
  1361. border: 3rpx solid white;
  1362. }
  1363. }
  1364. .user-basic-info {
  1365. text-align: center;
  1366. .user-nickname {
  1367. font-size: 28rpx;
  1368. font-weight: 700;
  1369. color: #333333;
  1370. display: block;
  1371. margin-bottom: 5rpx;
  1372. }
  1373. .user-age-location {
  1374. font-size: 24rpx;
  1375. color: #666666;
  1376. }
  1377. }
  1378. .match-score {
  1379. display: flex;
  1380. align-items: center;
  1381. gap: 8rpx;
  1382. padding: 8rpx 16rpx;
  1383. background: #FFE5F1;
  1384. border-radius: 8rpx;
  1385. .match-text {
  1386. font-size: 22rpx;
  1387. color: #666666;
  1388. }
  1389. .match-percentage {
  1390. font-size: 26rpx;
  1391. font-weight: 700;
  1392. color: #E91E63;
  1393. }
  1394. }
  1395. .user-tags {
  1396. display: flex;
  1397. gap: 8rpx;
  1398. flex-wrap: wrap;
  1399. justify-content: center;
  1400. .user-tag {
  1401. font-size: 20rpx;
  1402. color: #666666;
  1403. background: #F5F5F5;
  1404. padding: 6rpx 12rpx;
  1405. border-radius: 8rpx;
  1406. border: 1rpx solid #E0E0E0;
  1407. }
  1408. }
  1409. }
  1410. }
  1411. }
  1412. /* 个人魅力指数 */
  1413. .charm-index-section {
  1414. margin: 25rpx 35rpx;
  1415. .charm-card {
  1416. background: #FFFFFF;
  1417. border-radius: 16rpx;
  1418. padding: 35rpx;
  1419. border: 2rpx solid #E0E0E0;
  1420. .charm-header {
  1421. display: flex;
  1422. justify-content: space-between;
  1423. align-items: center;
  1424. margin-bottom: 25rpx;
  1425. .charm-title {
  1426. font-size: 32rpx;
  1427. font-weight: 800;
  1428. color: #333333;
  1429. }
  1430. .charm-score {
  1431. font-size: 48rpx;
  1432. font-weight: 800;
  1433. color: #E91E63;
  1434. }
  1435. }
  1436. .charm-progress {
  1437. margin-bottom: 30rpx;
  1438. .progress-bar {
  1439. width: 100%;
  1440. height: 12rpx;
  1441. background: #FFE5F1;
  1442. border-radius: 6rpx;
  1443. overflow: hidden;
  1444. margin-bottom: 10rpx;
  1445. .progress-fill {
  1446. height: 100%;
  1447. background: #E91E63;
  1448. border-radius: 6rpx;
  1449. transition: width 1s ease;
  1450. }
  1451. }
  1452. .progress-text {
  1453. font-size: 24rpx;
  1454. color: #666666;
  1455. text-align: center;
  1456. display: block;
  1457. }
  1458. }
  1459. .charm-items {
  1460. display: flex;
  1461. flex-direction: column;
  1462. gap: 20rpx;
  1463. margin-bottom: 25rpx;
  1464. .charm-item {
  1465. display: flex;
  1466. justify-content: space-between;
  1467. align-items: center;
  1468. .charm-item-label {
  1469. font-size: 26rpx;
  1470. color: #666666;
  1471. font-weight: 500;
  1472. }
  1473. .charm-item-progress {
  1474. display: flex;
  1475. align-items: center;
  1476. gap: 12rpx;
  1477. flex: 1;
  1478. margin-left: 20rpx;
  1479. .item-progress-bar {
  1480. flex: 1;
  1481. height: 8rpx;
  1482. background: #FFE5F1;
  1483. border-radius: 4rpx;
  1484. overflow: hidden;
  1485. .item-progress-fill {
  1486. height: 100%;
  1487. background: #E91E63;
  1488. border-radius: 4rpx;
  1489. transition: width 1s ease;
  1490. }
  1491. }
  1492. .charm-item-score {
  1493. font-size: 24rpx;
  1494. color: #E91E63;
  1495. font-weight: 600;
  1496. min-width: 60rpx;
  1497. text-align: right;
  1498. }
  1499. }
  1500. }
  1501. }
  1502. .charm-tip {
  1503. padding: 20rpx;
  1504. background: #FFF8E1;
  1505. border-radius: 8rpx;
  1506. border: 2rpx solid #FFD54F;
  1507. .tip-text {
  1508. font-size: 24rpx;
  1509. color: #666666;
  1510. line-height: 1.5;
  1511. }
  1512. }
  1513. }
  1514. }
  1515. /* 底部占位 */
  1516. .bottom-placeholder {
  1517. height: 30rpx;
  1518. }
  1519. /* 底部导航栏 */
  1520. .tabbar {
  1521. position: fixed;
  1522. bottom: 0;
  1523. left: 0;
  1524. right: 0;
  1525. display: flex;
  1526. background-color: #FFFFFF;
  1527. border-top: 1rpx solid #F0F0F0;
  1528. padding-bottom: constant(safe-area-inset-bottom);
  1529. padding-bottom: env(safe-area-inset-bottom);
  1530. z-index: 999;
  1531. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  1532. .tabbar-item {
  1533. flex: 1;
  1534. display: flex;
  1535. flex-direction: column;
  1536. align-items: center;
  1537. justify-content: center;
  1538. padding: 15rpx 0;
  1539. position: relative;
  1540. .first-icon{
  1541. width: 25px;
  1542. height: 25px;
  1543. margin-bottom: 5px;
  1544. margin-top: 5px;
  1545. }
  1546. .tabbar-icon {
  1547. font-size: 44rpx;
  1548. margin-bottom: 5rpx;
  1549. }
  1550. .tabbar-text {
  1551. font-size: 22rpx;
  1552. color: #722F37;
  1553. }
  1554. &.active {
  1555. .tabbar-text {
  1556. color: #E91E63;
  1557. font-weight: bold;
  1558. }
  1559. }
  1560. }
  1561. }
  1562. /* 成功案例 */
  1563. .success-case-section {
  1564. .success-case-grid {
  1565. display: grid;
  1566. grid-template-columns: repeat(2, 1fr);
  1567. gap: 20rpx;
  1568. margin: 0 35rpx;
  1569. .case-card {
  1570. background: #FFFFFF;
  1571. border-radius: 16rpx;
  1572. overflow: hidden;
  1573. border: 2rpx solid #E0E0E0;
  1574. transition: all 0.3s ease;
  1575. &:active {
  1576. transform: scale(0.98);
  1577. opacity: 0.9;
  1578. }
  1579. .case-image-wrapper {
  1580. width: 100%;
  1581. height: 320rpx;
  1582. position: relative;
  1583. overflow: hidden;
  1584. .case-image {
  1585. width: 100%;
  1586. height: 100%;
  1587. }
  1588. }
  1589. .case-content {
  1590. padding: 20rpx;
  1591. .couple-names {
  1592. font-size: 28rpx;
  1593. font-weight: 700;
  1594. color: #333333;
  1595. margin-bottom: 10rpx;
  1596. line-height: 1.3;
  1597. }
  1598. .case-quote {
  1599. font-size: 24rpx;
  1600. color: #666666;
  1601. line-height: 1.5;
  1602. margin-bottom: 12rpx;
  1603. display: -webkit-box;
  1604. -webkit-box-orient: vertical;
  1605. -webkit-line-clamp: 2;
  1606. overflow: hidden;
  1607. }
  1608. .case-meta {
  1609. .marriage-date {
  1610. font-size: 22rpx;
  1611. color: #999999;
  1612. line-height: 1.4;
  1613. }
  1614. }
  1615. }
  1616. }
  1617. }
  1618. }
  1619. @keyframes marquee {
  1620. 0% {
  1621. transform: translateX(0);
  1622. }
  1623. 100% {
  1624. transform: translateX(-50%);
  1625. }
  1626. }
  1627. .tabbar-badge {
  1628. position: absolute;
  1629. top: 8rpx;
  1630. right: 50%;
  1631. margin-right: -40rpx;
  1632. min-width: 32rpx;
  1633. height: 32rpx;
  1634. line-height: 32rpx;
  1635. padding: 0 6rpx;
  1636. background-color: #FA5151;
  1637. border-radius: 16rpx;
  1638. font-size: 20rpx;
  1639. color: #FFFFFF;
  1640. text-align: center;
  1641. }
  1642. </style>