index.vue 44 KB

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