index.vue 49 KB

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