index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  1. <template>
  2. <view class="plaza-page">
  3. <!-- 顶部标题栏 -->
  4. <view class="header">
  5. <view class="header-background">
  6. <view class="feather feather-left">🪶</view>
  7. <view class="feather feather-right">🪶</view>
  8. </view>
  9. <view class="header-content">
  10. <text class="header-subtitle">两只羽毛</text>
  11. <text class="header-title">💕 缘分广场</text>
  12. <text class="header-desc">两只羽毛相遇,编织爱情故事</text>
  13. </view>
  14. </view>
  15. <!-- 动态列表 -->
  16. <scroll-view
  17. class="dynamic-list"
  18. scroll-y
  19. @scrolltolower="loadMore"
  20. refresher-enabled
  21. :refresher-triggered="refreshing"
  22. @refresherrefresh="onRefresh"
  23. >
  24. <!-- 列表内容 -->
  25. <view class="list-content">
  26. <!-- 动态卡片 -->
  27. <view
  28. v-for="item in dynamicList"
  29. :key="item.dynamicId"
  30. class="dynamic-card"
  31. @click="goToDetail(item.dynamicId)"
  32. @longpress="showReportMenu(item)"
  33. >
  34. <!-- 用户信息 -->
  35. <view class="user-info">
  36. <image
  37. :src="getAvatar(item)"
  38. class="avatar"
  39. mode="aspectFill"
  40. ></image>
  41. <view class="user-details">
  42. <text class="nickname">{{ getNickname(item) }}</text>
  43. <text class="time">{{ formatTime(item.createdAt) }}</text>
  44. </view>
  45. </view>
  46. <!-- 动态内容 -->
  47. <view class="dynamic-content">
  48. <text class="content-text">{{ item.content }}</text>
  49. </view>
  50. <!-- 媒体内容(图片) -->
  51. <view v-if="item.mediaUrls && item.mediaUrls.length > 0" class="media-container">
  52. <view
  53. :class="['image-grid', getGridClass(item)]"
  54. >
  55. <image
  56. v-for="(url, index) in item.mediaUrls.slice(0, 9)"
  57. :key="index"
  58. :src="url"
  59. class="media-image"
  60. mode="aspectFill"
  61. @click.stop="previewImage(item.mediaUrls, index)"
  62. ></image>
  63. </view>
  64. </view>
  65. <!-- 互动栏 -->
  66. <view class="action-bar">
  67. <view class="action-item" @click.stop="handleLike(item)">
  68. <text :class="['icon', !!item.isLiked ? 'icon-liked' : '']">
  69. {{ !!item.isLiked ? '❤️' : '🤍' }}
  70. </text>
  71. <text class="action-text">{{ item.likeCount || 0 }}</text>
  72. </view>
  73. <view class="action-item">
  74. <text class="icon">💬</text>
  75. <text class="action-text">{{ item.commentCount || 0 }}</text>
  76. </view>
  77. <view class="action-item" @click.stop="handleFavorite(item)">
  78. <text :class="['icon', !!item.isFavorited ? 'icon-favorited' : '']">
  79. {{ !!item.isFavorited ? '⭐' : '☆' }}
  80. </text>
  81. <text class="action-text">{{ item.favoriteCount || 0 }}</text>
  82. </view>
  83. </view>
  84. </view>
  85. <!-- 加载提示 -->
  86. <view class="loading-tip" v-if="loading">
  87. <text>加载中...</text>
  88. </view>
  89. <!-- 没有更多数据 -->
  90. <view class="loading-tip" v-if="noMore && dynamicList.length > 0">
  91. <text>没有更多了~</text>
  92. </view>
  93. <!-- 空状态 -->
  94. <view class="empty-state" v-if="!loading && dynamicList.length === 0">
  95. <view class="empty-feathers">
  96. <text class="feather-icon">🪶</text>
  97. <text class="feather-icon">🪶</text>
  98. </view>
  99. <text class="empty-text">还没有缘分动态</text>
  100. <text class="empty-hint">快来分享你的美好时光,遇见有趣的灵魂吧~</text>
  101. <view class="empty-action" @click="goToPublish">
  102. <text>💕 发布第一条动态</text>
  103. </view>
  104. </view>
  105. </view>
  106. </scroll-view>
  107. <!-- 发布按钮 -->
  108. <view class="publish-btn" @click="goToPublish">
  109. <view class="publish-bg">
  110. <text class="publish-icon">💕</text>
  111. <text class="publish-text">分享心动</text>
  112. </view>
  113. </view>
  114. <!-- 举报菜单弹窗 -->
  115. <view v-if="showMenu" class="report-menu-popup">
  116. <view class="menu-mask" @click="hideReportMenu"></view>
  117. <view class="menu-content">
  118. <view class="menu-item" @click="handleReport">
  119. <text class="menu-icon">🚩</text>
  120. <text class="menu-text">举报此动态</text>
  121. </view>
  122. <view class="menu-item cancel" @click="hideReportMenu">
  123. <text class="menu-text">取消</text>
  124. </view>
  125. </view>
  126. </view>
  127. <!-- 底部导航栏 -->
  128. <view class="tabbar">
  129. <view class="tabbar-item" @click="switchTab('index')">
  130. <text class="tabbar-icon">🏠</text>
  131. <text class="tabbar-text">首页</text>
  132. </view>
  133. <view class="tabbar-item active" @click="switchTab('plaza')">
  134. <text class="tabbar-icon">💕</text>
  135. <text class="tabbar-text">动态</text>
  136. </view>
  137. <view class="tabbar-item" @click="switchTab('recommend')">
  138. <text class="tabbar-icon">👍</text>
  139. <text class="tabbar-text">推荐</text>
  140. </view>
  141. <view class="tabbar-item" @click="switchTab('message')">
  142. <text class="tabbar-icon">💬</text>
  143. <text class="tabbar-text">消息</text>
  144. <view v-if="unreadCount > 0" class="tabbar-badge">{{ unreadCount }}</view>
  145. </view>
  146. <view class="tabbar-item" @click="switchTab('mine')">
  147. <text class="tabbar-icon">👤</text>
  148. <text class="tabbar-text">我的</text>
  149. </view>
  150. </view>
  151. </view>
  152. </template>
  153. <script>
  154. import api from '@/utils/api.js'
  155. export default {
  156. data() {
  157. return {
  158. dynamicList: [],
  159. pageNum: 1,
  160. pageSize: 10,
  161. loading: false,
  162. refreshing: false,
  163. noMore: false,
  164. showMenu: false, // 显示举报菜单
  165. selectedDynamic: null, // 选中的动态
  166. currentUserId: 1, // 当前用户ID,实际应从存储获取
  167. defaultAvatar: 'https://via.placeholder.com/100x100.png?text=头像',
  168. likingMap: {}, // 记录正在点赞的动态ID,防止重复点击
  169. favoritingMap: {} // 记录正在收藏的动态ID,防止重复点击
  170. }
  171. },
  172. computed: {
  173. unreadCount() {
  174. return this.$store.getters.getTotalUnread || 0;
  175. }
  176. },
  177. onLoad() {
  178. // 从存储中获取当前用户ID
  179. const storedUserId = uni.getStorageSync('userId')
  180. if (storedUserId !== null && storedUserId !== undefined && storedUserId !== '') {
  181. this.currentUserId = parseInt(storedUserId)
  182. } else {
  183. // 尝试从 userInfo 中获取
  184. const userInfo = uni.getStorageSync('userInfo')
  185. if (userInfo && (userInfo.userId || userInfo.id || userInfo.user_id)) {
  186. this.currentUserId = parseInt(userInfo.userId || userInfo.id || userInfo.user_id)
  187. } else {
  188. // 未登录,设置为 null
  189. this.currentUserId = null
  190. }
  191. }
  192. this.loadDynamicList()
  193. // 监听详情页更新事件,实时同步点赞/收藏状态
  194. uni.$on('dynamic-updated', (payload) => {
  195. if (!payload || !payload.dynamicId) return
  196. const idx = this.dynamicList.findIndex(x => x.dynamicId === payload.dynamicId)
  197. if (idx !== -1) {
  198. const item = this.dynamicList[idx]
  199. // 使用 hasOwnProperty 严格检查属性是否存在,只更新事件中明确包含的字段
  200. // 这样可以避免误更新不相关的字段(如点赞时误更新收藏状态)
  201. // 根据 dynamic_likes 表判断:有记录显示 ❤️,无记录显示 🤍
  202. if (payload.hasOwnProperty('isLiked') && payload.isLiked !== undefined && payload.isLiked !== null) {
  203. this.$set(item, 'isLiked', payload.isLiked === true || payload.isLiked === 1 || payload.isLiked === 'true' || payload.isLiked === '1')
  204. }
  205. if (payload.hasOwnProperty('likeCount') && payload.likeCount !== undefined && payload.likeCount !== null) {
  206. this.$set(item, 'likeCount', Number(payload.likeCount) || 0)
  207. }
  208. // 只有当 isFavorited 明确存在于 payload 中时才更新(避免误更新)
  209. // 根据 dynamic_favorites 表判断:有记录显示 ⭐,无记录显示 ☆
  210. if (payload.hasOwnProperty('isFavorited') && payload.isFavorited !== undefined && payload.isFavorited !== null) {
  211. this.$set(item, 'isFavorited', payload.isFavorited === true || payload.isFavorited === 1 || payload.isFavorited === 'true' || payload.isFavorited === '1')
  212. }
  213. if (payload.hasOwnProperty('favoriteCount') && payload.favoriteCount !== undefined && payload.favoriteCount !== null) {
  214. this.$set(item, 'favoriteCount', Number(payload.favoriteCount) || 0)
  215. }
  216. }
  217. })
  218. // 监听发布页插入新动态
  219. uni.$on('dynamic-insert', (d) => {
  220. if (!d) return
  221. // 仅在第一页顶部插入
  222. this.dynamicList = [d, ...this.dynamicList]
  223. })
  224. },
  225. onShow() {
  226. // 返回列表页时自动刷新,确保状态一致
  227. // 重新获取当前用户ID(可能在其他页面登录/登出)
  228. const storedUserId = uni.getStorageSync('userId')
  229. if (storedUserId !== null && storedUserId !== undefined && storedUserId !== '') {
  230. this.currentUserId = parseInt(storedUserId)
  231. } else {
  232. // 尝试从 userInfo 中获取
  233. const userInfo = uni.getStorageSync('userInfo')
  234. if (userInfo && (userInfo.userId || userInfo.id || userInfo.user_id)) {
  235. this.currentUserId = parseInt(userInfo.userId || userInfo.id || userInfo.user_id)
  236. } else {
  237. // 未登录,设置为 null
  238. this.currentUserId = null
  239. }
  240. }
  241. this.pageNum = 1
  242. this.noMore = false
  243. this.dynamicList = []
  244. this.loadDynamicList()
  245. },
  246. methods: {
  247. // 兼容WXML:获取头像
  248. getAvatar(item) {
  249. if (item && item.user && item.user.avatarUrl) {
  250. return item.user.avatarUrl
  251. }
  252. return this.defaultAvatar
  253. },
  254. // 兼容WXML:获取昵称
  255. getNickname(item) {
  256. if (item && item.user && item.user.nickname) {
  257. return item.user.nickname
  258. }
  259. return '匿名用户'
  260. },
  261. // 兼容WXML:图片栅格class
  262. getGridClass(item) {
  263. const len = (item && item.mediaUrls && item.mediaUrls.length) ? item.mediaUrls.length : 0
  264. const n = Math.min(len, 3)
  265. return 'grid-' + n
  266. },
  267. // 加载动态列表
  268. async loadDynamicList() {
  269. if (this.loading || this.noMore) return
  270. this.loading = true
  271. try {
  272. const res = await api.dynamic.getRecommendList({
  273. pageNum: this.pageNum,
  274. pageSize: this.pageSize,
  275. userId: this.currentUserId
  276. })
  277. if (res && res.records) {
  278. // 处理数据,确保布尔值正确转换(根据 dynamic_likes 和 dynamic_favorites 表判断)
  279. // 后端返回的 isLiked 和 isFavorited 应该已经是 Boolean,但为了兼容性,确保正确转换
  280. const newData = res.records.map(item => ({
  281. ...item,
  282. // 如果 dynamic_likes 表中有记录,显示 ❤️,否则显示 🤍
  283. isLiked: item.isLiked === true || item.isLiked === 1 || item.isLiked === 'true' || item.isLiked === '1',
  284. // 如果 dynamic_favorites 表中有记录,显示 ⭐,否则显示 ☆
  285. isFavorited: item.isFavorited === true || item.isFavorited === 1 || item.isFavorited === 'true' || item.isFavorited === '1'
  286. }))
  287. if (this.pageNum === 1) {
  288. this.dynamicList = newData
  289. } else {
  290. this.dynamicList = [...this.dynamicList, ...newData]
  291. }
  292. // 判断是否还有更多数据
  293. if (res.current >= res.pages) {
  294. this.noMore = true
  295. } else {
  296. this.pageNum++
  297. }
  298. }
  299. } catch (error) {
  300. console.error('加载动态列表失败:', error)
  301. uni.showToast({
  302. title: '加载失败',
  303. icon: 'none'
  304. })
  305. } finally {
  306. this.loading = false
  307. this.refreshing = false
  308. }
  309. },
  310. // 下拉刷新
  311. onRefresh() {
  312. this.refreshing = true
  313. this.pageNum = 1
  314. this.noMore = false
  315. this.dynamicList = []
  316. this.loadDynamicList()
  317. },
  318. // 上拉加载更多
  319. loadMore() {
  320. if (!this.noMore && !this.loading) {
  321. this.loadDynamicList()
  322. }
  323. },
  324. // 处理点赞
  325. async handleLike(item) {
  326. // 防止重复点击:如果正在处理该动态的点赞请求,直接返回
  327. if (this.likingMap[item.dynamicId]) {
  328. return
  329. }
  330. try {
  331. // 标记为正在处理
  332. this.$set(this.likingMap, item.dynamicId, true)
  333. // 根据 dynamic_likes 表判断是否点赞(有记录显示 ❤️,无记录显示 🤍)
  334. const isLiked = item.isLiked === true || item.isLiked === 1 || item.isLiked === 'true' || item.isLiked === '1'
  335. const originalCount = item.likeCount || 0
  336. const newIsLiked = !isLiked
  337. const newLikeCount = isLiked ? Math.max(0, originalCount - 1) : originalCount + 1
  338. // 立即更新UI(乐观更新),使用 $set 确保响应式更新
  339. this.$set(item, 'isLiked', newIsLiked)
  340. this.$set(item, 'likeCount', newLikeCount)
  341. // 发送请求
  342. if (isLiked) {
  343. // 取消点赞
  344. await api.dynamic.unlike(item.dynamicId)
  345. } else {
  346. // 点赞
  347. await api.dynamic.like(item.dynamicId)
  348. }
  349. } catch (error) {
  350. console.error('点赞操作失败:', error)
  351. // 请求失败,恢复原状态
  352. const currentIsLiked = item.isLiked === true || item.isLiked === 1 || item.isLiked === 'true' || item.isLiked === '1'
  353. this.$set(item, 'isLiked', !currentIsLiked)
  354. this.$set(item, 'likeCount', !currentIsLiked ? (item.likeCount || 0) + 1 : Math.max(0, (item.likeCount || 0) - 1))
  355. uni.showToast({
  356. title: '操作失败,请重试',
  357. icon: 'none'
  358. })
  359. } finally {
  360. // 延迟300毫秒后释放锁,防止快速点击
  361. setTimeout(() => {
  362. this.$set(this.likingMap, item.dynamicId, false)
  363. }, 300)
  364. }
  365. },
  366. // 处理收藏
  367. async handleFavorite(item) {
  368. // 防止重复点击:如果正在处理该动态的收藏请求,直接返回
  369. if (this.favoritingMap[item.dynamicId]) {
  370. return
  371. }
  372. try {
  373. // 标记为正在处理
  374. this.$set(this.favoritingMap, item.dynamicId, true)
  375. // 根据 dynamic_favorites 表判断是否收藏(有记录显示 ⭐,无记录显示 ☆)
  376. const isFavorited = item.isFavorited === true || item.isFavorited === 1 || item.isFavorited === 'true' || item.isFavorited === '1'
  377. const originalCount = item.favoriteCount || 0
  378. const newIsFavorited = !isFavorited
  379. const newFavoriteCount = isFavorited ? Math.max(0, originalCount - 1) : originalCount + 1
  380. // 立即更新UI(乐观更新),使用 $set 确保响应式更新
  381. this.$set(item, 'isFavorited', newIsFavorited)
  382. this.$set(item, 'favoriteCount', newFavoriteCount)
  383. if (isFavorited) {
  384. // 取消收藏
  385. await api.dynamic.unfavorite(item.dynamicId)
  386. } else {
  387. // 收藏
  388. await api.dynamic.favorite(item.dynamicId)
  389. uni.showToast({
  390. title: '收藏成功',
  391. icon: 'success'
  392. })
  393. }
  394. } catch (error) {
  395. console.error('收藏操作失败:', error)
  396. // 请求失败,恢复原状态
  397. const currentIsFavorited = item.isFavorited === true || item.isFavorited === 1 || item.isFavorited === 'true' || item.isFavorited === '1'
  398. this.$set(item, 'isFavorited', !currentIsFavorited)
  399. this.$set(item, 'favoriteCount', !currentIsFavorited ? (item.favoriteCount || 0) + 1 : Math.max(0, (item.favoriteCount || 0) - 1))
  400. uni.showToast({
  401. title: '操作失败,请重试',
  402. icon: 'none'
  403. })
  404. } finally {
  405. // 延迟300毫秒后释放锁,防止快速点击
  406. setTimeout(() => {
  407. this.$set(this.favoritingMap, item.dynamicId, false)
  408. }, 300)
  409. }
  410. },
  411. // 预览图片
  412. previewImage(urls, current) {
  413. uni.previewImage({
  414. urls: urls,
  415. current: current
  416. })
  417. },
  418. // 跳转到详情页
  419. goToDetail(dynamicId) {
  420. uni.navigateTo({
  421. url: `/pages/plaza/detail?id=${dynamicId}`
  422. })
  423. },
  424. // 跳转到发布页
  425. goToPublish() {
  426. uni.navigateTo({
  427. url: '/pages/plaza/publish'
  428. })
  429. },
  430. // 显示举报菜单
  431. showReportMenu(item) {
  432. // 震动反馈
  433. uni.vibrateShort({
  434. type: 'light'
  435. })
  436. this.selectedDynamic = item
  437. this.showMenu = true
  438. },
  439. // 隐藏举报菜单
  440. hideReportMenu() {
  441. this.showMenu = false
  442. this.selectedDynamic = null
  443. },
  444. // 处理举报
  445. handleReport() {
  446. this.hideReportMenu()
  447. if (!this.selectedDynamic || !this.selectedDynamic.dynamicId) {
  448. uni.showToast({
  449. title: '动态ID不存在',
  450. icon: 'none'
  451. })
  452. return
  453. }
  454. // 跳转到举报页面
  455. uni.navigateTo({
  456. url: `/pages/plaza/report?id=${this.selectedDynamic.dynamicId}`
  457. })
  458. },
  459. // 格式化时间
  460. formatTime(timeStr) {
  461. if (!timeStr) return ''
  462. const time = new Date(timeStr)
  463. const now = new Date()
  464. const diff = now - time
  465. // 1分钟内
  466. if (diff < 60000) {
  467. return '刚刚'
  468. }
  469. // 1小时内
  470. if (diff < 3600000) {
  471. return Math.floor(diff / 60000) + '分钟前'
  472. }
  473. // 24小时内
  474. if (diff < 86400000) {
  475. return Math.floor(diff / 3600000) + '小时前'
  476. }
  477. // 7天内
  478. if (diff < 604800000) {
  479. return Math.floor(diff / 86400000) + '天前'
  480. }
  481. // 超过7天显示日期
  482. const year = time.getFullYear()
  483. const month = String(time.getMonth() + 1).padStart(2, '0')
  484. const day = String(time.getDate()).padStart(2, '0')
  485. if (year === now.getFullYear()) {
  486. return `${month}-${day}`
  487. }
  488. return `${year}-${month}-${day}`
  489. },
  490. // 切换Tab
  491. switchTab(tab) {
  492. if (tab === 'plaza') return
  493. const tabPages = {
  494. index: '/pages/index/index',
  495. recommend: '/pages/recommend/index',
  496. message: '/pages/message/index',
  497. mine: '/pages/mine/index'
  498. }
  499. if (tabPages[tab]) {
  500. uni.redirectTo({
  501. url: tabPages[tab]
  502. })
  503. }
  504. }
  505. }
  506. }
  507. </script>
  508. <style lang="scss" scoped>
  509. .plaza-page {
  510. min-height: 100vh;
  511. background: #FFF0F5; // 淡淡粉色背景
  512. // 顶部标题栏
  513. .header {
  514. position: fixed;
  515. top: 0;
  516. left: 0;
  517. right: 0;
  518. height: 88rpx; // 更紧凑,减小头部占用
  519. background: transparent; // 移除重色背景,突出可爱风淡粉
  520. display: flex;
  521. flex-direction: column;
  522. align-items: center;
  523. justify-content: center;
  524. padding-top: 0; // 移除顶部安全区额外留白
  525. z-index: 999;
  526. box-shadow: none;
  527. overflow: visible;
  528. position: relative;
  529. .header-background { display: none; }
  530. .header-content {
  531. text-align: center;
  532. z-index: 1;
  533. .header-subtitle {
  534. font-size: 22rpx;
  535. color: #E91E63;
  536. display: block;
  537. margin-bottom: 8rpx;
  538. letter-spacing: 2rpx;
  539. }
  540. .header-title {
  541. font-size: 36rpx;
  542. font-weight: 700;
  543. color: #D81B60;
  544. text-shadow: none;
  545. display: block;
  546. margin-bottom: 2rpx; // 缩小标题与描述间距
  547. }
  548. .header-desc {
  549. font-size: 20rpx;
  550. color: #AD1457;
  551. display: block;
  552. letter-spacing: 1rpx;
  553. }
  554. }
  555. }
  556. // 动态列表
  557. .dynamic-list {
  558. margin-top: 88rpx; // 同步减少顶部外边距
  559. padding-bottom: 120rpx;
  560. height: calc(100vh - 88rpx);
  561. .list-content {
  562. padding: 12rpx; // 再收紧列表内边距
  563. }
  564. // 动态卡片
  565. .dynamic-card {
  566. background: #FFFFFF; // 纯白卡片
  567. border-radius: 20rpx;
  568. padding: 24rpx; // 收紧卡片内边距
  569. margin-bottom: 14rpx; // 卡片之间更紧凑
  570. box-shadow: 0 4rpx 12rpx rgba(233, 30, 99, 0.07);
  571. border: 1rpx solid rgba(255, 182, 193, 0.22);
  572. transition: all 0.3s ease;
  573. position: relative;
  574. overflow: hidden;
  575. // 用户信息
  576. .user-info {
  577. display: flex;
  578. align-items: center;
  579. margin-bottom: 24rpx;
  580. .avatar {
  581. width: 88rpx;
  582. height: 88rpx;
  583. border-radius: 50%;
  584. margin-right: 24rpx;
  585. border: 3rpx solid #FFB3BA;
  586. box-shadow: 0 4rpx 12rpx rgba(233, 30, 99, 0.2);
  587. }
  588. .user-details {
  589. flex: 1;
  590. .nickname {
  591. display: block;
  592. font-size: 30rpx;
  593. font-weight: 600;
  594. color: #2D1B69;
  595. margin-bottom: 8rpx;
  596. }
  597. .time {
  598. font-size: 24rpx;
  599. color: #8B5A96;
  600. opacity: 0.8;
  601. }
  602. }
  603. }
  604. // 动态内容
  605. .dynamic-content {
  606. margin-bottom: 20rpx;
  607. .content-text {
  608. font-size: 28rpx;
  609. line-height: 1.6;
  610. color: #333333;
  611. word-wrap: break-word;
  612. }
  613. }
  614. // 媒体容器
  615. .media-container {
  616. margin-bottom: 16rpx;
  617. .image-grid {
  618. display: grid;
  619. gap: 10rpx;
  620. &.grid-1 {
  621. grid-template-columns: 1fr;
  622. .media-image {
  623. height: 400rpx;
  624. border-radius: 12rpx;
  625. }
  626. }
  627. &.grid-2,
  628. &.grid-3 {
  629. grid-template-columns: repeat(3, 1fr);
  630. .media-image {
  631. height: 180rpx;
  632. border-radius: 12rpx;
  633. }
  634. }
  635. .media-image {
  636. width: 100%;
  637. background-color: #F5F5F5;
  638. }
  639. }
  640. }
  641. // 互动栏
  642. .action-bar {
  643. display: flex;
  644. align-items: center;
  645. padding-top: 20rpx;
  646. border-top: 1rpx solid #F5F5F5;
  647. .action-item {
  648. flex: 1;
  649. display: flex;
  650. align-items: center;
  651. justify-content: center;
  652. .icon {
  653. font-size: 40rpx;
  654. margin-right: 8rpx;
  655. &.icon-liked {
  656. animation: heartBeat 0.3s ease-in-out;
  657. }
  658. &.icon-favorited {
  659. animation: starShine 0.3s ease-in-out;
  660. }
  661. }
  662. .action-text {
  663. font-size: 24rpx;
  664. color: #666666;
  665. }
  666. }
  667. }
  668. }
  669. // 加载提示
  670. .loading-tip {
  671. text-align: center;
  672. padding: 40rpx 0;
  673. font-size: 24rpx;
  674. color: #999999;
  675. }
  676. // 空状态
  677. .empty-state {
  678. display: flex;
  679. flex-direction: column;
  680. align-items: center;
  681. justify-content: center;
  682. padding: 200rpx 60rpx;
  683. .empty-icon {
  684. font-size: 120rpx;
  685. margin-bottom: 30rpx;
  686. }
  687. .empty-text {
  688. font-size: 32rpx;
  689. color: #333333;
  690. margin-bottom: 16rpx;
  691. }
  692. .empty-hint {
  693. font-size: 24rpx;
  694. color: #999999;
  695. }
  696. }
  697. }
  698. // 发布按钮
  699. .publish-btn {
  700. position: fixed;
  701. bottom: 160rpx;
  702. right: 40rpx;
  703. z-index: 998;
  704. .publish-bg {
  705. width: 140rpx;
  706. height: 140rpx;
  707. background: linear-gradient(135deg, #FF6B9D 0%, #E91E63 25%, #C2185B 50%, #FF8A95 75%, #FFB3BA 100%);
  708. border-radius: 50%;
  709. display: flex;
  710. flex-direction: column;
  711. align-items: center;
  712. justify-content: center;
  713. box-shadow: 0 12rpx 36rpx rgba(233, 30, 99, 0.5);
  714. transition: all 0.3s ease;
  715. border: 4rpx solid rgba(255, 255, 255, 0.8);
  716. animation: pulse-love 3s ease-in-out infinite;
  717. &:active {
  718. transform: scale(0.9);
  719. }
  720. .publish-icon {
  721. font-size: 42rpx;
  722. margin-bottom: 4rpx;
  723. }
  724. .publish-text {
  725. font-size: 18rpx;
  726. color: rgba(255, 255, 255, 0.9);
  727. font-weight: 500;
  728. letter-spacing: 1rpx;
  729. }
  730. }
  731. }
  732. // 举报菜单弹窗
  733. .report-menu-popup {
  734. position: fixed;
  735. top: 0;
  736. left: 0;
  737. right: 0;
  738. bottom: 0;
  739. z-index: 9998;
  740. .menu-mask {
  741. position: absolute;
  742. top: 0;
  743. left: 0;
  744. right: 0;
  745. bottom: 0;
  746. background-color: rgba(0, 0, 0, 0.5);
  747. }
  748. .menu-content {
  749. position: absolute;
  750. bottom: 0;
  751. left: 0;
  752. right: 0;
  753. background-color: #FFFFFF;
  754. border-radius: 30rpx 30rpx 0 0;
  755. padding: 20rpx 30rpx;
  756. padding-bottom: calc(20rpx + constant(safe-area-inset-bottom));
  757. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  758. animation: slideUp 0.3s ease;
  759. .menu-item {
  760. height: 100rpx;
  761. display: flex;
  762. align-items: center;
  763. justify-content: center;
  764. border-radius: 12rpx;
  765. margin-bottom: 16rpx;
  766. transition: background-color 0.3s ease;
  767. &:not(.cancel) {
  768. background: #FFF5F7;
  769. &:active {
  770. background: #FFE8EC;
  771. }
  772. }
  773. &.cancel {
  774. background: #F5F5F5;
  775. margin-top: 8rpx;
  776. &:active {
  777. background: #EEEEEE;
  778. }
  779. }
  780. .menu-icon {
  781. font-size: 36rpx;
  782. margin-right: 12rpx;
  783. }
  784. .menu-text {
  785. font-size: 30rpx;
  786. color: #333333;
  787. font-weight: 500;
  788. }
  789. }
  790. }
  791. }
  792. // 底部导航栏
  793. .tabbar {
  794. position: fixed;
  795. bottom: 0;
  796. left: 0;
  797. right: 0;
  798. display: flex;
  799. background-color: #FFFFFF;
  800. border-top: 1rpx solid #F0F0F0;
  801. padding-bottom: constant(safe-area-inset-bottom);
  802. padding-bottom: env(safe-area-inset-bottom);
  803. z-index: 999;
  804. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  805. .tabbar-item {
  806. flex: 1;
  807. display: flex;
  808. flex-direction: column;
  809. align-items: center;
  810. justify-content: center;
  811. padding: 15rpx 0;
  812. position: relative;
  813. .tabbar-icon {
  814. font-size: 44rpx;
  815. margin-bottom: 5rpx;
  816. }
  817. .tabbar-text {
  818. font-size: 22rpx;
  819. color: #666666;
  820. }
  821. &.active {
  822. .tabbar-text {
  823. color: #E91E63;
  824. font-weight: bold;
  825. }
  826. }
  827. }
  828. }
  829. }
  830. // 动画
  831. @keyframes heartBeat {
  832. 0%, 100% {
  833. transform: scale(1);
  834. }
  835. 50% {
  836. transform: scale(1.2);
  837. }
  838. }
  839. @keyframes starShine {
  840. 0%, 100% {
  841. transform: scale(1) rotate(0deg);
  842. }
  843. 50% {
  844. transform: scale(1.2) rotate(15deg);
  845. }
  846. }
  847. @keyframes slideUp {
  848. from {
  849. transform: translateY(100%);
  850. }
  851. to {
  852. transform: translateY(0);
  853. }
  854. }
  855. .tabbar-badge {
  856. position: absolute;
  857. top: 8rpx;
  858. right: 50%;
  859. margin-right: -40rpx;
  860. min-width: 32rpx;
  861. height: 32rpx;
  862. line-height: 32rpx;
  863. padding: 0 6rpx;
  864. background-color: #FA5151;
  865. border-radius: 16rpx;
  866. font-size: 20rpx;
  867. color: #FFFFFF;
  868. text-align: center;
  869. }
  870. </style>