index.vue 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464
  1. <template>
  2. <div class="dynamic-management-container">
  3. <!-- 头部:Tabs和发布按钮 -->
  4. <div class="header-section">
  5. <el-tabs v-model="activeTab" @tab-click="handleTabClick">
  6. <el-tab-pane label="推荐" name="recommend" />
  7. <el-tab-pane label="关注" name="follow" />
  8. </el-tabs>
  9. <div class="action-buttons">
  10. <el-button type="primary" @click="handlePublish"> 发布动态 </el-button>
  11. </div>
  12. </div>
  13. <!-- 动态列表(推荐和关注共用) -->
  14. <div v-if="dynamicList.length > 0" class="content-section">
  15. <div class="dynamic-grid">
  16. <div v-for="item in paginatedList" :key="item.id" class="dynamic-card" @click="handleCardClick(item)">
  17. <!-- 图片/视频区域 -->
  18. <div class="dynamic-image-wrapper">
  19. <!-- 视频 -->
  20. <video v-if="item.isVideo && item.imageUrl" :src="item.imageUrl" class="dynamic-image" controls preload="metadata" />
  21. <!-- 图片 -->
  22. <img v-else-if="item.imageUrl" :src="item.imageUrl" :alt="item.title" class="dynamic-image" />
  23. <!-- 占位符 -->
  24. <div v-else class="image-placeholder">
  25. <el-icon :size="48" color="#999">
  26. <Picture />
  27. </el-icon>
  28. </div>
  29. </div>
  30. <!-- 动态内容 -->
  31. <div class="dynamic-content">
  32. <div class="dynamic-text">
  33. {{ item.title }}
  34. </div>
  35. <!-- 用户信息和点赞 -->
  36. <div class="dynamic-footer">
  37. <div class="user-info">
  38. <div class="user-avatar">
  39. <img v-if="item.userAvatar" :src="item.userAvatar" :alt="item.userName" />
  40. <el-icon v-else :size="24">
  41. <Avatar />
  42. </el-icon>
  43. </div>
  44. <span class="user-name">{{ item.userName }}</span>
  45. </div>
  46. <div class="like-section" @click.stop="handleLike(item)">
  47. <i class="iconfont icon-dianzanb" :style="{ fontSize: '18px', color: item.isLike == '1' ? '#f56c6c' : '#999' }" />
  48. <span class="like-count">{{ item.dianzanCount }}</span>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. <!-- 空状态 -->
  56. <div v-else class="empty-section">
  57. <el-empty :description="activeTab === 'follow' ? '暂无关注的动态' : '暂无动态数据'" />
  58. </div>
  59. <!-- 分页 -->
  60. <div v-if="dynamicList.length > 0" class="pagination-section">
  61. <el-pagination
  62. v-model:current-page="pagination.page"
  63. v-model:page-size="pagination.pageSize"
  64. :page-sizes="[10, 20, 30, 50]"
  65. :total="pagination.total"
  66. layout="total, sizes, prev, pager, next, jumper"
  67. @size-change="handleSizeChange"
  68. @current-change="handleCurrentChange"
  69. />
  70. </div>
  71. <!-- 动态详情 Drawer -->
  72. <el-drawer
  73. v-model="detailDrawerVisible"
  74. direction="rtl"
  75. size="90%"
  76. :show-close="false"
  77. destroy-on-close
  78. class="detail-drawer"
  79. >
  80. <template #header>
  81. <div class="drawer-header">
  82. <el-button class="close-btn" text @click="handleCloseDetail">
  83. <el-icon :size="24">
  84. <Close />
  85. </el-icon>
  86. </el-button>
  87. </div>
  88. </template>
  89. <div v-if="currentDetail" class="detail-content">
  90. <!-- 主内容区域 -->
  91. <div class="detail-main">
  92. <!-- 图片/视频轮播展示 -->
  93. <div class="media-container">
  94. <!-- 多媒体轮播 -->
  95. <el-carousel
  96. v-if="currentDetail.mediaList && currentDetail.mediaList.length > 0"
  97. :autoplay="false"
  98. :loop="false"
  99. indicator-position="outside"
  100. arrow="always"
  101. height="100%"
  102. class="media-carousel"
  103. @change="handleCarouselChange"
  104. >
  105. <el-carousel-item v-for="(media, index) in currentDetail.mediaList" :key="index">
  106. <!-- 视频 -->
  107. <video
  108. v-if="media.type === 'video'"
  109. :ref="el => setVideoRef(el, index)"
  110. :src="media.url"
  111. class="detail-media detail-video"
  112. controls
  113. preload="metadata"
  114. @play="handleVideoPlay(index)"
  115. />
  116. <!-- 图片 -->
  117. <img v-else :src="media.url" :alt="currentDetail.title" class="detail-media detail-image" />
  118. </el-carousel-item>
  119. </el-carousel>
  120. <!-- 占位符 -->
  121. <div v-else class="media-placeholder">
  122. <el-icon :size="80" color="#dcdfe6">
  123. <Picture />
  124. </el-icon>
  125. </div>
  126. <!-- 媒体计数指示器 -->
  127. <div v-if="currentDetail.mediaList && currentDetail.mediaList.length > 1" class="media-counter">
  128. {{ currentCarouselIndex + 1 }} / {{ currentDetail.mediaList.length }}
  129. </div>
  130. </div>
  131. <!-- 底部信息 -->
  132. <div class="detail-info">
  133. <div class="author-info">
  134. <div class="author-avatar">
  135. <img
  136. v-if="currentDetail.author?.avatar || currentDetail.userAvatar"
  137. :src="currentDetail.author?.avatar || currentDetail.userAvatar"
  138. :alt="currentDetail.author?.name || currentDetail.userName"
  139. />
  140. <el-icon v-else :size="32">
  141. <Avatar />
  142. </el-icon>
  143. </div>
  144. <div class="author-details">
  145. <div class="author-name">@{{ currentDetail.author?.name || currentDetail.userName }}</div>
  146. <div class="publish-time">
  147. {{ currentDetail.createdTime }}
  148. </div>
  149. </div>
  150. </div>
  151. <div style="padding-bottom: 10px; color: #ffffff">
  152. {{ currentDetail.title }}
  153. </div>
  154. <div class="detail-description">
  155. <p
  156. v-if="isDescriptionExpanded || (currentDetail.context && currentDetail.context.length >= 20)"
  157. :class="{ 'text-ellipsis': !isDescriptionExpanded }"
  158. >
  159. {{ currentDetail.context }}
  160. </p>
  161. <span v-if="currentDetail.context" class="expand-btn" @click="toggleDescription">
  162. {{ isDescriptionExpanded ? "收起" : "展开" }}
  163. </span>
  164. </div>
  165. </div>
  166. </div>
  167. <!-- 右侧操作栏 -->
  168. <div class="action-bar">
  169. <!-- 作者头像 -->
  170. <div class="action-item author-action">
  171. <div class="action-avatar" @click="handleViewUserProfile">
  172. <img
  173. v-if="currentDetail.author?.avatar || currentDetail.userAvatar"
  174. :src="currentDetail.author?.avatar || currentDetail.userAvatar"
  175. :alt="currentDetail.author?.name || currentDetail.userName"
  176. />
  177. <el-icon v-else :size="40" color="#fff">
  178. <Avatar />
  179. </el-icon>
  180. <!-- 关注按钮 (定位在头像右下角) -->
  181. <div v-if="currentDetail.isFollowThis == 0 && !isMyDynamic" class="follow-badge" @click.stop="handleFollowInDetail">
  182. <el-icon :size="16" color="#fff">
  183. <Plus />
  184. </el-icon>
  185. </div>
  186. </div>
  187. </div>
  188. <!-- 点赞 -->
  189. <div class="action-item" @click="handleDetailLike">
  190. <div class="action-icon">
  191. <i
  192. class="iconfont icon-dianzanb"
  193. :style="{ fontSize: '28px', color: currentDetail.isLike == '1' ? '#f56c6c' : '#fff' }"
  194. />
  195. </div>
  196. <div class="action-count">
  197. {{ currentDetail.dianzanCount }}
  198. </div>
  199. </div>
  200. <!-- 评论 -->
  201. <div class="action-item" @click="handleShowComments">
  202. <div class="action-icon">
  203. <el-icon :size="28" color="#fff">
  204. <ChatDotRound />
  205. </el-icon>
  206. </div>
  207. <div class="action-count">
  208. {{ currentDetail.commentCount }}
  209. </div>
  210. </div>
  211. <!-- 分享 -->
  212. <div class="action-item" @click="handleShare">
  213. <div class="action-icon">
  214. <el-icon :size="28" color="#fff">
  215. <Share />
  216. </el-icon>
  217. </div>
  218. <div class="action-count">分享</div>
  219. </div>
  220. <!-- 更多 -->
  221. <el-popover placement="left" :width="120" trigger="click" popper-class="more-actions-popover">
  222. <template #reference>
  223. <div class="action-item">
  224. <div class="action-icon">
  225. <el-icon :size="28" color="#fff">
  226. <MoreFilled />
  227. </el-icon>
  228. </div>
  229. </div>
  230. </template>
  231. <div class="more-actions-menu">
  232. <!-- 如果是当前用户的动态,显示编辑和删除 -->
  233. <template v-if="isMyDynamic">
  234. <div class="menu-item" style="display: flex; align-items: center; cursor: pointer" @click="handleDeleteDynamic">
  235. <el-icon :size="18">
  236. <Delete /> </el-icon
  237. >&nbsp;&nbsp;
  238. <span>删除</span>
  239. </div>
  240. </template>
  241. <!-- 如果不是当前用户的动态,显示举报和拉黑 -->
  242. <template v-else>
  243. <div
  244. class="menu-item"
  245. style="display: flex; align-items: center; padding-bottom: 10px; cursor: pointer"
  246. @click="handleReportDynamic"
  247. >
  248. <el-icon :size="18">
  249. <Warning /> </el-icon
  250. >&nbsp;&nbsp;
  251. <span>举报</span>
  252. </div>
  253. <div class="menu-item" style="display: flex; align-items: center; cursor: pointer" @click="handleBlockUserClick">
  254. <el-icon :size="18">
  255. <CircleClose /> </el-icon
  256. >&nbsp;&nbsp;
  257. <span>拉黑</span>
  258. </div>
  259. </template>
  260. </div>
  261. </el-popover>
  262. </div>
  263. </div>
  264. </el-drawer>
  265. <!-- 评论侧边栏 -->
  266. <el-drawer v-model="commentDrawerVisible" title="评论" direction="rtl" size="400px" destroy-on-close>
  267. <!-- 评论列表 -->
  268. <div class="comment-list-container">
  269. <div v-if="commentListData.length > 0" class="comment-list">
  270. <div v-for="comment in commentListData" :key="comment.id" class="comment-item">
  271. <div class="comment-avatar">
  272. <img v-if="comment.userImage" :src="comment.userImage" :alt="comment.userName" />
  273. <el-icon v-else :size="32">
  274. <Avatar />
  275. </el-icon>
  276. </div>
  277. <div class="comment-content-wrapper">
  278. <div class="comment-header">
  279. <span class="comment-user-name">{{ comment.userName }}</span>
  280. </div>
  281. <div class="comment-text">
  282. {{ comment.commentContent }}
  283. </div>
  284. <div class="comment-actions">
  285. <span class="comment-action-item" @click="handleLikeComment(comment)">
  286. <i class="iconfont icon-dianzanb" :style="{ fontSize: '16px', color: comment.isLiked ? '#f56c6c' : '#999' }" />
  287. <span>{{ comment.likeCount || 0 }}</span>
  288. </span>
  289. <span class="comment-action-item" @click="handleReplyComment(comment)">
  290. <el-icon :size="16">
  291. <ChatDotRound />
  292. </el-icon>
  293. <span>回复</span>
  294. </span>
  295. </div>
  296. <!-- 商家回复 -->
  297. <div v-for="item in comment.storeComment" :key="item.id" class="store-comment-wrapper">
  298. <div class="store-comment-item">
  299. <div class="store-comment-avatar">
  300. <img v-if="item.userImage" :src="item.userImage" :alt="item.userName" />
  301. <el-icon v-else :size="24">
  302. <Avatar />
  303. </el-icon>
  304. </div>
  305. <div class="store-comment-content">
  306. <div class="store-comment-header">
  307. <span class="store-comment-user-name">{{ item.userName || "商家" }}</span>
  308. <span class="store-comment-time">{{ item.createdTime || item.createDate }}</span>
  309. </div>
  310. <div class="store-comment-text">
  311. {{ item.commentContent }}
  312. <span
  313. class="comment-action-item"
  314. @click="handleLikeComment(item)"
  315. style="display: flex; align-items: center"
  316. >
  317. <i
  318. class="iconfont icon-dianzanb"
  319. :style="{ fontSize: '16px', color: item.isLiked ? '#f56c6c' : '#999' }"
  320. />&nbsp;
  321. <span>{{ item.likeCount || 0 }}</span>
  322. </span>
  323. </div>
  324. </div>
  325. </div>
  326. </div>
  327. </div>
  328. </div>
  329. </div>
  330. <el-empty v-else description="暂无评论" />
  331. </div>
  332. <!-- 评论输入框 -->
  333. <div class="comment-input-wrapper">
  334. <!-- 回复提示 -->
  335. <div v-if="replyingComment" class="reply-hint">
  336. <span class="reply-text">回复 @{{ replyingComment.userName }}</span>
  337. <el-icon class="cancel-reply" @click="handleCancelReply">
  338. <Close />
  339. </el-icon>
  340. </div>
  341. <el-input
  342. v-model="commentInput"
  343. type="textarea"
  344. :rows="3"
  345. :placeholder="replyingComment ? '输入回复内容...' : '你要评论点什么呢~'"
  346. maxlength="500"
  347. show-word-limit
  348. />
  349. <el-button type="primary" :loading="commentSubmitting" @click="handleSubmitComment">
  350. {{ replyingComment ? "回复" : "发送" }}
  351. </el-button>
  352. </div>
  353. </el-drawer>
  354. <!-- 举报对话框 -->
  355. <el-dialog v-model="reportDialogVisible" title="举报理由" width="500px" destroy-on-close @close="handleCloseReportDialog">
  356. <div class="report-dialog-content">
  357. <div class="report-tip">请选择最符合的原因,以便于我们进行的处理</div>
  358. <!-- 举报原因选项 -->
  359. <div class="report-reasons">
  360. <el-radio-group v-model="reportForm.reason">
  361. <el-radio label="用户违规"> 用户违规 </el-radio>
  362. <el-radio label="色情低俗"> 色情低俗 </el-radio>
  363. <el-radio label="违法违规"> 违法违规 </el-radio>
  364. <el-radio label="侮辱谩骂、煽动对立"> 侮辱谩骂、煽动对立 </el-radio>
  365. <el-radio label="涉嫌诈骗"> 涉嫌诈骗 </el-radio>
  366. <el-radio label="人身攻击"> 人身攻击 </el-radio>
  367. <el-radio label="种族歧视"> 种族歧视 </el-radio>
  368. <el-radio label="政治敏感"> 政治敏感 </el-radio>
  369. <el-radio label="虚假、不实内容"> 虚假、不实内容 </el-radio>
  370. <el-radio label="违反公德秩序"> 违反公德秩序 </el-radio>
  371. <el-radio label="危害人身安全"> 危害人身安全 </el-radio>
  372. <el-radio label="网络暴力"> 网络暴力 </el-radio>
  373. <el-radio label="其他原因"> 其他原因 </el-radio>
  374. </el-radio-group>
  375. </div>
  376. <!-- 详细描述(仅"其他原因"时显示) -->
  377. <div v-if="reportForm.reason === '其他原因'" class="report-description">
  378. <el-input
  379. v-model="reportForm.description"
  380. type="textarea"
  381. :rows="4"
  382. placeholder="请您在此处填写具体原因,我们会在第一时间为您处理!(必填)"
  383. maxlength="300"
  384. show-word-limit
  385. />
  386. </div>
  387. <!-- 上传凭证 -->
  388. <div class="report-upload">
  389. <div class="upload-title">上传凭证</div>
  390. <el-upload
  391. v-model:file-list="reportForm.fileList"
  392. list-type="picture-card"
  393. :limit="9"
  394. :on-preview="handleReportPreview"
  395. :on-remove="handleReportRemove"
  396. :before-upload="beforeReportUpload"
  397. :http-request="handleReportUpload"
  398. accept="image/*"
  399. multiple
  400. >
  401. <el-icon :size="24">
  402. <Plus />
  403. </el-icon>
  404. </el-upload>
  405. </div>
  406. <!-- 同意协议 -->
  407. <div class="report-agreement">
  408. <el-checkbox v-model="reportForm.agreed"> 同时拉黑该用户 </el-checkbox>
  409. </div>
  410. </div>
  411. <template #footer>
  412. <div class="dialog-footer">
  413. <el-button @click="reportDialogVisible = false"> 取消 </el-button>
  414. <el-button type="primary" :loading="reportSubmitting" @click="handleSubmitReport"> 提交 </el-button>
  415. </div>
  416. </template>
  417. </el-dialog>
  418. <!-- 分享对话框 -->
  419. <el-dialog v-model="shareDialogVisible" title="分享给好友" width="500px" destroy-on-close @close="handleCloseShareDialog">
  420. <div class="share-dialog-content">
  421. <!-- 好友列表 -->
  422. <div class="share-friend-list">
  423. <div v-if="filteredShareFriendList.length > 0">
  424. <div
  425. v-for="friend in filteredShareFriendList"
  426. :key="friend.id"
  427. class="share-friend-item"
  428. @click="handleSelectFriend(friend)"
  429. >
  430. <div class="friend-info">
  431. <div class="friend-avatar">
  432. <img v-if="friend.avatar" :src="friend.avatar" :alt="friend.name" />
  433. <el-icon v-else :size="40">
  434. <Avatar />
  435. </el-icon>
  436. </div>
  437. <div class="friend-name">
  438. {{ friend.name }}
  439. </div>
  440. </div>
  441. <el-icon v-if="selectedFriends.includes(friend.id)" :size="20" color="#409eff">
  442. <CircleCheck />
  443. </el-icon>
  444. </div>
  445. </div>
  446. <el-empty v-else description="暂无好友" />
  447. </div>
  448. <!-- 已选择的好友 -->
  449. <div v-if="selectedFriends.length > 0" class="selected-friends">
  450. <div class="selected-title">已选择 {{ selectedFriends.length }} 位好友</div>
  451. <div class="selected-list">
  452. <el-tag v-for="friendId in selectedFriends" :key="friendId" closable @close="handleRemoveFriend(friendId)">
  453. {{ shareFriendList.find(f => f.id === friendId)?.name }}
  454. </el-tag>
  455. </div>
  456. </div>
  457. </div>
  458. <template #footer>
  459. <div class="dialog-footer">
  460. <el-button @click="shareDialogVisible = false"> 取消 </el-button>
  461. <el-button
  462. type="primary"
  463. :loading="shareSubmitting"
  464. :disabled="selectedFriends.length === 0"
  465. @click="handleConfirmShare"
  466. >
  467. 确认分享
  468. </el-button>
  469. </div>
  470. </template>
  471. </el-dialog>
  472. <PcImagePreviewViewer
  473. v-model:visible="reportEvidencePreviewVisible"
  474. :url-list="reportEvidencePreviewUrls"
  475. :initial-index="reportEvidencePreviewIndex"
  476. />
  477. </div>
  478. </template>
  479. <script setup lang="ts" name="dynamicManagementIndex">
  480. import { ref, reactive, computed, onMounted, onActivated, watch } from "vue";
  481. import { useRouter, useRoute } from "vue-router";
  482. import { ElMessage, ElMessageBox } from "element-plus";
  483. import {
  484. Picture,
  485. Avatar,
  486. Close,
  487. ChatDotRound,
  488. Share,
  489. MoreFilled,
  490. Edit,
  491. Delete,
  492. Warning,
  493. CircleClose,
  494. Plus,
  495. Search,
  496. CircleCheck
  497. } from "@element-plus/icons-vue";
  498. import {
  499. toggleFollowUser,
  500. blockUser,
  501. uploadImg,
  502. saveComment,
  503. commentList,
  504. type CommentListParams,
  505. getMutualAttention,
  506. addTransferCount,
  507. deleteDynamicsById,
  508. getUserDynamics,
  509. likeDynamicNew,
  510. unlikeDynamicNew,
  511. getUserByPhone,
  512. reportUserViolation
  513. } from "@/api/modules/newLoginApi";
  514. // import { uploadImg } from "@/api/modules/upload";
  515. import { normalizeCommonCommentListResponse, countTopAndNestedComments } from "@/utils/commonCommentList";
  516. import { useUserStore } from "@/stores/modules/user";
  517. import { useWebSocketStore } from "@/stores/modules/websocket";
  518. import PcImagePreviewViewer from "@/components/pcMediaPreview/PcImagePreviewViewer.vue";
  519. const router = useRouter();
  520. const userStore = useUserStore();
  521. const socketStore = useWebSocketStore();
  522. // WebSocket 基础地址(与商家端一致,分享前连接)
  523. const WS_BASE = import.meta.env.VITE_WS_BASE || "ws://192.168.10.80:8000/alienStore/socket/";
  524. // 举报原因到违规类型的映射
  525. const violationTypeMap: Record<string, number> = {
  526. 用户违规: 1,
  527. 色情低俗: 2,
  528. 违法违规: 3,
  529. "侮辱谩骂、煽动对立": 4,
  530. 涉嫌诈骗: 5,
  531. 人身攻击: 6,
  532. 种族歧视: 7,
  533. 政治敏感: 8,
  534. "虚假、不实内容": 9,
  535. 违反公德秩序: 10,
  536. 危害人身安全: 11,
  537. 网络暴力: 12,
  538. 其他原因: 13
  539. };
  540. // 接口定义
  541. // 媒体项类型
  542. interface MediaItem {
  543. url: string;
  544. type: "image" | "video";
  545. }
  546. interface DynamicItem {
  547. isLike: any;
  548. dianzanCount: any;
  549. createdTime: any;
  550. context: string;
  551. id: number;
  552. title: string;
  553. content: string;
  554. imageUrl: string;
  555. userName: string;
  556. userAvatar: string;
  557. likeCount: number;
  558. isLiked: boolean;
  559. createTime: string;
  560. userId?: string | number; // 发布者ID
  561. phoneId?: string; // 发布者店铺ID
  562. storeUserId?: string | number; // 小店用户ID(用于举报)
  563. userType?: number; // 发布者用户类型:1商家,2用户
  564. phone?: string; // 发布者手机号
  565. isFollowed?: number; // 是否已关注:0未关注,1已关注
  566. isFollowThis?: number; // 是否已关注:0未关注,1已关注(用于判断关注按钮显示)
  567. isVideo?: boolean; // 是否为视频
  568. mediaType?: string; // 媒体类型:image 或 video
  569. mediaList?: MediaItem[]; // 媒体列表(支持多张图片和视频)
  570. }
  571. interface DetailItem extends DynamicItem {
  572. author?: {
  573. id: number;
  574. name: string;
  575. avatar: string;
  576. };
  577. context: string;
  578. commentCount: number;
  579. isFollowThis?: number; // 是否已关注:0未关注,1已关注(用于判断关注按钮显示)
  580. }
  581. // 响应式数据
  582. const activeTab = ref("recommend");
  583. const dynamicList = ref<DynamicItem[]>([]);
  584. const isfollowed = ref(0); // 0: 推荐, 1: 关注
  585. // 详情 Drawer 相关
  586. const detailDrawerVisible = ref(false);
  587. const currentDetail = ref<DetailItem | null>(null);
  588. // 描述展开/收起状态
  589. const isDescriptionExpanded = ref(false);
  590. // 轮播相关
  591. const currentCarouselIndex = ref(0);
  592. const videoRefs = ref<Map<number, HTMLVideoElement>>(new Map());
  593. // 设置视频引用
  594. const setVideoRef = (el: any, index: number) => {
  595. if (el) {
  596. videoRefs.value.set(index, el as HTMLVideoElement);
  597. }
  598. };
  599. // 轮播切换时暂停所有视频
  600. const handleCarouselChange = (newIndex: number) => {
  601. // 暂停所有视频
  602. videoRefs.value.forEach(video => {
  603. if (video && !video.paused) {
  604. video.pause();
  605. }
  606. });
  607. currentCarouselIndex.value = newIndex;
  608. };
  609. // 视频播放时暂停其他视频
  610. const handleVideoPlay = (currentIndex: number) => {
  611. videoRefs.value.forEach((video, index) => {
  612. if (index !== currentIndex && video && !video.paused) {
  613. video.pause();
  614. }
  615. });
  616. };
  617. // 举报对话框相关
  618. const reportDialogVisible = ref(false);
  619. const reportSubmitting = ref(false);
  620. const reportForm = reactive({
  621. reason: "用户违规", // 默认选择第一个选项
  622. description: "",
  623. fileList: [] as any[],
  624. agreed: false
  625. });
  626. const reportEvidencePreviewVisible = ref(false);
  627. const reportEvidencePreviewUrls = ref<string[]>([]);
  628. const reportEvidencePreviewIndex = ref(0);
  629. // 分享对话框相关
  630. interface ShareFriend {
  631. id: number;
  632. name: string;
  633. avatar: string;
  634. phoneId?: string;
  635. }
  636. const shareDialogVisible = ref(false);
  637. const shareSubmitting = ref(false);
  638. const shareSearch = ref("");
  639. const shareFriendList = ref<ShareFriend[]>([]);
  640. const selectedFriends = ref<number[]>([]);
  641. // 过滤后的好友列表
  642. const filteredShareFriendList = computed(() => {
  643. if (!shareSearch.value) {
  644. return shareFriendList.value;
  645. }
  646. const keyword = shareSearch.value.toLowerCase();
  647. return shareFriendList.value.filter(friend => friend.name.toLowerCase().includes(keyword));
  648. });
  649. // 分页
  650. const pagination = reactive({
  651. page: 1,
  652. pageSize: 10,
  653. total: 0
  654. });
  655. // 直接使用动态列表(后端已完成分页)
  656. const paginatedList = computed(() => {
  657. return dynamicList.value;
  658. });
  659. // 判断当前详情是否是当前用户的动态
  660. const isMyDynamic = computed(() => {
  661. const currentUserStoreId = userStore.userInfo?.storeId;
  662. const dynamicStoreUserId = currentDetail.value?.storeUserId; // ✅ 添加可选链操作符
  663. // 通过 storeId 和 storeUserId 判断是否是当前用户的动态
  664. const result = currentUserStoreId == dynamicStoreUserId;
  665. console.log("是否是自己发布的作品:", result);
  666. return result;
  667. });
  668. // 标签切换
  669. const handleTabClick = (tab: any) => {
  670. // 根据切换的 tab 更新 isfollowed 的值
  671. // 使用传入的 tab.props.name 获取当前点击的 tab,而不是 activeTab.value
  672. const tabName = tab?.props?.name || tab?.paneName || activeTab.value;
  673. if (tabName === "recommend") {
  674. isfollowed.value = 0; // 推荐
  675. } else if (tabName === "follow") {
  676. isfollowed.value = 1; // 关注
  677. }
  678. pagination.page = 1;
  679. loadDynamicList();
  680. };
  681. // 发布动态
  682. const handlePublish = () => {
  683. // 校验是否已入驻店铺
  684. if (!userStore.userInfo?.storeId) {
  685. ElMessage.warning("请先入驻店铺");
  686. return;
  687. }
  688. router.push("/dynamicManagement/publishDynamic");
  689. };
  690. // 分页大小改变
  691. const handleSizeChange = (val: number) => {
  692. pagination.pageSize = val;
  693. pagination.page = 1;
  694. loadDynamicList();
  695. };
  696. // 当前页改变
  697. const handleCurrentChange = (val: number) => {
  698. pagination.page = val;
  699. loadDynamicList();
  700. };
  701. // 根据 phoneId 判断用户类型
  702. const getUserTypeFromPhoneId = (phoneId: string | undefined): number => {
  703. if (!phoneId) return 1; // 默认商家
  704. const prefix = phoneId.split("_")[0]; // 截取 "_" 之前的文字
  705. return prefix === "store" ? 1 : 2; // store = 商家(1), 其他 = 用户(2)
  706. };
  707. // 获取黑名单列表(从 localStorage)
  708. const getBlockedUserList = (): string[] => {
  709. try {
  710. const blockedList = localStorage.getItem("blockedUserList");
  711. return blockedList ? JSON.parse(blockedList) : [];
  712. } catch (error) {
  713. console.error("获取黑名单失败:", error);
  714. return [];
  715. }
  716. };
  717. // 添加到黑名单(保存到 localStorage)
  718. const addToBlockedList = (phoneId: string) => {
  719. try {
  720. const blockedList = getBlockedUserList();
  721. if (!blockedList.includes(phoneId)) {
  722. blockedList.push(phoneId);
  723. localStorage.setItem("blockedUserList", JSON.stringify(blockedList));
  724. console.log("已添加到黑名单:", phoneId, "当前黑名单:", blockedList);
  725. }
  726. } catch (error) {
  727. console.error("添加黑名单失败:", error);
  728. }
  729. };
  730. // 加载动态列表
  731. const loadDynamicList = async () => {
  732. try {
  733. // 获取店铺ID(从 userStore 中获取,如果没有则使用默认值)
  734. const phoneId = userStore.userInfo?.phoneId;
  735. const res = await getUserDynamics({
  736. type: 2, // 固定值,表示动态类型
  737. isfollowed: isfollowed.value, // 0 推荐, 1 关注(使用全局变量)
  738. myself: 0, // 0 表示他人的动态
  739. page: pagination.page,
  740. size: pagination.pageSize,
  741. phoneId: `store_${userStore.userInfo?.phone}`
  742. });
  743. // 处理返回的数据
  744. if (res.data) {
  745. // 根据实际返回的数据结构进行映射
  746. const responseData = res.data as any;
  747. let list = responseData.records;
  748. // 获取黑名单并过滤
  749. const blockedList = getBlockedUserList();
  750. if (blockedList.length > 0) {
  751. const originalLength = list.length;
  752. list = list.filter((item: any) => {
  753. const itemPhoneId = item.phoneId || item.storeId || "";
  754. return !blockedList.includes(itemPhoneId);
  755. });
  756. const filteredCount = originalLength - list.length;
  757. if (filteredCount > 0) {
  758. console.log(`已过滤 ${filteredCount} 条被拉黑用户的动态`);
  759. }
  760. }
  761. dynamicList.value = list.map((item: any) => {
  762. const phoneId = item.phoneId || item.storeId;
  763. const userType = getUserTypeFromPhoneId(phoneId); // 根据 phoneId 判断用户类型
  764. // 从 phoneId 中提取手机号("_" 之后的部分)
  765. let phone = item.phone || item.userPhone || item.mobile || "";
  766. if (!phone && phoneId && phoneId.includes("_")) {
  767. phone = phoneId.split("_")[1]; // 截取 "_" 之后的文字作为手机号
  768. }
  769. // 输出关注状态(仅第一条)
  770. if (item.id === list[0].id) {
  771. console.log("接口返回的isFollowThis:", item.isFollowThis, "(0=未关注, 1=已关注)");
  772. }
  773. // 解析媒体列表(支持多张图片和视频)
  774. const mediaUrl = item.imagePath || "";
  775. const mediaUrls = mediaUrl
  776. .split(",")
  777. .map((url: string) => url.trim())
  778. .filter((url: string) => url);
  779. const mediaList: MediaItem[] = mediaUrls.map((url: string) => ({
  780. url,
  781. type: url.toLowerCase().endsWith(".mp4") ? ("video" as const) : ("image" as const)
  782. }));
  783. const firstUrl = mediaUrls[0] || "";
  784. const isVideo = firstUrl.toLowerCase().endsWith(".mp4");
  785. const mediaType = isVideo ? "video" : "image";
  786. // 获取用户头像(优先使用 userImage 字段)
  787. const userAvatar = item.userImage || item.userAvatar || item.avatar || item.headImg || "";
  788. return {
  789. // 保留接口返回的所有原始字段
  790. ...item,
  791. // 额外添加的处理字段
  792. id: item.id || item.dynamicId,
  793. title: item.title || item.content || item.dynamicContent || "这家店超好吃....",
  794. content: item.content || item.dynamicContent || "",
  795. imageUrl: firstUrl, // 使用第一个URL(兼容旧逻辑)
  796. mediaList, // 完整媒体列表
  797. userName: item.userName || item.nickname || item.storeName || "用户",
  798. userAvatar: userAvatar,
  799. likeCount: item.likeCount || item.praiseCount || 0,
  800. isLiked: item.isLiked || item.isPraise || false,
  801. createTime: item.createTime || item.createDate || new Date().toISOString(),
  802. userId: item.userId || item.createUserId,
  803. phoneId: phoneId,
  804. storeUserId: item.storeUserId || item.userId || item.createUserId, // 小店用户ID
  805. userType: userType, // 用户类型:1商家,2用户
  806. phone: phone, // 手机号(从 phoneId 或其他字段获取)
  807. isFollowed: item.isFollowThis, // 使用isFollowThis字段:0未关注(显示按钮),1已关注(隐藏按钮)
  808. isFollowThis: item.isFollowThis, // 是否已关注:0未关注,1已关注(用于判断关注按钮显示)
  809. isVideo: isVideo, // 是否为视频
  810. mediaType: mediaType // 媒体类型
  811. };
  812. });
  813. pagination.total = responseData.total || responseData.totalCount || list.length;
  814. }
  815. } catch (error) {
  816. console.error("加载动态列表失败:", error);
  817. ElMessage.error("加载动态列表失败");
  818. // 失败时清空列表
  819. dynamicList.value = [];
  820. pagination.total = 0;
  821. }
  822. };
  823. // 点击卡片 - 查看详情(直接使用列表数据)
  824. const handleCardClick = async (item: DynamicItem) => {
  825. console.log("点击动态:", item);
  826. console.log("isFollowThis值:", item.isFollowThis, "(0=未关注显示按钮, 1=已关注隐藏按钮)");
  827. console.log("isMyDynamic:", isMyDynamic.value);
  828. // 重置描述展开状态
  829. isDescriptionExpanded.value = false;
  830. // 直接使用列表数据构建详情
  831. currentDetail.value = {
  832. ...item,
  833. author: {
  834. id: 0,
  835. name: item.userName,
  836. avatar: item.userAvatar
  837. },
  838. context: item.context,
  839. createdTime: item.createdTime,
  840. dianzanCount: item.dianzanCount,
  841. isLike: item.isLike,
  842. commentCount: 0,
  843. isFollowThis: item.isFollowThis // 使用item.isFollowThis而不是item.isFollowed
  844. };
  845. detailDrawerVisible.value = true;
  846. // 打开抽屉时加载评论列表
  847. await loadCommentList();
  848. };
  849. // 列表点赞/取消点赞
  850. const handleLike = async (item: DynamicItem) => {
  851. try {
  852. // 获取当前用户的手机号,并在前面拼接 "store_"
  853. const phone = userStore.userInfo?.phone || "";
  854. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  855. const params = {
  856. userId: currentUserPhoneId, // 当前用户phoneId
  857. huifuId: item.id, // 动态ID
  858. type: 2 // 2表示点赞
  859. };
  860. // 根据当前点赞状态调用不同的接口
  861. if (item.isLike == "1") {
  862. // 已点赞,调用取消点赞接口
  863. await unlikeDynamicNew(params);
  864. } else {
  865. // 未点赞,调用点赞接口
  866. await likeDynamicNew(params);
  867. }
  868. await loadDynamicList();
  869. // ElMessage.success(item.isLike != "1" ? "点赞成功" : "取消点赞");
  870. } catch (error) {
  871. console.error("列表点赞操作失败:", error);
  872. ElMessage.error("操作失败");
  873. }
  874. };
  875. // 关闭详情
  876. const handleCloseDetail = () => {
  877. detailDrawerVisible.value = false;
  878. // 暂停所有视频
  879. videoRefs.value.forEach(video => {
  880. if (video && !video.paused) {
  881. video.pause();
  882. }
  883. });
  884. setTimeout(() => {
  885. currentDetail.value = null;
  886. currentCarouselIndex.value = 0;
  887. videoRefs.value.clear();
  888. }, 300);
  889. };
  890. // 详情页点赞(表单方式提交)
  891. const handleDetailLike = async () => {
  892. if (!currentDetail.value) return;
  893. try {
  894. // 获取当前用户的手机号,并在前面拼接 "store_"
  895. const phone = userStore.userInfo?.phone || "";
  896. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  897. const params = {
  898. userId: currentUserPhoneId, // 当前用户phoneId
  899. huifuId: currentDetail.value.id, // 动态ID
  900. type: 2 // 2表示点赞
  901. };
  902. // 根据当前点赞状态调用不同的接口
  903. if (currentDetail.value.isLike == "1") {
  904. // 已点赞,调用取消点赞接口
  905. await unlikeDynamicNew(params);
  906. } else {
  907. // 未点赞,调用点赞接口
  908. await likeDynamicNew(params);
  909. }
  910. // 重新加载动态列表以获取最新数据
  911. await loadDynamicList();
  912. // 更新当前详情的点赞状态(从重新加载的列表中获取)
  913. const updatedItem = dynamicList.value.find(item => item.id === currentDetail.value?.id);
  914. if (updatedItem && currentDetail.value) {
  915. currentDetail.value.isLike = updatedItem.isLike;
  916. currentDetail.value.dianzanCount = updatedItem.dianzanCount;
  917. }
  918. } catch (error) {
  919. console.error("点赞操作失败:", error);
  920. ElMessage.error("操作失败");
  921. }
  922. };
  923. // 切换描述展开/收起
  924. const toggleDescription = () => {
  925. isDescriptionExpanded.value = !isDescriptionExpanded.value;
  926. };
  927. // 显示评论
  928. // 评论相关
  929. const commentDrawerVisible = ref(false);
  930. const commentListData = ref<any[]>([]);
  931. const commentInput = ref("");
  932. const commentSubmitting = ref(false);
  933. const currentCommentDynamicId = ref<number | string>("");
  934. const replyingComment = ref<any>(null); // 当前正在回复的评论
  935. const handleShowComments = () => {
  936. if (!currentDetail.value) return;
  937. commentDrawerVisible.value = true;
  938. currentCommentDynamicId.value = currentDetail.value.id;
  939. // 清空评论输入框
  940. commentInput.value = "";
  941. // 清空回复评论
  942. replyingComment.value = null;
  943. };
  944. // 加载评论列表
  945. const loadCommentList = async () => {
  946. if (!currentDetail.value) return;
  947. try {
  948. const params: CommentListParams = {
  949. pageNum: 1,
  950. pageSize: 100,
  951. sourceId: currentDetail.value.id,
  952. sourceType: 2
  953. };
  954. const uid = userStore.userInfo?.userId ?? userStore.userInfo?.id;
  955. if (uid !== undefined && uid !== null && uid !== "") {
  956. const n = Number(uid);
  957. if (Number.isFinite(n)) params.userId = Math.trunc(n);
  958. }
  959. const res: any = await commentList(params);
  960. if (res.code === 200) {
  961. const list = normalizeCommonCommentListResponse(res.data);
  962. commentListData.value = list;
  963. if (currentDetail.value) {
  964. const raw = res.data;
  965. const pageTotal =
  966. raw && typeof raw === "object" && !Array.isArray(raw) && typeof (raw as { total?: number }).total === "number"
  967. ? (raw as { total: number }).total
  968. : undefined;
  969. currentDetail.value.commentCount =
  970. pageTotal !== undefined && pageTotal >= 0 ? pageTotal : countTopAndNestedComments(list);
  971. }
  972. console.log("评论列表:", commentListData.value);
  973. }
  974. } catch (error) {
  975. console.error("加载评论列表失败:", error);
  976. }
  977. };
  978. // 提交评论
  979. const handleSubmitComment = async () => {
  980. if (!commentInput.value.trim()) {
  981. ElMessage.warning("请输入评论内容");
  982. return;
  983. }
  984. if (!currentDetail.value) {
  985. ElMessage.error("动态信息不存在");
  986. return;
  987. }
  988. try {
  989. commentSubmitting.value = true;
  990. // 判断是回复评论还是评论动态
  991. const isReply = !!replyingComment.value;
  992. const params: any = {
  993. replyId: isReply ? replyingComment.value.id : "", // 回复评论时传评论ID,否则为空
  994. commentContent: commentInput.value,
  995. businessType: "2",
  996. businessId: String(currentDetail.value.id),
  997. storeId: userStore.userInfo?.storeId || userStore.userInfo?.createdId,
  998. commentStar: "",
  999. phoneId: `store_${userStore.userInfo?.phone}`
  1000. };
  1001. const res: any = await saveComment(params);
  1002. if (res.code === 200) {
  1003. ElMessage.success(isReply ? "回复成功" : "评论成功");
  1004. commentInput.value = "";
  1005. replyingComment.value = null; // 清空回复状态
  1006. await loadCommentList();
  1007. } else {
  1008. ElMessage.error(res.message || (isReply ? "回复失败" : "评论失败"));
  1009. }
  1010. } catch (error) {
  1011. console.error("提交评论失败:", error);
  1012. ElMessage.error(replyingComment.value ? "回复失败" : "评论失败");
  1013. } finally {
  1014. commentSubmitting.value = false;
  1015. }
  1016. };
  1017. // 点赞评论
  1018. const handleLikeComment = async (comment: any) => {
  1019. console.log(comment);
  1020. try {
  1021. // 获取当前用户的手机号,并在前面拼接 "store_"
  1022. const phone = userStore.userInfo?.phone || "";
  1023. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1024. const params = {
  1025. userId: currentUserPhoneId, // 当前用户phoneId
  1026. huifuId: comment.id, // 动态ID
  1027. type: 1 // 2表示点赞
  1028. };
  1029. // 根据当前点赞状态调用不同的接口
  1030. if (comment.isLiked) {
  1031. // 已点赞,调用取消点赞接口
  1032. await unlikeDynamicNew(params);
  1033. } else {
  1034. // 未点赞,调用点赞接口
  1035. await likeDynamicNew(params);
  1036. }
  1037. // 切换点赞状态
  1038. comment.isLiked = !comment.isLiked;
  1039. comment.likeCount += comment.isLiked ? 1 : -1;
  1040. } catch (error) {
  1041. console.error("列表点赞操作失败:", error);
  1042. ElMessage.error("操作失败");
  1043. }
  1044. };
  1045. // 回复评论
  1046. const handleReplyComment = (comment: any) => {
  1047. replyingComment.value = comment;
  1048. commentInput.value = ``;
  1049. // 聚焦到输入框
  1050. setTimeout(() => {
  1051. const textarea = document.querySelector(".comment-input-wrapper textarea") as HTMLTextAreaElement;
  1052. if (textarea) {
  1053. textarea.focus();
  1054. }
  1055. }, 100);
  1056. };
  1057. // 取消回复
  1058. const handleCancelReply = () => {
  1059. replyingComment.value = null;
  1060. commentInput.value = "";
  1061. };
  1062. // 分享(参考商家端 newDetail:分享前先连接 WebSocket)
  1063. const handleShare = async () => {
  1064. const phone = userStore.userInfo?.phone || "";
  1065. const senderId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1066. const wsUrl = `${WS_BASE.replace(/\/$/, "")}/${senderId}`;
  1067. try {
  1068. if (!socketStore.isConnected || socketStore.lastConnectedUrl !== wsUrl) {
  1069. const connected = await socketStore.connect(wsUrl);
  1070. if (!connected) {
  1071. ElMessage.warning("连接失败,请稍后重试");
  1072. return;
  1073. }
  1074. }
  1075. } catch (e) {
  1076. console.error("WebSocket 连接失败:", e);
  1077. ElMessage.warning("连接失败,请稍后重试");
  1078. return;
  1079. }
  1080. shareDialogVisible.value = true;
  1081. await loadShareFriendList();
  1082. };
  1083. // 加载好友列表
  1084. const loadShareFriendList = async () => {
  1085. try {
  1086. // 获取当前用户的手机号,并在前面拼接 "store_"
  1087. const phone = userStore.userInfo?.phone || "";
  1088. const fansId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1089. const res: any = await getMutualAttention({
  1090. page: 1,
  1091. size: 1000,
  1092. fansId: fansId,
  1093. name: ""
  1094. });
  1095. if (res.code === 200) {
  1096. const dataList = res.data?.records || res.data?.list || res.data || [];
  1097. shareFriendList.value = dataList.map((item: any) => ({
  1098. id: item.id || item.userId,
  1099. name: item.userName || item.nickname || item.name || "用户",
  1100. avatar: item.userImage || item.avatar || item.headImg || "",
  1101. phoneId: item.phoneId || item.fansId || ""
  1102. }));
  1103. console.log("加载好友列表成功:", shareFriendList.value);
  1104. }
  1105. } catch (error) {
  1106. console.error("加载好友列表失败:", error);
  1107. ElMessage.error("加载好友列表失败");
  1108. shareFriendList.value = [];
  1109. }
  1110. };
  1111. // 搜索好友
  1112. const handleShareSearch = () => {
  1113. // 搜索由计算属性自动处理
  1114. };
  1115. // 选择好友
  1116. const handleSelectFriend = (friend: ShareFriend) => {
  1117. const index = selectedFriends.value.indexOf(friend.id);
  1118. if (index > -1) {
  1119. // 已选择,取消选择
  1120. selectedFriends.value.splice(index, 1);
  1121. } else {
  1122. // 未选择,添加选择
  1123. selectedFriends.value.push(friend.id);
  1124. }
  1125. };
  1126. // 移除已选择的好友
  1127. const handleRemoveFriend = (friendId: number) => {
  1128. const index = selectedFriends.value.indexOf(friendId);
  1129. if (index > -1) {
  1130. selectedFriends.value.splice(index, 1);
  1131. }
  1132. };
  1133. // 确认分享(参考商家端 newDetail:通过 WebSocket sendMessage 发送给每位好友,再调 addTransferCount)
  1134. const handleConfirmShare = async () => {
  1135. if (selectedFriends.value.length === 0) {
  1136. ElMessage.warning("请选择要分享的好友");
  1137. return;
  1138. }
  1139. if (!currentDetail.value) {
  1140. ElMessage.error("动态信息不存在");
  1141. return;
  1142. }
  1143. const phone = userStore.userInfo?.phone || "";
  1144. const senderId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1145. const detailPayload = {
  1146. ...currentDetail.value,
  1147. imageList: currentDetail.value.imagePath.split(","),
  1148. cover: currentDetail.value.imagePath.split(",")[0]
  1149. };
  1150. try {
  1151. shareSubmitting.value = true;
  1152. // 先通过 WebSocket 给每位选中好友发送动态分享消息(与商家端 sendMessage 格式一致)
  1153. for (const friendId of selectedFriends.value) {
  1154. const friend = shareFriendList.value.find(f => f.id === friendId);
  1155. const receiverId = friend?.phoneId || friend?.id;
  1156. if (!receiverId) continue;
  1157. await socketStore.sendMessage({
  1158. category: "message",
  1159. receiverId,
  1160. senderId,
  1161. type: 3,
  1162. text: {
  1163. sendType: "dynamicShare",
  1164. url: JSON.stringify(detailPayload)
  1165. }
  1166. });
  1167. }
  1168. // 再调用 addTransferCount 接口,传递动态 id(与商家端一致)
  1169. const res: any = await addTransferCount({
  1170. id: currentDetail.value.id
  1171. });
  1172. if (res.code === 200) {
  1173. ElMessage.success(`已分享给 ${selectedFriends.value.length} 位好友`);
  1174. shareDialogVisible.value = false;
  1175. // 更新当前详情的分享数
  1176. if (typeof (currentDetail.value as any).transferCount === "number") {
  1177. (currentDetail.value as any).transferCount += selectedFriends.value.length;
  1178. }
  1179. } else {
  1180. ElMessage.error(res.message || "分享失败");
  1181. }
  1182. } catch (error) {
  1183. console.error("分享失败:", error);
  1184. ElMessage.error("分享失败");
  1185. } finally {
  1186. shareSubmitting.value = false;
  1187. }
  1188. };
  1189. // 关闭分享对话框
  1190. const handleCloseShareDialog = () => {
  1191. shareSearch.value = "";
  1192. selectedFriends.value = [];
  1193. shareFriendList.value = [];
  1194. };
  1195. // 查看用户主页
  1196. const handleViewUserProfile = () => {
  1197. if (!currentDetail.value) return;
  1198. // 跳转到他人动态主页,传递用户信息
  1199. router.push({
  1200. path: "/dynamicManagement/userDynamic",
  1201. query: {
  1202. userId: currentDetail.value.storeOrUserId || "",
  1203. phoneId: currentDetail.value.phoneId || "",
  1204. userName: currentDetail.value.userName || "",
  1205. userAvatar: currentDetail.value.userAvatar || "",
  1206. phone: currentDetail.value.phone || ""
  1207. }
  1208. });
  1209. };
  1210. // 详情页关注(右侧操作栏)
  1211. const handleFollowInDetail = async () => {
  1212. if (!currentDetail.value) return;
  1213. try {
  1214. const phone = userStore.userInfo?.phone || "";
  1215. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1216. await toggleFollowUser({
  1217. followedId: currentDetail.value.phoneId || "",
  1218. fansId: currentUserPhoneId,
  1219. fansType: 2
  1220. });
  1221. // 更新关注状态
  1222. if (currentDetail.value) {
  1223. currentDetail.value.isFollowed = 1;
  1224. currentDetail.value.isFollowThis = 1; // 同时更新isFollowThis字段
  1225. }
  1226. // 同步更新列表中的状态
  1227. const listItem = dynamicList.value.find(item => item.id === currentDetail.value?.id);
  1228. if (listItem) {
  1229. listItem.isFollowed = 1;
  1230. listItem.isFollowThis = 1; // 同时更新列表项的isFollowThis状态
  1231. }
  1232. ElMessage.success("关注成功");
  1233. } catch (error) {
  1234. console.error("关注操作失败:", error);
  1235. ElMessage.error("操作失败");
  1236. }
  1237. };
  1238. // 编辑动态
  1239. const handleEditDynamic = () => {
  1240. if (!currentDetail.value) return;
  1241. detailDrawerVisible.value = false;
  1242. router.push({
  1243. path: "/dynamicManagement/publishDynamic",
  1244. query: { id: currentDetail.value.id }
  1245. });
  1246. };
  1247. // 删除动态
  1248. const handleDeleteDynamic = async () => {
  1249. if (!currentDetail.value) return;
  1250. try {
  1251. await ElMessageBox.confirm("确定要删除这条动态吗?删除后将无法恢复。", "删除确认", {
  1252. confirmButtonText: "确定删除",
  1253. cancelButtonText: "取消",
  1254. type: "warning",
  1255. confirmButtonClass: "el-button--danger"
  1256. }).then(async () => {
  1257. if (!currentDetail.value) return;
  1258. const res: any = await deleteDynamicsById({ id: currentDetail.value.id });
  1259. if (res.code === 200) {
  1260. ElMessage.success("删除成功");
  1261. detailDrawerVisible.value = false;
  1262. const index = dynamicList.value.findIndex(item => item.id === currentDetail.value?.id);
  1263. if (index > -1) {
  1264. dynamicList.value.splice(index, 1);
  1265. }
  1266. }
  1267. });
  1268. } catch {
  1269. // 用户取消删除
  1270. }
  1271. };
  1272. // 举报动态
  1273. const handleReportDynamic = () => {
  1274. reportDialogVisible.value = true;
  1275. };
  1276. // 举报图片预览
  1277. const handleReportPreview = (uploadFile: any) => {
  1278. const list = (reportForm.fileList || []).map((f: any) => String(f.url || "").trim()).filter(Boolean);
  1279. const url = String(uploadFile?.url || "").trim();
  1280. const urls = list.length ? list : url ? [url] : [];
  1281. if (!urls.length) return;
  1282. const idx = url ? urls.indexOf(url) : 0;
  1283. reportEvidencePreviewUrls.value = urls;
  1284. reportEvidencePreviewIndex.value = Math.max(0, idx);
  1285. reportEvidencePreviewVisible.value = true;
  1286. };
  1287. // 移除举报图片
  1288. const handleReportRemove = (uploadFile: any, uploadFiles: any[]) => {
  1289. // 已由 v-model:file-list 自动处理
  1290. };
  1291. // 举报图片上传前验证
  1292. const beforeReportUpload = (file: File) => {
  1293. const isImage = file.type.startsWith("image/");
  1294. const isLt20M = file.size / 1024 / 1024 < 20;
  1295. if (!isImage) {
  1296. ElMessage.error("只能上传图片文件!");
  1297. return false;
  1298. }
  1299. if (!isLt20M) {
  1300. ElMessage.error("图片大小不能超过 20MB!");
  1301. return false;
  1302. }
  1303. return true;
  1304. };
  1305. // 自定义举报图片上传
  1306. const handleReportUpload = async (options: any) => {
  1307. const { file, onSuccess, onError } = options;
  1308. try {
  1309. const uploadFormData = new FormData();
  1310. uploadFormData.append("file", file);
  1311. const response: any = await uploadImg(uploadFormData);
  1312. const url =
  1313. response?.data && (Array.isArray(response.data) && response.data.length > 0 ? response.data[0] : response.data.fileUrl);
  1314. if (response && response.code === 200 && url) {
  1315. onSuccess({
  1316. url
  1317. });
  1318. } else {
  1319. ElMessage.error(response?.msg || "图片上传失败");
  1320. onError(new Error(response?.msg || "图片上传失败"));
  1321. }
  1322. } catch (error) {
  1323. console.error("图片上传失败:", error);
  1324. ElMessage.error("图片上传失败");
  1325. onError(error);
  1326. }
  1327. };
  1328. // 提交举报
  1329. const handleSubmitReport = async () => {
  1330. // 验证表单
  1331. if (!reportForm.reason) {
  1332. ElMessage.warning("请选择举报原因");
  1333. return;
  1334. }
  1335. // 只有选择"其他原因"时才验证详细描述
  1336. if (reportForm.reason === "其他原因" && !reportForm.description.trim()) {
  1337. ElMessage.warning("请填写详细描述");
  1338. return;
  1339. }
  1340. if (!currentDetail.value) {
  1341. ElMessage.warning("动态信息异常");
  1342. return;
  1343. }
  1344. reportSubmitting.value = true;
  1345. try {
  1346. // 获取违规类型编号
  1347. const violationType = violationTypeMap[reportForm.reason];
  1348. // 获取举报凭证图片(如果有多张,用逗号分隔)
  1349. const reportEvidenceImg = reportForm.fileList
  1350. .map((f: any) => f.url || f.response?.url)
  1351. .filter(Boolean)
  1352. .join(",");
  1353. // 获取当前用户信息
  1354. const currentUserId = userStore.userInfo?.id || userStore.userInfo?.userId || "";
  1355. const currentUserType = userStore.userInfo?.userType || userStore.userInfo?.type || 1; // 用户类型:1商家,2用户,默认1
  1356. // 获取被举报用户类型(从 phoneId 解析)
  1357. const reportedUserType = currentDetail.value.userType || 1;
  1358. // 根据手机号获取被举报人ID
  1359. let reportedUserId = currentDetail.value.storeUserId || currentDetail.value.userId || "";
  1360. if (currentDetail.value.phone) {
  1361. try {
  1362. const userRes = await getUserByPhone({ phone: currentDetail.value.phone });
  1363. const userData = userRes.data as any;
  1364. if (userData && userData.id) {
  1365. reportedUserId = userData.id;
  1366. console.log("通过手机号获取到被举报人ID:", reportedUserId);
  1367. }
  1368. } catch (error) {
  1369. console.error("获取被举报人ID失败:", error);
  1370. // 如果获取失败,使用原有的 storeUserId
  1371. }
  1372. }
  1373. console.log("当前用户类型:", userStore.userInfo);
  1374. console.log("被举报用户类型:", reportedUserType);
  1375. console.log("被举报人ID:", reportedUserId);
  1376. console.log("动态详情:", currentDetail.value);
  1377. // 调用举报接口
  1378. await reportUserViolation({
  1379. dynamicsId: currentDetail.value.id, // 动态ID
  1380. reportContextType: "2", // 举报上下文类型:2表示动态
  1381. violationType: violationType, // 违规类型
  1382. otherReasonContent: reportForm.reason === "其他原因" ? reportForm.description : "", // 只有选择"其他原因"时才传详细描述
  1383. reportEvidenceImg: reportEvidenceImg, // 举报凭证图片
  1384. reportedUserId: reportedUserId, // 被举报用户ID(通过手机号获取)
  1385. reportedUserType: reportedUserType, // 被举报用户类型(从 phoneId 解析)
  1386. reportingUserId: currentUserId, // 举报人ID
  1387. reportingUserType: currentUserType // 举报人类型(当前登录用户类型)
  1388. });
  1389. // 如果同时拉黑该用户
  1390. if (reportForm.agreed) {
  1391. try {
  1392. // 调用拉黑接口(跳过确认对话框)
  1393. await handleBlockUser(true);
  1394. ElMessage.success("举报提交成功,已拉黑该用户");
  1395. } catch (blockError) {
  1396. console.error("拉黑失败:", blockError);
  1397. ElMessage.warning("举报提交成功,但拉黑失败");
  1398. }
  1399. } else {
  1400. ElMessage.success("举报提交成功,我们会尽快处理");
  1401. }
  1402. reportDialogVisible.value = false;
  1403. } catch (error) {
  1404. console.error("举报提交失败:", error);
  1405. ElMessage.error("举报提交失败");
  1406. } finally {
  1407. reportSubmitting.value = false;
  1408. }
  1409. };
  1410. // 关闭举报对话框
  1411. const handleCloseReportDialog = () => {
  1412. reportForm.reason = "用户违规"; // 重置为默认选项
  1413. reportForm.description = "";
  1414. reportForm.fileList = [];
  1415. reportForm.agreed = false;
  1416. };
  1417. // 监听举报原因变化,如果不是"其他原因"则清空详细描述
  1418. watch(
  1419. () => reportForm.reason,
  1420. newReason => {
  1421. if (newReason !== "其他原因") {
  1422. reportForm.description = "";
  1423. }
  1424. }
  1425. );
  1426. // 拉黑用户(点击菜单项)
  1427. const handleBlockUserClick = () => {
  1428. handleBlockUser(false);
  1429. };
  1430. // 拉黑用户
  1431. const handleBlockUser = async (skipConfirm: boolean = false) => {
  1432. if (!currentDetail.value) return;
  1433. try {
  1434. // 如果不跳过确认,显示确认对话框
  1435. if (!skipConfirm) {
  1436. await ElMessageBox.confirm("拉黑后将不再看到该用户的动态,确定要拉黑吗?", "拉黑确认", {
  1437. confirmButtonText: "确定拉黑",
  1438. cancelButtonText: "取消",
  1439. type: "warning"
  1440. });
  1441. }
  1442. // 获取当前用户信息
  1443. const currentUserId = userStore.userInfo?.id || userStore.userInfo?.userId || "";
  1444. const currentUserType = userStore.userInfo?.userType || userStore.userInfo?.type || 1; // 用户类型:1商家,2用户,默认1
  1445. // 获取被拉黑用户类型(从 phoneId 解析)
  1446. const blockedUserType = currentDetail.value.userType || 1;
  1447. console.log("当前用户信息:", userStore.userInfo);
  1448. console.log("当前用户类型:", currentUserType);
  1449. console.log("被拉黑用户类型:", blockedUserType);
  1450. console.log("动态详情:", currentDetail.value);
  1451. // 调用拉黑接口
  1452. await blockUser({
  1453. blockerType: currentUserType, // 拉黑者类型(当前登录用户类型)
  1454. blockedType: blockedUserType, // 被拉黑者类型(从 phoneId 解析)
  1455. blockerId: currentUserId, // 拉黑者ID(当前登录用户)
  1456. blockedId: currentDetail.value.storeUserId || currentDetail.value.userId || "" // 被拉黑者ID
  1457. });
  1458. if (!skipConfirm) {
  1459. ElMessage.success("已拉黑该用户");
  1460. }
  1461. // 保存被拉黑用户的 phoneId 到 localStorage
  1462. const blockedPhoneId = currentDetail.value.phoneId;
  1463. if (blockedPhoneId) {
  1464. addToBlockedList(blockedPhoneId);
  1465. }
  1466. detailDrawerVisible.value = false;
  1467. // 重新加载动态列表(会自动应用黑名单过滤)
  1468. await loadDynamicList();
  1469. } catch (error) {
  1470. if (!skipConfirm) {
  1471. // 单独拉黑时,用户取消操作或接口失败
  1472. console.error("拉黑失败:", error);
  1473. if (error !== "cancel") {
  1474. ElMessage.error("拉黑失败");
  1475. }
  1476. } else {
  1477. // 举报后自动拉黑失败,抛出错误
  1478. throw error;
  1479. }
  1480. }
  1481. };
  1482. // 初始化
  1483. onMounted(() => {
  1484. loadDynamicList();
  1485. });
  1486. // 页面激活时刷新列表(从发布页面返回时触发)
  1487. onActivated(() => {
  1488. loadDynamicList();
  1489. });
  1490. </script>
  1491. <style scoped lang="scss">
  1492. @import "@/assets/dianzanFont/iconfont.css";
  1493. .dynamic-management-container {
  1494. min-height: calc(100vh - 120px);
  1495. padding: 20px;
  1496. background: #ffffff;
  1497. // 头部区域
  1498. .header-section {
  1499. display: flex;
  1500. align-items: center;
  1501. justify-content: space-between;
  1502. margin-bottom: 20px;
  1503. border-bottom: 1px solid #e4e7ed;
  1504. :deep(.el-tabs) {
  1505. flex: 1;
  1506. margin-bottom: -1px;
  1507. .el-tabs__header {
  1508. margin-bottom: 0;
  1509. }
  1510. .el-tabs__nav-wrap::after {
  1511. display: none;
  1512. }
  1513. }
  1514. .action-buttons {
  1515. padding-bottom: 10px;
  1516. margin-left: 20px;
  1517. }
  1518. }
  1519. // 内容区域
  1520. .content-section {
  1521. margin-top: 20px;
  1522. }
  1523. // 动态网格布局
  1524. .dynamic-grid {
  1525. display: grid;
  1526. grid-template-columns: repeat(3, 1fr);
  1527. gap: 20px;
  1528. margin-bottom: 20px;
  1529. @media (width <= 1400px) {
  1530. grid-template-columns: repeat(2, 1fr);
  1531. }
  1532. @media (width <= 768px) {
  1533. grid-template-columns: repeat(1, 1fr);
  1534. }
  1535. }
  1536. // 动态卡片
  1537. .dynamic-card {
  1538. overflow: hidden;
  1539. cursor: pointer;
  1540. background: #ffffff;
  1541. border: 1px solid #e4e7ed;
  1542. border-radius: 8px;
  1543. transition: all 0.3s;
  1544. &:hover {
  1545. box-shadow: 0 2px 12px rgb(0 0 0 / 10%);
  1546. transform: translateY(-2px);
  1547. }
  1548. // 图片区域
  1549. .dynamic-image-wrapper {
  1550. display: flex;
  1551. align-items: center;
  1552. justify-content: center;
  1553. width: 100%;
  1554. height: 220px;
  1555. overflow: hidden;
  1556. background: #f5f7fa;
  1557. .dynamic-image {
  1558. width: 100%;
  1559. height: 100%;
  1560. object-fit: cover;
  1561. }
  1562. .image-placeholder {
  1563. display: flex;
  1564. align-items: center;
  1565. justify-content: center;
  1566. width: 100%;
  1567. height: 100%;
  1568. background: #f5f7fa;
  1569. }
  1570. }
  1571. // 动态内容
  1572. .dynamic-content {
  1573. padding: 12px 16px;
  1574. .dynamic-text {
  1575. margin-bottom: 12px;
  1576. overflow: hidden;
  1577. font-size: 14px;
  1578. color: #333333;
  1579. text-overflow: ellipsis;
  1580. white-space: nowrap;
  1581. }
  1582. // 底部信息
  1583. .dynamic-footer {
  1584. display: flex;
  1585. align-items: center;
  1586. justify-content: space-between;
  1587. .user-info {
  1588. display: flex;
  1589. gap: 8px;
  1590. align-items: center;
  1591. .user-avatar {
  1592. display: flex;
  1593. align-items: center;
  1594. justify-content: center;
  1595. width: 24px;
  1596. height: 24px;
  1597. overflow: hidden;
  1598. background: #e4e7ed;
  1599. border-radius: 50%;
  1600. img {
  1601. width: 100%;
  1602. height: 100%;
  1603. object-fit: cover;
  1604. }
  1605. }
  1606. .user-name {
  1607. font-size: 13px;
  1608. color: #666666;
  1609. }
  1610. }
  1611. .like-section {
  1612. display: flex;
  1613. gap: 4px;
  1614. align-items: center;
  1615. .like-icon {
  1616. cursor: pointer;
  1617. transition: color 0.3s;
  1618. &:hover {
  1619. color: #f56c6c;
  1620. }
  1621. }
  1622. .like-count {
  1623. font-size: 13px;
  1624. color: #666666;
  1625. }
  1626. }
  1627. }
  1628. }
  1629. }
  1630. // 空状态
  1631. .empty-section {
  1632. padding: 80px 0;
  1633. text-align: center;
  1634. }
  1635. // 分页
  1636. .pagination-section {
  1637. display: flex;
  1638. justify-content: center;
  1639. padding: 20px 0;
  1640. margin-top: 30px;
  1641. }
  1642. // 详情 Drawer
  1643. :deep(.detail-drawer) {
  1644. .el-drawer__header {
  1645. position: absolute;
  1646. top: 0;
  1647. right: 0;
  1648. left: 0;
  1649. z-index: 10;
  1650. padding: 0;
  1651. margin: 0;
  1652. background: transparent;
  1653. }
  1654. .el-drawer__body {
  1655. padding: 0;
  1656. background: #000000;
  1657. }
  1658. .drawer-header {
  1659. padding: 20px;
  1660. .close-btn {
  1661. padding: 8px;
  1662. font-size: 24px;
  1663. color: #ffffff;
  1664. background: #ffffff;
  1665. }
  1666. }
  1667. .detail-content {
  1668. position: relative;
  1669. display: flex;
  1670. width: 100%;
  1671. height: 100%;
  1672. // 主内容区域
  1673. .detail-main {
  1674. display: flex;
  1675. flex: 1;
  1676. flex-direction: column;
  1677. align-items: center;
  1678. justify-content: center;
  1679. padding: 80px 120px 40px 40px;
  1680. .media-container {
  1681. position: relative;
  1682. display: flex;
  1683. flex: 1;
  1684. align-items: center;
  1685. justify-content: center;
  1686. width: 100%;
  1687. max-width: 800px;
  1688. min-height: 400px;
  1689. .media-carousel {
  1690. width: 100%;
  1691. height: 100%;
  1692. min-height: 400px;
  1693. max-height: 70vh;
  1694. :deep(.el-carousel__container) {
  1695. height: 100% !important;
  1696. min-height: 400px;
  1697. }
  1698. :deep(.el-carousel__item) {
  1699. display: flex;
  1700. align-items: center;
  1701. justify-content: center;
  1702. background: transparent;
  1703. }
  1704. :deep(.el-carousel__arrow) {
  1705. width: 48px;
  1706. height: 48px;
  1707. font-size: 24px;
  1708. color: #ffffff;
  1709. background-color: rgb(0 0 0 / 40%);
  1710. border: none;
  1711. &:hover {
  1712. background-color: rgb(0 0 0 / 60%);
  1713. }
  1714. }
  1715. :deep(.el-carousel__indicators) {
  1716. bottom: -30px;
  1717. .el-carousel__indicator {
  1718. .el-carousel__button {
  1719. width: 8px;
  1720. height: 8px;
  1721. background-color: rgb(255 255 255 / 40%);
  1722. border-radius: 50%;
  1723. }
  1724. &.is-active .el-carousel__button {
  1725. background-color: #409eff;
  1726. }
  1727. }
  1728. }
  1729. }
  1730. .detail-media {
  1731. max-width: 100%;
  1732. max-height: 65vh;
  1733. object-fit: contain;
  1734. border-radius: 8px;
  1735. }
  1736. .detail-image {
  1737. max-width: 100%;
  1738. max-height: 65vh;
  1739. object-fit: contain;
  1740. border-radius: 8px;
  1741. }
  1742. .detail-video {
  1743. width: 100%;
  1744. max-height: 65vh;
  1745. background: #000000;
  1746. border-radius: 8px;
  1747. }
  1748. .media-placeholder {
  1749. display: flex;
  1750. align-items: center;
  1751. justify-content: center;
  1752. width: 400px;
  1753. height: 400px;
  1754. background: rgb(255 255 255 / 5%);
  1755. border-radius: 8px;
  1756. }
  1757. .media-counter {
  1758. position: absolute;
  1759. right: 16px;
  1760. bottom: -24px;
  1761. padding: 4px 12px;
  1762. font-size: 14px;
  1763. color: #ffffff;
  1764. background: rgb(0 0 0 / 50%);
  1765. border-radius: 12px;
  1766. }
  1767. }
  1768. .detail-info {
  1769. width: 100%;
  1770. max-width: 800px;
  1771. padding: 20px 0;
  1772. .author-info {
  1773. display: flex;
  1774. gap: 12px;
  1775. align-items: center;
  1776. margin-bottom: 16px;
  1777. .author-avatar {
  1778. display: flex;
  1779. align-items: center;
  1780. justify-content: center;
  1781. width: 40px;
  1782. height: 40px;
  1783. overflow: hidden;
  1784. background: rgb(255 255 255 / 10%);
  1785. border-radius: 50%;
  1786. img {
  1787. width: 100%;
  1788. height: 100%;
  1789. object-fit: cover;
  1790. }
  1791. }
  1792. .author-details {
  1793. flex: 1;
  1794. .author-name {
  1795. margin-bottom: 4px;
  1796. font-size: 16px;
  1797. font-weight: 500;
  1798. color: #ffffff;
  1799. }
  1800. .publish-time {
  1801. font-size: 13px;
  1802. color: rgb(255 255 255 / 60%);
  1803. }
  1804. }
  1805. }
  1806. .detail-description {
  1807. position: relative;
  1808. font-size: 15px;
  1809. line-height: 1.6;
  1810. color: #ffffff;
  1811. p {
  1812. margin: 0;
  1813. word-break: break-word;
  1814. &.text-ellipsis {
  1815. display: -webkit-box;
  1816. overflow: hidden;
  1817. text-overflow: ellipsis;
  1818. -webkit-line-clamp: 2;
  1819. line-clamp: 2;
  1820. -webkit-box-orient: vertical;
  1821. }
  1822. }
  1823. .expand-btn {
  1824. display: inline-block;
  1825. margin-top: 8px;
  1826. font-size: 14px;
  1827. color: #409eff;
  1828. cursor: pointer;
  1829. user-select: none;
  1830. &:hover {
  1831. color: #66b1ff;
  1832. }
  1833. }
  1834. }
  1835. }
  1836. }
  1837. // 右侧操作栏
  1838. .action-bar {
  1839. position: fixed;
  1840. right: 40px;
  1841. bottom: 100px;
  1842. z-index: 10;
  1843. display: flex;
  1844. flex-direction: column;
  1845. gap: 24px;
  1846. .action-item {
  1847. display: flex;
  1848. flex-direction: column;
  1849. gap: 6px;
  1850. align-items: center;
  1851. cursor: pointer;
  1852. transition: transform 0.3s;
  1853. &:hover {
  1854. transform: scale(1.1);
  1855. }
  1856. &.author-action {
  1857. cursor: pointer;
  1858. &:hover {
  1859. transform: scale(1.1);
  1860. }
  1861. }
  1862. .action-avatar {
  1863. position: relative;
  1864. display: flex;
  1865. align-items: center;
  1866. justify-content: center;
  1867. width: 48px;
  1868. height: 48px;
  1869. overflow: visible;
  1870. cursor: pointer;
  1871. background: rgb(255 255 255 / 20%);
  1872. border: 2px solid #ffffff;
  1873. border-radius: 50%;
  1874. img {
  1875. width: 100%;
  1876. height: 100%;
  1877. object-fit: cover;
  1878. border-radius: 50%;
  1879. }
  1880. .follow-badge {
  1881. position: absolute;
  1882. right: -4px;
  1883. bottom: -4px;
  1884. z-index: 2;
  1885. display: flex;
  1886. align-items: center;
  1887. justify-content: center;
  1888. width: 24px;
  1889. height: 24px;
  1890. cursor: pointer;
  1891. background: #409eff;
  1892. border: 2px solid #ffffff;
  1893. border-radius: 50%;
  1894. transition: transform 0.2s;
  1895. &:hover {
  1896. transform: scale(1.15);
  1897. }
  1898. }
  1899. }
  1900. .action-icon {
  1901. display: flex;
  1902. align-items: center;
  1903. justify-content: center;
  1904. width: 48px;
  1905. height: 48px;
  1906. background: rgb(0 0 0 / 50%);
  1907. backdrop-filter: blur(10px);
  1908. border-radius: 50%;
  1909. &.follow-icon {
  1910. background: #409eff;
  1911. }
  1912. }
  1913. .action-count {
  1914. font-size: 13px;
  1915. color: #ffffff;
  1916. text-align: center;
  1917. text-shadow: 0 1px 3px rgb(0 0 0 / 50%);
  1918. }
  1919. }
  1920. }
  1921. }
  1922. }
  1923. // 更多操作 Popover
  1924. :deep(.more-actions-popover) {
  1925. min-width: 120px;
  1926. padding: 8px 0;
  1927. background: rgb(0 0 0 / 90%);
  1928. backdrop-filter: blur(10px);
  1929. border: 1px solid rgb(255 255 255 / 10%);
  1930. .el-popper__arrow::before {
  1931. background: rgb(0 0 0 / 90%);
  1932. border: 1px solid rgb(255 255 255 / 10%);
  1933. }
  1934. .more-actions-menu {
  1935. .menu-item {
  1936. display: flex;
  1937. gap: 10px;
  1938. align-items: center;
  1939. padding: 10px 16px;
  1940. font-size: 14px;
  1941. line-height: 20px;
  1942. color: #ffffff;
  1943. cursor: pointer;
  1944. transition: all 0.3s;
  1945. &:hover {
  1946. background: rgb(255 255 255 / 10%);
  1947. }
  1948. .el-icon {
  1949. display: inline-flex;
  1950. flex-shrink: 0;
  1951. align-items: center;
  1952. justify-content: center;
  1953. width: 18px;
  1954. height: 18px;
  1955. color: #ffffff;
  1956. vertical-align: middle;
  1957. }
  1958. span {
  1959. display: inline-block;
  1960. line-height: 20px;
  1961. vertical-align: middle;
  1962. }
  1963. }
  1964. }
  1965. }
  1966. // 举报对话框
  1967. :deep(.el-dialog) {
  1968. .report-dialog-content {
  1969. .report-tip {
  1970. margin-bottom: 20px;
  1971. font-size: 14px;
  1972. line-height: 1.6;
  1973. color: #606266;
  1974. }
  1975. .report-reasons {
  1976. margin-bottom: 20px;
  1977. .el-radio-group {
  1978. display: flex;
  1979. flex-wrap: wrap;
  1980. gap: 12px 16px;
  1981. .el-radio {
  1982. height: auto;
  1983. margin-right: 0;
  1984. white-space: nowrap;
  1985. .el-radio__label {
  1986. font-size: 14px;
  1987. color: #303133;
  1988. }
  1989. }
  1990. }
  1991. }
  1992. .report-description {
  1993. margin-bottom: 20px;
  1994. :deep(.el-textarea__inner) {
  1995. font-size: 14px;
  1996. }
  1997. }
  1998. .report-upload {
  1999. margin-bottom: 20px;
  2000. .upload-title {
  2001. margin-bottom: 12px;
  2002. font-size: 14px;
  2003. font-weight: 500;
  2004. color: #303133;
  2005. }
  2006. :deep(.el-upload-list) {
  2007. display: flex;
  2008. flex-wrap: wrap;
  2009. gap: 8px;
  2010. }
  2011. :deep(.el-upload--picture-card) {
  2012. width: 100px;
  2013. height: 100px;
  2014. border-radius: 4px;
  2015. }
  2016. :deep(.el-upload-list--picture-card .el-upload-list__item) {
  2017. width: 100px;
  2018. height: 100px;
  2019. margin: 0;
  2020. border-radius: 4px;
  2021. }
  2022. }
  2023. .report-agreement {
  2024. .el-checkbox {
  2025. .el-checkbox__label {
  2026. font-size: 14px;
  2027. color: #606266;
  2028. }
  2029. }
  2030. }
  2031. }
  2032. .dialog-footer {
  2033. display: flex;
  2034. gap: 12px;
  2035. justify-content: flex-end;
  2036. }
  2037. }
  2038. // 评论侧边栏样式
  2039. .comment-list-container {
  2040. flex: 1;
  2041. height: calc(100vh - 200px);
  2042. padding: 0 20px;
  2043. overflow-y: auto;
  2044. .comment-list {
  2045. .comment-item {
  2046. display: flex;
  2047. gap: 12px;
  2048. padding: 16px 0;
  2049. border-bottom: 1px solid #f0f0f0;
  2050. &:last-child {
  2051. border-bottom: none;
  2052. }
  2053. .comment-avatar {
  2054. display: flex;
  2055. flex-shrink: 0;
  2056. align-items: center;
  2057. justify-content: center;
  2058. width: 40px;
  2059. height: 40px;
  2060. overflow: hidden;
  2061. background: #f5f5f5;
  2062. border-radius: 50%;
  2063. img {
  2064. width: 100%;
  2065. height: 100%;
  2066. object-fit: cover;
  2067. }
  2068. }
  2069. .comment-content-wrapper {
  2070. flex: 1;
  2071. min-width: 0;
  2072. .comment-header,
  2073. .store-comment-header {
  2074. display: flex;
  2075. align-items: center;
  2076. justify-content: space-between;
  2077. margin-bottom: 8px;
  2078. .comment-user-name {
  2079. font-size: 14px;
  2080. font-weight: 500;
  2081. color: #303133;
  2082. }
  2083. .comment-time {
  2084. font-size: 12px;
  2085. color: #909399;
  2086. }
  2087. }
  2088. .comment-text {
  2089. margin-bottom: 8px;
  2090. font-size: 14px;
  2091. line-height: 1.6;
  2092. color: #606266;
  2093. word-break: break-all;
  2094. }
  2095. // 商家回复样式
  2096. .store-comment-wrapper {
  2097. padding: 12px;
  2098. margin-top: 12px;
  2099. background: #f5f7fa;
  2100. border-radius: 8px;
  2101. .store-comment-item {
  2102. display: flex;
  2103. gap: 10px;
  2104. .store-comment-avatar {
  2105. display: flex;
  2106. flex-shrink: 0;
  2107. align-items: center;
  2108. justify-content: center;
  2109. width: 32px;
  2110. height: 32px;
  2111. overflow: hidden;
  2112. background: #ffffff;
  2113. border-radius: 50%;
  2114. img {
  2115. width: 100%;
  2116. height: 100%;
  2117. object-fit: cover;
  2118. }
  2119. }
  2120. .store-comment-content {
  2121. flex: 1;
  2122. min-width: 0;
  2123. .store-comment-header {
  2124. display: flex;
  2125. align-items: center;
  2126. justify-content: space-between;
  2127. margin-bottom: 6px;
  2128. .store-comment-user-name {
  2129. font-size: 13px;
  2130. font-weight: 500;
  2131. color: #409eff;
  2132. }
  2133. .store-comment-time {
  2134. font-size: 11px;
  2135. color: #909399;
  2136. }
  2137. }
  2138. .store-comment-text {
  2139. display: flex;
  2140. align-items: center;
  2141. justify-content: space-between;
  2142. font-size: 13px;
  2143. line-height: 1.5;
  2144. color: #606266;
  2145. word-break: break-all;
  2146. }
  2147. }
  2148. }
  2149. }
  2150. .comment-actions {
  2151. display: flex;
  2152. gap: 20px;
  2153. .comment-action-item {
  2154. display: flex;
  2155. gap: 4px;
  2156. align-items: center;
  2157. font-size: 13px;
  2158. color: #909399;
  2159. cursor: pointer;
  2160. transition: color 0.3s;
  2161. &:hover {
  2162. color: #409eff;
  2163. }
  2164. span {
  2165. font-size: 13px;
  2166. }
  2167. }
  2168. }
  2169. }
  2170. }
  2171. }
  2172. }
  2173. .comment-input-wrapper {
  2174. position: absolute;
  2175. right: 0;
  2176. bottom: 0;
  2177. left: 0;
  2178. padding: 16px 20px;
  2179. background: #ffffff;
  2180. border-top: 1px solid #e4e7ed;
  2181. box-shadow: 0 -2px 8px rgb(0 0 0 / 5%);
  2182. .reply-hint {
  2183. display: flex;
  2184. align-items: center;
  2185. justify-content: space-between;
  2186. padding: 8px 12px;
  2187. margin-bottom: 8px;
  2188. background: #f5f7fa;
  2189. border-radius: 4px;
  2190. .reply-text {
  2191. font-size: 13px;
  2192. color: #409eff;
  2193. }
  2194. .cancel-reply {
  2195. font-size: 16px;
  2196. color: #909399;
  2197. cursor: pointer;
  2198. transition: color 0.3s;
  2199. &:hover {
  2200. color: #f56c6c;
  2201. }
  2202. }
  2203. }
  2204. :deep(.el-textarea) {
  2205. margin-bottom: 12px;
  2206. }
  2207. .el-button {
  2208. width: 100%;
  2209. }
  2210. }
  2211. // 分享对话框
  2212. .share-dialog-content {
  2213. .search-box {
  2214. margin-bottom: 16px;
  2215. }
  2216. .share-friend-list {
  2217. max-height: 400px;
  2218. margin-bottom: 16px;
  2219. overflow-y: auto;
  2220. .share-friend-item {
  2221. display: flex;
  2222. align-items: center;
  2223. justify-content: space-between;
  2224. padding: 12px;
  2225. cursor: pointer;
  2226. border-radius: 8px;
  2227. transition: background-color 0.3s;
  2228. &:hover {
  2229. background-color: #f5f7fa;
  2230. }
  2231. .friend-info {
  2232. display: flex;
  2233. gap: 12px;
  2234. align-items: center;
  2235. .friend-avatar {
  2236. display: flex;
  2237. flex-shrink: 0;
  2238. align-items: center;
  2239. justify-content: center;
  2240. width: 40px;
  2241. height: 40px;
  2242. overflow: hidden;
  2243. background: #f5f5f5;
  2244. border-radius: 50%;
  2245. img {
  2246. width: 100%;
  2247. height: 100%;
  2248. object-fit: cover;
  2249. }
  2250. }
  2251. .friend-name {
  2252. font-size: 14px;
  2253. font-weight: 500;
  2254. color: #303133;
  2255. }
  2256. }
  2257. }
  2258. }
  2259. .selected-friends {
  2260. padding: 12px;
  2261. background: #f5f7fa;
  2262. border-radius: 8px;
  2263. .selected-title {
  2264. margin-bottom: 8px;
  2265. font-size: 13px;
  2266. color: #606266;
  2267. }
  2268. .selected-list {
  2269. display: flex;
  2270. flex-wrap: wrap;
  2271. gap: 8px;
  2272. .el-tag {
  2273. max-width: 120px;
  2274. overflow: hidden;
  2275. text-overflow: ellipsis;
  2276. white-space: nowrap;
  2277. }
  2278. }
  2279. }
  2280. }
  2281. }
  2282. </style>