index.vue 25 KB

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