index.vue 43 KB

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