index.vue 45 KB

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