myDynamic.vue 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406
  1. <template>
  2. <div class="my-dynamic-container">
  3. <!-- 用户信息卡片 -->
  4. <div class="user-card">
  5. <div class="user-header">
  6. <div class="user-avatar-section">
  7. <div class="user-avatar-large">
  8. <img v-if="cachedHeadImg" :src="cachedHeadImg" :alt="userInfo.name" />
  9. <el-icon v-else :size="60">
  10. <Avatar />
  11. </el-icon>
  12. </div>
  13. <div class="user-info-text">
  14. <div class="user-name">
  15. {{ userStore.userInfo.nickName }}
  16. </div>
  17. <div class="user-stats">
  18. <span class="stat-item" @click="openRelationDialog('friend')">{{ userInfo.followCount }} 好友</span>
  19. <span class="stat-divider">|</span>
  20. <span class="stat-item" @click="openRelationDialog('follow')">{{ userInfo.fansCount }} 关注</span>
  21. <span class="stat-divider">|</span>
  22. <span class="stat-item" @click="openRelationDialog('fans')">{{ userInfo.likeCount }} 粉丝</span>
  23. </div>
  24. </div>
  25. <el-button type="primary" size="small" @click="addFriend" class="add-friend-btn">
  26. <el-icon class="btn-icon">
  27. <Plus />
  28. </el-icon>
  29. 添加好友
  30. </el-button>
  31. </div>
  32. </div>
  33. <div class="user-bio">
  34. {{ userStore.userInfo.accountBlurb }}
  35. </div>
  36. </div>
  37. <!-- 标签页 -->
  38. <div class="tabs-section">
  39. <el-tabs v-model="activeTab" @tab-click="handleTabClick">
  40. <el-tab-pane label="动态" name="dynamic" />
  41. <el-tab-pane label="赞过" name="liked" />
  42. </el-tabs>
  43. </div>
  44. <!-- 内容区域 -->
  45. <div v-if="contentList.length > 0 && activeTab === 'dynamic'" class="content-section">
  46. <!-- 动态卡片网格 -->
  47. <div class="content-grid">
  48. <div class="draft-card" @click="handleDraftClick">
  49. <el-icon :size="48" color="#999">
  50. <Edit />
  51. </el-icon>
  52. <div class="draft-title">本地草稿</div>
  53. <div class="draft-count">有{{ draftCount }}篇动态待发布</div>
  54. </div>
  55. <div v-for="item in contentList" :key="item.id" class="content-card" @click="handleCardClick(item)">
  56. <!-- 封面图片/视频区域 -->
  57. <div class="content-cover-wrapper">
  58. <img v-if="item.imagePath" :src="getCoverImage(item)" :alt="item.title" class="content-cover" />
  59. <div v-else class="cover-placeholder">
  60. <el-icon :size="48" color="#999">
  61. <Picture />
  62. </el-icon>
  63. </div>
  64. <!-- 视频播放按钮 -->
  65. <div v-if="isVideoItem(item)" class="play-overlay">
  66. <el-icon :size="40" color="#fff">
  67. <VideoPlay />
  68. </el-icon>
  69. </div>
  70. <!-- 标题标签(仅第一个显示) -->
  71. <div v-if="item.showLabel" class="content-label">
  72. {{ item.labelText }}
  73. </div>
  74. </div>
  75. <!-- 底部信息 -->
  76. <div class="content-footer">
  77. <div class="footer-left">
  78. <el-icon :size="14" color="#666">
  79. <View />
  80. </el-icon>
  81. <span class="view-count">{{ item.liulanCount }}</span>
  82. </div>
  83. <div class="footer-right">
  84. <i class="iconfont icon-dianzanb" :style="{ fontSize: '14px', color: item.isLike == '1' ? '#f56c6c' : '#666' }" />
  85. <span class="like-count">{{ item.dianzanCount || 0 }}</span>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <!-- 赞过 -->
  92. <div class="content-section" v-if="dianZanList.length > 0 && activeTab === 'liked'">
  93. <div class="content-grid">
  94. <div v-for="item in dianZanList" :key="item.id" class="content-card" @click="handleCardClick(item)">
  95. <!-- 封面图片/视频区域 -->
  96. <div class="content-cover-wrapper">
  97. <img v-if="item.imagePath" :src="getCoverImage(item)" :alt="item.title" class="content-cover" />
  98. <div v-else class="cover-placeholder">
  99. <el-icon :size="48" color="#999">
  100. <Picture />
  101. </el-icon>
  102. </div>
  103. <!-- 视频播放按钮 -->
  104. <div v-if="isVideoItem(item)" class="play-overlay">
  105. <el-icon :size="40" color="#fff">
  106. <VideoPlay />
  107. </el-icon>
  108. </div>
  109. <!-- 标题标签(仅第一个显示) -->
  110. <div v-if="item.showLabel" class="content-label">
  111. {{ item.labelText }}
  112. </div>
  113. </div>
  114. <!-- 底部信息 -->
  115. <div class="content-footer">
  116. <div class="footer-left">
  117. <el-icon :size="14" color="#666">
  118. <View />
  119. </el-icon>
  120. <span class="view-count">{{ item.liulanCount || 0 }}</span>
  121. </div>
  122. <div class="footer-right">
  123. <i class="iconfont icon-dianzanb" :style="{ fontSize: '14px', color: item.isLike == '1' ? '#f56c6c' : '#666' }" />
  124. <span class="like-count">{{ item.dianzanCount || 0 }}</span>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. <!-- 动态详情 Drawer -->
  131. <el-drawer
  132. v-model="detailDrawerVisible"
  133. direction="rtl"
  134. size="90%"
  135. :show-close="false"
  136. destroy-on-close
  137. class="detail-drawer"
  138. >
  139. <template #header>
  140. <div class="drawer-header">
  141. <el-button class="close-btn" text @click="handleCloseDetail">
  142. <el-icon :size="24">
  143. <Close />
  144. </el-icon>
  145. </el-button>
  146. </div>
  147. </template>
  148. <div v-if="currentDetail" class="detail-content">
  149. <!-- 主内容区域 -->
  150. <div class="detail-main">
  151. <!-- 图片/视频轮播展示 -->
  152. <div class="media-container">
  153. <!-- 多媒体轮播 -->
  154. <el-carousel
  155. v-if="currentDetail.mediaList && currentDetail.mediaList.length > 0"
  156. :autoplay="false"
  157. :loop="false"
  158. indicator-position="outside"
  159. arrow="always"
  160. height="100%"
  161. class="media-carousel"
  162. @change="handleCarouselChange"
  163. >
  164. <el-carousel-item v-for="(media, index) in currentDetail.mediaList" :key="index">
  165. <!-- 视频 -->
  166. <video
  167. v-if="media.type === 'video'"
  168. :ref="el => setVideoRef(el, index)"
  169. :src="media.url"
  170. class="detail-media detail-video"
  171. controls
  172. preload="metadata"
  173. @play="handleVideoPlay(index)"
  174. />
  175. <!-- 图片 -->
  176. <img v-else :src="media.url" :alt="currentDetail.title" class="detail-media detail-image" />
  177. </el-carousel-item>
  178. </el-carousel>
  179. <!-- 占位符 -->
  180. <div v-else class="media-placeholder">
  181. <el-icon :size="80" color="#dcdfe6">
  182. <Picture />
  183. </el-icon>
  184. </div>
  185. <!-- 媒体计数指示器 -->
  186. <div v-if="currentDetail.mediaList && currentDetail.mediaList.length > 1" class="media-counter">
  187. {{ currentCarouselIndex + 1 }} / {{ currentDetail.mediaList.length }}
  188. </div>
  189. </div>
  190. <!-- 底部信息 -->
  191. <div class="detail-info">
  192. <div class="author-info">
  193. <div class="author-avatar">
  194. <img
  195. v-if="currentDetail.author?.avatar || currentDetail.userAvatar"
  196. :src="currentDetail.author?.avatar || currentDetail.userAvatar"
  197. :alt="currentDetail.author?.name || currentDetail.userName"
  198. />
  199. <el-icon v-else :size="32">
  200. <Avatar />
  201. </el-icon>
  202. </div>
  203. <div class="author-details">
  204. <div class="author-name">@{{ currentDetail.author?.name || currentDetail.userName }}</div>
  205. <div class="publish-time">
  206. {{ currentDetail.publishTime }}
  207. </div>
  208. </div>
  209. </div>
  210. <div style="padding-bottom: 10px; color: #ffffff">
  211. {{ currentDetail.title }}
  212. </div>
  213. <div class="detail-description">
  214. <p
  215. v-if="isDescriptionExpanded || (currentDetail.context && currentDetail.context.length >= 20)"
  216. :class="{ 'text-ellipsis': !isDescriptionExpanded }"
  217. >
  218. {{ currentDetail.context }}
  219. </p>
  220. <span v-if="currentDetail.context" class="expand-btn" @click="toggleDescription">
  221. {{ isDescriptionExpanded ? "收起" : "展开" }}
  222. </span>
  223. </div>
  224. </div>
  225. </div>
  226. <!-- 右侧操作栏 -->
  227. <div class="action-bar">
  228. <!-- 作者头像 -->
  229. <div class="action-item author-action">
  230. <div class="action-avatar" @click="handleViewUserProfile">
  231. <img
  232. v-if="currentDetail.author?.avatar || currentDetail.userAvatar"
  233. :src="currentDetail.author?.avatar || currentDetail.userAvatar"
  234. :alt="currentDetail.author?.name || currentDetail.userName"
  235. />
  236. <el-icon v-else :size="40" color="#fff">
  237. <Avatar />
  238. </el-icon>
  239. </div>
  240. </div>
  241. <!-- 点赞 -->
  242. <div class="action-item" @click="handleDetailLike">
  243. <div class="action-icon">
  244. <i
  245. class="iconfont icon-dianzanb"
  246. :style="{ fontSize: '28px', color: currentDetail.isLike == '1' ? '#f56c6c' : '#fff' }"
  247. />
  248. </div>
  249. <div class="action-count">
  250. {{ currentDetail.dianzanCount }}
  251. </div>
  252. </div>
  253. <!-- 评论 -->
  254. <div class="action-item" @click="handleShowComments">
  255. <div class="action-icon">
  256. <el-icon :size="28" color="#fff">
  257. <ChatDotRound />
  258. </el-icon>
  259. </div>
  260. <div class="action-count">
  261. {{ currentDetail.commentCount }}
  262. </div>
  263. </div>
  264. <!-- 分享 -->
  265. <div class="action-item" @click="handleShare">
  266. <div class="action-icon">
  267. <el-icon :size="28" color="#fff">
  268. <Share />
  269. </el-icon>
  270. </div>
  271. <div class="action-count">分享</div>
  272. </div>
  273. <!-- 更多 -->
  274. <el-popover placement="left" :width="120" trigger="click" popper-class="more-actions-popover">
  275. <template #reference>
  276. <div class="action-item">
  277. <div class="action-icon">
  278. <el-icon :size="28" color="#fff">
  279. <MoreFilled />
  280. </el-icon>
  281. </div>
  282. </div>
  283. </template>
  284. <div class="more-actions-menu">
  285. <!-- 如果是当前用户的动态,显示删除 -->
  286. <template v-if="isMyDynamic">
  287. <!-- <div class="menu-item" @click="handleEditDynamic">
  288. <el-icon :size="18">
  289. <Edit />
  290. </el-icon>
  291. <span>编辑</span>
  292. </div> -->
  293. <div class="menu-item" style="display: flex; cursor: pointer" @click="handleDeleteDynamic">
  294. <el-icon :size="18">
  295. <Delete /> </el-icon
  296. >&nbsp;&nbsp;
  297. <span>删除</span>
  298. </div>
  299. </template>
  300. <!-- 如果不是当前用户的动态,显示举报和拉黑 -->
  301. <template v-else>
  302. <div class="menu-item" @click="handleReportDynamic">
  303. <el-icon :size="18">
  304. <Warning />
  305. </el-icon>
  306. <span>举报</span>
  307. </div>
  308. <div class="menu-item" @click="handleBlockUserClick">
  309. <el-icon :size="18">
  310. <CircleClose />
  311. </el-icon>
  312. <span>拉黑</span>
  313. </div>
  314. </template>
  315. </div>
  316. </el-popover>
  317. </div>
  318. </div>
  319. </el-drawer>
  320. <!-- 评论侧边栏 -->
  321. <el-drawer v-model="commentDrawerVisible" title="评论" direction="rtl" size="400px" destroy-on-close>
  322. <!-- 评论列表 -->
  323. <div class="comment-list-container">
  324. <div v-if="commentListData.length > 0" class="comment-list">
  325. <div v-for="comment in commentListData" :key="comment.id" class="comment-item">
  326. <div class="comment-avatar">
  327. <img v-if="comment.userAvatar" :src="comment.userAvatar" :alt="comment.userName" />
  328. <el-icon v-else :size="32">
  329. <Avatar />
  330. </el-icon>
  331. </div>
  332. <div class="comment-content-wrapper">
  333. <div class="comment-header">
  334. <span class="comment-user-name">{{ comment.userName }}</span>
  335. </div>
  336. <div class="comment-text">
  337. {{ comment.commentContent }}
  338. </div>
  339. <div class="comment-actions">
  340. <span class="comment-action-item" @click="handleLikeComment(comment)">
  341. <i class="iconfont icon-dianzanb" :style="{ fontSize: '16px', color: comment.isLiked ? '#f56c6c' : '#999' }" />
  342. <span>{{ comment.likeCount || 0 }}</span>
  343. </span>
  344. <span class="comment-action-item" @click="handleReplyComment(comment)">
  345. <el-icon :size="16">
  346. <ChatDotRound />
  347. </el-icon>
  348. <span>回复</span>
  349. </span>
  350. </div>
  351. <!-- 商家回复 -->
  352. <div v-for="item in comment.storeComment" :key="item.id" class="store-comment-wrapper">
  353. <div class="store-comment-item">
  354. <div class="store-comment-avatar">
  355. <img v-if="item.userImage" :src="item.userImage" :alt="item.userName" />
  356. <el-icon v-else :size="24">
  357. <Avatar />
  358. </el-icon>
  359. </div>
  360. <div class="store-comment-content">
  361. <div class="store-comment-header">
  362. <span class="store-comment-user-name">{{ item.userName || "商家" }}</span>
  363. <span class="store-comment-time">{{ item.createdTime || item.createDate }}</span>
  364. </div>
  365. <div class="store-comment-text">
  366. {{ item.commentContent }}
  367. <span
  368. class="comment-action-item"
  369. @click="handleLikeComment(item)"
  370. style="display: flex; align-items: center"
  371. >
  372. <i
  373. class="iconfont icon-dianzanb"
  374. :style="{ fontSize: '16px', color: item.isLiked ? '#f56c6c' : '#999' }"
  375. />&nbsp;
  376. <span>{{ item.likeCount || 0 }}</span>
  377. </span>
  378. </div>
  379. </div>
  380. </div>
  381. </div>
  382. </div>
  383. </div>
  384. </div>
  385. <el-empty v-else description="暂无评论" />
  386. </div>
  387. <!-- 评论输入框 -->
  388. <div class="comment-input-wrapper">
  389. <!-- 回复提示 -->
  390. <div v-if="replyingComment" class="reply-hint">
  391. <span class="reply-text">回复 @{{ replyingComment.userName }}</span>
  392. <el-icon class="cancel-reply" @click="handleCancelReply">
  393. <Close />
  394. </el-icon>
  395. </div>
  396. <el-input
  397. v-model="commentInput"
  398. type="textarea"
  399. :rows="3"
  400. :placeholder="replyingComment ? '输入回复内容...' : '你要评论点什么呢~'"
  401. maxlength="500"
  402. show-word-limit
  403. />
  404. <el-button type="primary" :loading="commentSubmitting" @click="handleSubmitComment">
  405. {{ replyingComment ? "回复" : "发送" }}
  406. </el-button>
  407. </div>
  408. </el-drawer>
  409. <!-- 好友/关注/粉丝对话框 -->
  410. <el-dialog
  411. v-model="relationDialogVisible"
  412. :title="relationDialogTitle"
  413. width="600px"
  414. destroy-on-close
  415. @close="handleCloseRelationDialog"
  416. >
  417. <div class="relation-dialog-content">
  418. <!-- 标签页 -->
  419. <el-tabs v-model="relationActiveTab" @tab-click="handleRelationTabClick">
  420. <el-tab-pane label="好友" name="friend" value="friend" />
  421. <el-tab-pane label="关注" name="follow" value="follow" />
  422. <el-tab-pane label="粉丝" name="fans" value="fans" />
  423. </el-tabs>
  424. <!-- 搜索框 -->
  425. <div class="search-box">
  426. <el-input v-model="relationSearch" placeholder="请输入手机号或昵称" clearable @input="handleRelationSearch">
  427. <template #prefix>
  428. <el-icon>
  429. <Search />
  430. </el-icon>
  431. </template>
  432. </el-input>
  433. </div>
  434. <!-- 用户列表(一页5条,滚动到底自动加载) -->
  435. <div ref="relationListScrollRef" class="relation-list" @scroll="onRelationListScroll">
  436. <div v-for="user in filteredRelationList" :key="user.id" class="relation-item">
  437. <div class="user-info-row">
  438. <div class="user-avatar-small">
  439. <img v-if="user.avatar" :src="user.avatar" :alt="user.name" />
  440. <el-icon v-else :size="40">
  441. <Avatar />
  442. </el-icon>
  443. </div>
  444. <div class="user-details">
  445. <div class="user-name-text">
  446. {{ user.name }}
  447. </div>
  448. <div class="user-desc">
  449. {{ user.description }}
  450. </div>
  451. </div>
  452. </div>
  453. <div class="action-button">
  454. <el-button
  455. v-if="user.relationStatus === 'following'"
  456. type="primary"
  457. plain
  458. size="small"
  459. @click="handleUnfollow(user)"
  460. >
  461. 已关注
  462. </el-button>
  463. <el-button v-else-if="user.relationStatus === 'mutual'" type="primary" size="small" @click="handleUnfollow(user)">
  464. 互相关注
  465. </el-button>
  466. <el-button v-else type="primary" plain size="small" @click="handleFollow(user)"> 关注 </el-button>
  467. </div>
  468. </div>
  469. <!-- 触底加载哨兵(IntersectionObserver 检测可见时加载更多) -->
  470. <div v-if="relationHasMore" ref="relationLoadMoreSentinelRef" class="relation-load-sentinel" />
  471. <!-- 加载更多按钮(点击或滚到底都会触发) -->
  472. <div v-if="relationHasMore" class="relation-load-more">
  473. <el-button :loading="relationLoading" text type="primary" @click="loadMoreRelationList">
  474. {{ relationLoading ? "加载中..." : "点击或滚动到底加载更多" }}
  475. </el-button>
  476. </div>
  477. <!-- 空状态 -->
  478. <el-empty v-if="!relationLoading && filteredRelationList.length === 0" description="暂无数据" />
  479. </div>
  480. </div>
  481. </el-dialog>
  482. <!-- 添加好友对话框 -->
  483. <el-dialog
  484. v-model="addFriendDialogVisible"
  485. title="添加好友"
  486. width="500px"
  487. destroy-on-close
  488. @close="handleCloseAddFriendDialog"
  489. >
  490. <div class="add-friend-dialog-content">
  491. <!-- 搜索框 -->
  492. <div class="search-box">
  493. <el-input
  494. v-model="addFriendSearchKeyword"
  495. placeholder="请输入手机号或昵称"
  496. clearable
  497. @keyup.enter="handleSearchFriend"
  498. @input="handleSearchInput"
  499. @clear="handleClearSearch"
  500. >
  501. <template #prefix>
  502. <el-icon>
  503. <Search />
  504. </el-icon>
  505. </template>
  506. </el-input>
  507. </div>
  508. <!-- 搜索结果 -->
  509. <div v-if="addFriendSearchKeyword" class="search-results">
  510. <div v-if="addFriendSearching" class="search-loading">
  511. <el-icon class="is-loading" :size="20">
  512. <Loading />
  513. </el-icon>
  514. <span>搜索中...</span>
  515. </div>
  516. <div v-else-if="addFriendSearchResults.length > 0" class="search-results-list">
  517. <div class="search-results-count">共{{ addFriendSearchResults.length }}个搜索结果</div>
  518. <div v-for="user in addFriendSearchResults" :key="user.phoneId || user.id" class="search-result-item">
  519. <div class="user-info-row">
  520. <div class="user-avatar-small">
  521. <img v-if="user.imgUrl" :src="user.imgUrl || user.userAvatar" :alt="user.name || user.userName" />
  522. <el-icon v-else :size="40">
  523. <Avatar />
  524. </el-icon>
  525. </div>
  526. <div class="user-details">
  527. <div class="user-name-text">
  528. {{ user.storeUserName || "—" }}
  529. </div>
  530. <div class="user-desc">
  531. {{ user.blurb || "—" }}
  532. </div>
  533. </div>
  534. </div>
  535. <div class="action-button">
  536. <el-button v-if="user.isFollowThis == 1" type="primary" plain size="small" @click="handleUnfollowInSearch(user)">
  537. 已关注
  538. </el-button>
  539. <el-button v-else type="primary" plain size="small" @click="handleFollowInSearch(user)"> 关注 </el-button>
  540. </div>
  541. </div>
  542. </div>
  543. <div v-else class="search-empty">
  544. <el-empty description="暂无搜索结果" />
  545. </div>
  546. </div>
  547. <div v-else class="search-placeholder">
  548. <el-empty description="请输入手机号或昵称进行搜索" />
  549. </div>
  550. </div>
  551. </el-dialog>
  552. <!-- 举报对话框 -->
  553. <el-dialog v-model="reportDialogVisible" title="举报理由" width="500px" destroy-on-close @close="handleCloseReportDialog">
  554. <div class="report-dialog-content">
  555. <div class="report-tip">请选择最符合的原因,以便于我们进行的处理</div>
  556. <!-- 举报原因选项 -->
  557. <div class="report-reasons">
  558. <el-radio-group v-model="reportForm.reason">
  559. <el-radio label="用户头像"> 用户头像 </el-radio>
  560. <el-radio label="名称/昵称"> 名称/昵称 </el-radio>
  561. <el-radio label="违法违规"> 违法违规 </el-radio>
  562. <el-radio label="低俗色情、暴力恐怖、政治谣言"> 低俗色情、暴力恐怖、政治谣言 </el-radio>
  563. <el-radio label="涉嫌诈骗"> 涉嫌诈骗 </el-radio>
  564. <el-radio label="人身攻击"> 人身攻击 </el-radio>
  565. <el-radio label="侵犯版权"> 侵犯版权 </el-radio>
  566. <el-radio label="恶意骚扰"> 恶意骚扰 </el-radio>
  567. <el-radio label="虚假/过度宣传"> 虚假/过度宣传 </el-radio>
  568. <el-radio label="诱导点赞分享"> 诱导点赞分享 </el-radio>
  569. <el-radio label="传播人身安全"> 传播人身安全 </el-radio>
  570. <el-radio label="侵权举报"> 侵权举报 </el-radio>
  571. <el-radio label="其他举报"> 其他举报 </el-radio>
  572. </el-radio-group>
  573. </div>
  574. <!-- 详细描述 -->
  575. <div class="report-description">
  576. <el-input
  577. v-model="reportForm.description"
  578. type="textarea"
  579. :rows="4"
  580. placeholder="请描述任何涉及举报内容的其体情况,我们会综合一判断合举政采!(必填)"
  581. maxlength="300"
  582. show-word-limit
  583. />
  584. </div>
  585. <!-- 上传凭证 -->
  586. <div class="report-upload">
  587. <div class="upload-title">上传凭证</div>
  588. <el-upload
  589. v-model:file-list="reportForm.fileList"
  590. list-type="picture-card"
  591. :limit="9"
  592. :on-preview="handleReportPreview"
  593. :on-remove="handleReportRemove"
  594. :before-upload="beforeReportUpload"
  595. :http-request="handleReportUpload"
  596. accept="image/*"
  597. multiple
  598. >
  599. <el-icon :size="24">
  600. <Plus />
  601. </el-icon>
  602. </el-upload>
  603. </div>
  604. <!-- 同意协议 -->
  605. <div class="report-agreement">
  606. <el-checkbox v-model="reportForm.agreed"> 同意发票用户协议 </el-checkbox>
  607. </div>
  608. </div>
  609. <template #footer>
  610. <div class="dialog-footer">
  611. <el-button @click="reportDialogVisible = false"> 取消 </el-button>
  612. <el-button type="primary" :loading="reportSubmitting" @click="handleSubmitReport"> 提交 </el-button>
  613. </div>
  614. </template>
  615. </el-dialog>
  616. <!-- 分享对话框 -->
  617. <el-dialog v-model="shareDialogVisible" title="分享给好友" width="500px" destroy-on-close @close="handleCloseShareDialog">
  618. <div class="share-dialog-content">
  619. <!-- 好友列表 -->
  620. <div class="share-friend-list">
  621. <div v-if="filteredShareFriendList.length > 0">
  622. <div
  623. v-for="friend in filteredShareFriendList"
  624. :key="friend.id"
  625. class="share-friend-item"
  626. @click="handleSelectFriend(friend)"
  627. >
  628. <div class="friend-info">
  629. <div class="friend-avatar">
  630. <img v-if="friend.avatar" :src="friend.avatar" :alt="friend.name" />
  631. <el-icon v-else :size="40">
  632. <Avatar />
  633. </el-icon>
  634. </div>
  635. <div class="friend-name">
  636. {{ friend.name }}
  637. </div>
  638. </div>
  639. <el-icon v-if="selectedFriends.includes(friend.id)" :size="20" color="#409eff">
  640. <CircleCheck />
  641. </el-icon>
  642. </div>
  643. </div>
  644. <el-empty v-else description="暂无好友" />
  645. </div>
  646. <!-- 已选择的好友 -->
  647. <div v-if="selectedFriends.length > 0" class="selected-friends">
  648. <div class="selected-title">已选择 {{ selectedFriends.length }} 位好友</div>
  649. <div class="selected-list">
  650. <el-tag v-for="friendId in selectedFriends" :key="friendId" closable @close="handleRemoveFriend(friendId)">
  651. {{ shareFriendList.find(f => f.id === friendId)?.name }}
  652. </el-tag>
  653. </div>
  654. </div>
  655. </div>
  656. <template #footer>
  657. <div class="dialog-footer">
  658. <el-button @click="shareDialogVisible = false"> 取消 </el-button>
  659. <el-button
  660. type="primary"
  661. :loading="shareSubmitting"
  662. :disabled="selectedFriends.length === 0"
  663. @click="handleConfirmShare"
  664. >
  665. 确认分享
  666. </el-button>
  667. </div>
  668. </template>
  669. </el-dialog>
  670. <PcImagePreviewViewer
  671. v-model:visible="reportEvidencePreviewVisible"
  672. :url-list="reportEvidencePreviewUrls"
  673. :initial-index="reportEvidencePreviewIndex"
  674. />
  675. </div>
  676. </template>
  677. <script setup lang="ts" name="myDynamic">
  678. import { ref, reactive, computed, onMounted, nextTick, watch } from "vue";
  679. import { useRouter } from "vue-router";
  680. import { ElMessage, ElMessageBox } from "element-plus";
  681. import {
  682. Avatar,
  683. Picture,
  684. VideoPlay,
  685. View,
  686. Search,
  687. Close,
  688. ChatDotRound,
  689. Share,
  690. MoreFilled,
  691. Edit,
  692. Delete,
  693. Warning,
  694. Plus,
  695. CircleCheck,
  696. CircleClose,
  697. Loading
  698. } from "@element-plus/icons-vue";
  699. import {
  700. deleteDynamicsById,
  701. getUserDynamics,
  702. getUserDraftDynamics,
  703. getHomePageInfo,
  704. getDianZanList,
  705. saveComment,
  706. commentList,
  707. type CommentListParams,
  708. getMutualAttention,
  709. getMyFollowed,
  710. addTransferCount,
  711. getMyUserFans,
  712. getMyStoreFans,
  713. blockUser,
  714. likeDynamicNew,
  715. unlikeDynamicNew,
  716. getStoreAndUserByName,
  717. toggleFollowUser,
  718. cancelFollewed
  719. } from "@/api/modules/newLoginApi";
  720. import {} from "@/api/modules/dynamicManagement";
  721. import { useUserStore } from "@/stores/modules/user";
  722. import FriendCoupon from "./friendCoupon.vue";
  723. import { localGet } from "@/utils";
  724. import { normalizeCommonCommentListResponse, countTopAndNestedComments } from "@/utils/commonCommentList";
  725. import PcImagePreviewViewer from "@/components/pcMediaPreview/PcImagePreviewViewer.vue";
  726. const router = useRouter();
  727. const userStore = useUserStore();
  728. // 接口定义
  729. interface UserInfo {
  730. name: string;
  731. avatar: string;
  732. bio: string;
  733. followCount: number;
  734. fansCount: number;
  735. likeCount: number;
  736. }
  737. interface MediaItem {
  738. url: string;
  739. type: "image" | "video";
  740. }
  741. interface ContentItem {
  742. id: number;
  743. title: string;
  744. coverUrl: string;
  745. imagePath?: string;
  746. type: "image" | "video";
  747. viewCount: number;
  748. liulanCount?: number;
  749. isLike?: string;
  750. dianzanCount?: number;
  751. showLabel?: boolean;
  752. labelText?: string;
  753. createTime: string;
  754. mediaList?: MediaItem[];
  755. }
  756. interface DetailItem extends ContentItem {
  757. author?: {
  758. id: number;
  759. name: string;
  760. avatar: string;
  761. };
  762. userAvatar?: string;
  763. userName?: string;
  764. description: string;
  765. publishTime: string;
  766. likeCount: number;
  767. commentCount: number;
  768. isLiked: boolean;
  769. isLike?: string; // 点赞状态:'0'未点赞,'1'已点赞
  770. dianzanCount?: number; // 点赞数量
  771. userId?: string | number; // 发布者ID
  772. phoneId?: string; // 发布者店铺ID
  773. storeUserId?: string | number; // 小店用户ID(用于举报和拉黑)
  774. userType?: number; // 发布者用户类型:1商家,2用户
  775. imagePath?: string; // 图片路径
  776. }
  777. interface RelationUser {
  778. id: number;
  779. name: string;
  780. avatar: string;
  781. description: string;
  782. relationStatus: "following" | "mutual" | "none"; // following: 已关注, mutual: 互相关注, none: 未关注
  783. phoneId?: string; // 用户的 phoneId,用于后续操作
  784. }
  785. // 响应式数据
  786. const activeTab = ref("dynamic");
  787. const contentList = ref<ContentItem[]>([]);
  788. const draftCount = ref(0); // 草稿数量
  789. // 详情 Drawer 相关
  790. const detailDrawerVisible = ref(false);
  791. const currentDetail = ref<DetailItem | null>(null);
  792. // 描述展开/收起状态
  793. const isDescriptionExpanded = ref(false);
  794. // 视频轮播相关
  795. const videoRefs = ref<HTMLVideoElement[]>([]);
  796. const currentCarouselIndex = ref(0);
  797. // 切换描述展开/收起
  798. const toggleDescription = () => {
  799. isDescriptionExpanded.value = !isDescriptionExpanded.value;
  800. };
  801. // 评论相关
  802. const commentDrawerVisible = ref(false);
  803. const commentListData = ref<any[]>([]);
  804. const commentInput = ref("");
  805. const commentSubmitting = ref(false);
  806. const replyingComment = ref<any>(null);
  807. // 关系对话框相关
  808. const relationDialogVisible = ref(false);
  809. const relationActiveTab = ref("friend");
  810. const relationSearch = ref("");
  811. const relationList = ref<RelationUser[]>([]);
  812. const relationPage = ref(1);
  813. const relationPageSize = 5;
  814. const relationTotal = ref(0);
  815. const relationLoading = ref(false);
  816. const relationHasMore = computed(() => relationList.value.length < relationTotal.value && !relationLoading.value);
  817. const relationListScrollRef = ref<HTMLElement | null>(null);
  818. const relationScrollTargets: HTMLElement[] = [];
  819. const onRelationListScroll = (e: Event) => {
  820. const el = e.target as HTMLElement;
  821. if (!el || !relationHasMore.value) return;
  822. const { scrollTop, scrollHeight, clientHeight } = el;
  823. const distanceToBottom = scrollHeight - scrollTop - clientHeight;
  824. if (distanceToBottom < 80) {
  825. loadMoreRelationList();
  826. }
  827. };
  828. const bindRelationScroll = () => {
  829. nextTick(() => {
  830. setTimeout(() => {
  831. const listEl = relationListScrollRef.value;
  832. if (!listEl) return;
  833. unbindRelationScroll();
  834. listEl.addEventListener("scroll", onRelationListScroll, { passive: true });
  835. relationScrollTargets.push(listEl);
  836. const dialogBody = listEl.closest(".el-dialog")?.querySelector(".el-dialog__body") as HTMLElement | null;
  837. if (dialogBody && dialogBody !== listEl) {
  838. dialogBody.addEventListener("scroll", onRelationListScroll, { passive: true });
  839. relationScrollTargets.push(dialogBody);
  840. }
  841. }, 100);
  842. });
  843. };
  844. const unbindRelationScroll = () => {
  845. relationScrollTargets.splice(0, relationScrollTargets.length).forEach(el => {
  846. el.removeEventListener("scroll", onRelationListScroll);
  847. });
  848. };
  849. watch(relationDialogVisible, visible => {
  850. if (visible) bindRelationScroll();
  851. else unbindRelationScroll();
  852. });
  853. //点击本地草稿
  854. const handleDraftClick = () => {
  855. router.push({
  856. path: "/dynamicManagement/draftDynamic"
  857. });
  858. };
  859. // 举报对话框相关
  860. const reportDialogVisible = ref(false);
  861. const reportSubmitting = ref(false);
  862. const reportForm = reactive({
  863. reason: "",
  864. description: "",
  865. fileList: [] as any[],
  866. agreed: false
  867. });
  868. const reportEvidencePreviewVisible = ref(false);
  869. const reportEvidencePreviewUrls = ref<string[]>([]);
  870. const reportEvidencePreviewIndex = ref(0);
  871. // 分享对话框相关
  872. interface ShareFriend {
  873. id: number;
  874. name: string;
  875. avatar: string;
  876. phoneId?: string;
  877. }
  878. const shareDialogVisible = ref(false);
  879. const shareSubmitting = ref(false);
  880. const shareSearch = ref("");
  881. const shareFriendList = ref<ShareFriend[]>([]);
  882. const selectedFriends = ref<number[]>([]);
  883. // 添加好友对话框相关
  884. const addFriendDialogVisible = ref(false);
  885. const addFriendSearchKeyword = ref("");
  886. const addFriendSearchResults = ref<any[]>([]);
  887. const addFriendSearching = ref(false);
  888. // 过滤后的好友列表
  889. const filteredShareFriendList = computed(() => {
  890. if (shareSearch.value == null || shareSearch.value === "") {
  891. return shareFriendList.value;
  892. }
  893. const keyword = String(shareSearch.value).toLowerCase();
  894. return shareFriendList.value.filter(friend => (friend.name ?? "").toLowerCase().includes(keyword));
  895. });
  896. // 用户信息
  897. const userInfo = reactive<UserInfo>({
  898. name: "白己的流浪主页",
  899. avatar: "",
  900. bio: "一家好吃的火锅店",
  901. followCount: 19,
  902. fansCount: 10,
  903. likeCount: 10
  904. });
  905. // 头像优先取缓存 geeker-user 的 headImg
  906. const cachedHeadImg = computed(() => localGet("geeker-user")?.userInfo?.headImg || userInfo.avatar || "");
  907. // 对话框标题
  908. const relationDialogTitle = computed(() => {
  909. const titles = {
  910. friend: "好友",
  911. follow: "关注",
  912. fans: "粉丝"
  913. };
  914. return titles[relationActiveTab.value as keyof typeof titles];
  915. });
  916. // 过滤后的关系列表
  917. const filteredRelationList = computed(() => {
  918. if (relationSearch.value == null || relationSearch.value === "") {
  919. return relationList.value;
  920. }
  921. const keyword = String(relationSearch.value).toLowerCase();
  922. return relationList.value.filter(
  923. user => (user.name ?? "").toLowerCase().includes(keyword) || (user.description ?? "").toLowerCase().includes(keyword)
  924. );
  925. });
  926. // 判断当前详情是否是当前用户的动态
  927. const isMyDynamic = computed(() => {
  928. if (!currentDetail.value) return false;
  929. // 获取当前用户的 storeId
  930. const currentUserStoreId = userStore.userInfo?.storeId;
  931. // 获取动态的 storeUserId 或 userId
  932. const dynamicStoreUserId = currentDetail.value.storeUserId || currentDetail.value.userId;
  933. // 通过 storeId 判断是否是当前用户的动态
  934. const result = currentUserStoreId == dynamicStoreUserId;
  935. console.log("是否是自己发布的作品:", result, {
  936. currentUserStoreId,
  937. dynamicStoreUserId
  938. });
  939. return result;
  940. });
  941. // 标签切换
  942. const handleTabClick = (pane: any) => {
  943. const tabName = pane.props.name;
  944. if (tabName === "liked") {
  945. getDianZan();
  946. } else if (tabName === "dynamic") {
  947. getDyanmicList();
  948. }
  949. };
  950. // 点击卡片
  951. const handleCardClick = async (item: any) => {
  952. try {
  953. // 重置描述展开状态
  954. isDescriptionExpanded.value = false;
  955. // 解析媒体列表(支持多张图片和视频)
  956. const mediaUrl = item.imagePath || "";
  957. const mediaUrls = mediaUrl
  958. .split(",")
  959. .map((url: string) => url.trim())
  960. .filter((url: string) => url);
  961. const mediaList: MediaItem[] = mediaUrls.map((url: string) => ({
  962. url,
  963. type: url.toLowerCase().endsWith(".mp4") ? ("video" as const) : ("image" as const)
  964. }));
  965. const firstUrl = mediaUrls[0] || "";
  966. const isVideo = firstUrl.toLowerCase().endsWith(".mp4");
  967. currentDetail.value = {
  968. ...item,
  969. mediaList,
  970. coverUrl: firstUrl,
  971. type: isVideo ? "video" : "image",
  972. author: {
  973. id: item.userId || 0,
  974. name: item.userName || "用户",
  975. avatar: item.userAvatar || item.userImage || ""
  976. },
  977. userAvatar: item.userAvatar || item.userImage || "",
  978. userName: item.userName || "用户",
  979. description: item.context || item.title || "",
  980. publishTime: item.createTime || item.createdTime || "",
  981. likeCount: item.likeCount || item.praiseNum || 0,
  982. commentCount: item.commentCount || 0,
  983. isLiked: item.isLiked || false
  984. };
  985. detailDrawerVisible.value = true;
  986. // 重置轮播索引
  987. currentCarouselIndex.value = 0;
  988. } catch (error) {
  989. console.error("加载详情失败:", error);
  990. ElMessage.error("加载详情失败");
  991. }
  992. };
  993. // 关闭详情
  994. const handleCloseDetail = () => {
  995. detailDrawerVisible.value = false;
  996. // 暂停所有视频
  997. videoRefs.value.forEach(video => {
  998. if (video && !video.paused) {
  999. video.pause();
  1000. }
  1001. });
  1002. setTimeout(() => {
  1003. currentDetail.value = null;
  1004. videoRefs.value = [];
  1005. }, 300);
  1006. };
  1007. // 设置视频引用
  1008. const setVideoRef = (el: any, index: number) => {
  1009. if (el) {
  1010. videoRefs.value[index] = el as HTMLVideoElement;
  1011. }
  1012. };
  1013. // 轮播切换
  1014. const handleCarouselChange = (newIndex: number) => {
  1015. // 暂停所有视频
  1016. videoRefs.value.forEach(video => {
  1017. if (video && !video.paused) {
  1018. video.pause();
  1019. }
  1020. });
  1021. currentCarouselIndex.value = newIndex;
  1022. };
  1023. // 视频播放
  1024. const handleVideoPlay = (index: number) => {
  1025. // 暂停其他视频
  1026. videoRefs.value.forEach((video, i) => {
  1027. if (i !== index && video && !video.paused) {
  1028. video.pause();
  1029. }
  1030. });
  1031. };
  1032. // 查看用户主页
  1033. const handleViewUserProfile = () => {
  1034. // ElMessage.info("查看用户主页功能开发中");
  1035. };
  1036. // 详情页点赞
  1037. const handleDetailLike = async () => {
  1038. if (!currentDetail.value) return;
  1039. try {
  1040. // 获取当前用户的手机号,并在前面拼接 "store_"
  1041. const phone = userStore.userInfo?.phone || "";
  1042. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1043. const params = {
  1044. userId: currentUserPhoneId, // 当前用户phoneId
  1045. huifuId: currentDetail.value.id, // 动态ID
  1046. type: 2 // 2表示点赞动态
  1047. };
  1048. // 根据当前点赞状态调用不同的接口
  1049. if (currentDetail.value.isLike == "1") {
  1050. // 已点赞,调用取消点赞接口
  1051. await unlikeDynamicNew(params);
  1052. currentDetail.value.isLike = "0";
  1053. currentDetail.value.dianzanCount = Math.max(0, (currentDetail.value.dianzanCount || 1) - 1);
  1054. } else {
  1055. // 未点赞,调用点赞接口
  1056. await likeDynamicNew(params);
  1057. currentDetail.value.isLike = "1";
  1058. currentDetail.value.dianzanCount = (currentDetail.value.dianzanCount || 0) + 1;
  1059. }
  1060. // 同步更新列表中的数据
  1061. const listItem = contentList.value.find(item => item.id === currentDetail.value?.id);
  1062. if (listItem) {
  1063. listItem.isLike = currentDetail.value.isLike;
  1064. listItem.dianzanCount = currentDetail.value.dianzanCount;
  1065. }
  1066. // 同步更新点赞列表中的数据
  1067. const dianZanItem = dianZanList.value.find(item => item.id === currentDetail.value?.id);
  1068. if (dianZanItem) {
  1069. dianZanItem.isLike = currentDetail.value.isLike;
  1070. dianZanItem.dianzanCount = currentDetail.value.dianzanCount;
  1071. }
  1072. ElMessage.success(currentDetail.value.isLike == "1" ? "点赞成功" : "取消点赞");
  1073. } catch (error) {
  1074. console.error("点赞操作失败:", error);
  1075. ElMessage.error("操作失败");
  1076. }
  1077. };
  1078. // 分享
  1079. const handleShare = async () => {
  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. // 确认分享
  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. try {
  1144. shareSubmitting.value = true;
  1145. // 调用 addTransferCount 接口,传递动态 id
  1146. const res: any = await addTransferCount({
  1147. id: currentDetail.value.id
  1148. });
  1149. if (res.code === 200) {
  1150. ElMessage.success(`已分享给 ${selectedFriends.value.length} 位好友`);
  1151. shareDialogVisible.value = false;
  1152. // 可以在这里更新动态的分享数(如果需要的话)
  1153. console.log("分享成功,动态ID:", currentDetail.value.id);
  1154. } else {
  1155. ElMessage.error(res.message || "分享失败");
  1156. }
  1157. } catch (error) {
  1158. console.error("分享失败:", error);
  1159. ElMessage.error("分享失败");
  1160. } finally {
  1161. shareSubmitting.value = false;
  1162. }
  1163. };
  1164. // 关闭分享对话框
  1165. const handleCloseShareDialog = () => {
  1166. shareSearch.value = "";
  1167. selectedFriends.value = [];
  1168. shareFriendList.value = [];
  1169. };
  1170. // 显示评论
  1171. const handleShowComments = async () => {
  1172. if (!currentDetail.value) return;
  1173. commentDrawerVisible.value = true;
  1174. await loadCommentList();
  1175. };
  1176. // 加载评论列表
  1177. const loadCommentList = async () => {
  1178. if (!currentDetail.value) return;
  1179. try {
  1180. const params: CommentListParams = {
  1181. pageNum: 1,
  1182. pageSize: 100,
  1183. sourceId: currentDetail.value.id,
  1184. sourceType: 2
  1185. };
  1186. const uid = userStore.userInfo?.userId ?? userStore.userInfo?.id;
  1187. if (uid !== undefined && uid !== null && uid !== "") {
  1188. const n = Number(uid);
  1189. if (Number.isFinite(n)) params.userId = Math.trunc(n);
  1190. }
  1191. const res: any = await commentList(params);
  1192. if (res.code === 200) {
  1193. const list = normalizeCommonCommentListResponse(res.data);
  1194. commentListData.value = list;
  1195. if (currentDetail.value) {
  1196. const raw = res.data;
  1197. const pageTotal =
  1198. raw && typeof raw === "object" && !Array.isArray(raw) && typeof (raw as { total?: number }).total === "number"
  1199. ? (raw as { total: number }).total
  1200. : undefined;
  1201. currentDetail.value.commentCount =
  1202. pageTotal !== undefined && pageTotal >= 0 ? pageTotal : countTopAndNestedComments(list);
  1203. }
  1204. console.log("评论列表:", commentListData.value);
  1205. }
  1206. } catch (error) {
  1207. console.error("加载评论列表失败:", error);
  1208. }
  1209. };
  1210. // 点赞评论
  1211. const handleLikeComment = async (comment: any) => {
  1212. console.log(comment);
  1213. try {
  1214. // 获取当前用户的手机号,并在前面拼接 "store_"
  1215. const phone = userStore.userInfo?.phone || "";
  1216. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1217. const params = {
  1218. userId: currentUserPhoneId, // 当前用户phoneId
  1219. huifuId: comment.id, // 评论ID
  1220. type: 1 // 1表示点赞评论
  1221. };
  1222. // 根据当前点赞状态调用不同的接口
  1223. if (comment.isLiked) {
  1224. // 已点赞,调用取消点赞接口
  1225. await unlikeDynamicNew(params);
  1226. } else {
  1227. // 未点赞,调用点赞接口
  1228. await likeDynamicNew(params);
  1229. }
  1230. // 切换点赞状态
  1231. comment.isLiked = !comment.isLiked;
  1232. comment.likeCount = comment.isLiked ? (comment.likeCount || 0) + 1 : Math.max(0, (comment.likeCount || 1) - 1);
  1233. ElMessage.success(comment.isLiked ? "点赞成功" : "取消点赞");
  1234. } catch (error) {
  1235. console.error("点赞评论失败:", error);
  1236. ElMessage.error("操作失败");
  1237. }
  1238. };
  1239. // 回复评论
  1240. const handleReplyComment = (comment: any) => {
  1241. replyingComment.value = comment;
  1242. commentInput.value = ``;
  1243. // 聚焦到输入框
  1244. setTimeout(() => {
  1245. const textarea = document.querySelector(".comment-input-wrapper textarea") as HTMLTextAreaElement;
  1246. if (textarea) {
  1247. textarea.focus();
  1248. }
  1249. }, 100);
  1250. };
  1251. // 取消回复
  1252. const handleCancelReply = () => {
  1253. replyingComment.value = null;
  1254. commentInput.value = "";
  1255. };
  1256. // 提交评论
  1257. const handleSubmitComment = async () => {
  1258. if (!commentInput.value.trim()) {
  1259. ElMessage.warning("请输入评论内容");
  1260. return;
  1261. }
  1262. if (!currentDetail.value) {
  1263. ElMessage.error("动态信息不存在");
  1264. return;
  1265. }
  1266. try {
  1267. commentSubmitting.value = true;
  1268. const phone = userStore.userInfo?.phone || "";
  1269. const phoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1270. // 判断是回复评论还是评论动态
  1271. const isReply = !!replyingComment.value;
  1272. const params: any = {
  1273. replyId: isReply ? replyingComment.value.id : "", // 回复评论时传 parentId,否则为 0
  1274. commentContent: commentInput.value,
  1275. businessType: "2",
  1276. businessId: String(currentDetail.value.id), // 对应请求体 sourceId(动态 id)
  1277. storeId: userStore.userInfo?.storeId || userStore.userInfo?.createdId, // 对应 merchantId
  1278. userId: userStore.userInfo?.userId ?? userStore.userInfo?.id ?? "",
  1279. phoneId: phoneId
  1280. };
  1281. const res: any = await saveComment(params);
  1282. if (res.code === 200) {
  1283. ElMessage.success(isReply ? "回复成功" : "评论成功");
  1284. commentInput.value = "";
  1285. replyingComment.value = null;
  1286. await loadCommentList();
  1287. } else {
  1288. ElMessage.error(res.message || (isReply ? "回复失败" : "评论失败"));
  1289. }
  1290. } catch (error) {
  1291. console.error("提交评论失败:", error);
  1292. ElMessage.error(replyingComment.value ? "回复失败" : "评论失败");
  1293. } finally {
  1294. commentSubmitting.value = false;
  1295. }
  1296. };
  1297. // 编辑动态
  1298. const handleEditDynamic = () => {
  1299. if (!currentDetail.value) return;
  1300. // 关闭详情页
  1301. detailDrawerVisible.value = false;
  1302. // 跳转到编辑页面
  1303. router.push({
  1304. path: "/dynamicManagement/publishDynamic",
  1305. query: { id: currentDetail.value.id }
  1306. });
  1307. };
  1308. // 删除动态
  1309. const handleDeleteDynamic = async () => {
  1310. if (!currentDetail.value) return;
  1311. try {
  1312. await ElMessageBox.confirm("确定要删除这条动态吗?删除后将无法恢复。", "删除确认", {
  1313. confirmButtonText: "确定删除",
  1314. cancelButtonText: "取消",
  1315. type: "warning",
  1316. confirmButtonClass: "el-button--danger"
  1317. }).then(async () => {
  1318. if (!currentDetail.value) return;
  1319. const res: any = await deleteDynamicsById({ id: currentDetail.value.id });
  1320. if (res.code === 200) {
  1321. ElMessage.success("删除成功");
  1322. detailDrawerVisible.value = false;
  1323. const index = contentList.value.findIndex(item => item.id === currentDetail.value?.id);
  1324. if (index > -1) {
  1325. contentList.value.splice(index, 1);
  1326. }
  1327. }
  1328. });
  1329. } catch {
  1330. // 用户取消删除
  1331. }
  1332. };
  1333. // 举报动态
  1334. const handleReportDynamic = () => {
  1335. reportDialogVisible.value = true;
  1336. };
  1337. // 拉黑用户(点击菜单项)
  1338. const handleBlockUserClick = () => {
  1339. handleBlockUser(false);
  1340. };
  1341. // 拉黑用户
  1342. const handleBlockUser = async (skipConfirm: boolean = false) => {
  1343. if (!currentDetail.value) return;
  1344. try {
  1345. // 如果不跳过确认,显示确认对话框
  1346. if (!skipConfirm) {
  1347. await ElMessageBox.confirm("拉黑后将不再看到该用户的动态,确定要拉黑吗?", "拉黑确认", {
  1348. confirmButtonText: "确定拉黑",
  1349. cancelButtonText: "取消",
  1350. type: "warning"
  1351. });
  1352. }
  1353. // 获取当前用户信息
  1354. const currentUserId = userStore.userInfo?.id || userStore.userInfo?.userId || userStore.userInfo?.storeId || "";
  1355. const currentUserType = userStore.userInfo?.userType || userStore.userInfo?.type || 1; // 用户类型:1商家,2用户,默认1
  1356. // 获取被拉黑用户类型(从 phoneId 解析)
  1357. const getUserTypeFromPhoneId = (phoneId: string | undefined): number => {
  1358. if (!phoneId) return 1; // 默认商家
  1359. const prefix = phoneId.split("_")[0]; // 截取 "_" 之前的文字
  1360. return prefix === "store" ? 1 : 2; // store = 商家(1), 其他 = 用户(2)
  1361. };
  1362. const blockedUserType = getUserTypeFromPhoneId(currentDetail.value.phoneId) || 1;
  1363. console.log("当前用户信息:", userStore.userInfo);
  1364. console.log("当前用户类型:", currentUserType);
  1365. console.log("被拉黑用户类型:", blockedUserType);
  1366. console.log("动态详情:", currentDetail.value);
  1367. // 调用拉黑接口
  1368. await blockUser({
  1369. blockerType: currentUserType, // 拉黑者类型(当前登录用户类型)
  1370. blockedType: blockedUserType, // 被拉黑者类型(从 phoneId 解析)
  1371. blockerId: currentUserId, // 拉黑者ID(当前登录用户)
  1372. blockedId: currentDetail.value.storeUserId || currentDetail.value.userId || "" // 被拉黑者ID
  1373. });
  1374. if (!skipConfirm) {
  1375. ElMessage.success("已拉黑该用户");
  1376. }
  1377. detailDrawerVisible.value = false;
  1378. // 从列表中移除该用户的动态
  1379. const index = contentList.value.findIndex(item => item.id === currentDetail.value?.id);
  1380. if (index > -1) {
  1381. contentList.value.splice(index, 1);
  1382. }
  1383. } catch (error) {
  1384. if (!skipConfirm) {
  1385. // 单独拉黑时,用户取消操作或接口失败
  1386. console.error("拉黑失败:", error);
  1387. if (error !== "cancel") {
  1388. ElMessage.error("拉黑失败");
  1389. }
  1390. } else {
  1391. // 举报后自动拉黑失败,抛出错误
  1392. throw error;
  1393. }
  1394. }
  1395. };
  1396. // 举报图片预览
  1397. const handleReportPreview = (uploadFile: any) => {
  1398. const list = (reportForm.fileList || []).map((f: any) => String(f.url || "").trim()).filter(Boolean);
  1399. const url = String(uploadFile?.url || "").trim();
  1400. const urls = list.length ? list : url ? [url] : [];
  1401. if (!urls.length) return;
  1402. const idx = url ? urls.indexOf(url) : 0;
  1403. reportEvidencePreviewUrls.value = urls;
  1404. reportEvidencePreviewIndex.value = Math.max(0, idx);
  1405. reportEvidencePreviewVisible.value = true;
  1406. };
  1407. // 移除举报图片
  1408. const handleReportRemove = (uploadFile: any, uploadFiles: any[]) => {
  1409. // 已由 v-model:file-list 自动处理
  1410. };
  1411. // 举报图片上传前验证
  1412. const beforeReportUpload = (file: File) => {
  1413. const isImage = file.type.startsWith("image/");
  1414. const isLt20M = file.size / 1024 / 1024 < 20;
  1415. if (!isImage) {
  1416. ElMessage.error("只能上传图片文件!");
  1417. return false;
  1418. }
  1419. if (!isLt20M) {
  1420. ElMessage.error("图片大小不能超过 20MB!");
  1421. return false;
  1422. }
  1423. return true;
  1424. };
  1425. // 自定义举报图片上传
  1426. const handleReportUpload = async (options: any) => {
  1427. const { file } = options;
  1428. try {
  1429. // TODO: 集成真实上传接口时,取消下面的注释
  1430. // const uploadFormData = new FormData();
  1431. // uploadFormData.append('file', file);
  1432. // const res = await uploadDynamicImage(uploadFormData);
  1433. // // 上传成功后更新文件列表
  1434. // return res;
  1435. // 临时方案:使用 FileReader 模拟上传
  1436. return new Promise((resolve, reject) => {
  1437. const reader = new FileReader();
  1438. reader.onload = e => {
  1439. resolve({
  1440. url: e.target?.result
  1441. });
  1442. };
  1443. reader.onerror = reject;
  1444. reader.readAsDataURL(file);
  1445. });
  1446. } catch (error) {
  1447. ElMessage.error("图片上传失败");
  1448. throw error;
  1449. }
  1450. };
  1451. // 提交举报
  1452. const handleSubmitReport = async () => {
  1453. // 验证表单
  1454. if (!reportForm.reason) {
  1455. ElMessage.warning("请选择举报原因");
  1456. return;
  1457. }
  1458. if (!reportForm.description.trim()) {
  1459. ElMessage.warning("请填写详细描述");
  1460. return;
  1461. }
  1462. if (!reportForm.agreed) {
  1463. ElMessage.warning("请同意发票用户协议");
  1464. return;
  1465. }
  1466. reportSubmitting.value = true;
  1467. try {
  1468. // TODO: 集成真实接口时,取消下面的注释
  1469. // await reportDynamic({
  1470. // dynamicId: currentDetail.value?.id,
  1471. // reason: reportForm.reason,
  1472. // description: reportForm.description,
  1473. // images: reportForm.fileList.map(f => f.url)
  1474. // });
  1475. // 模拟提交延迟
  1476. await new Promise(resolve => setTimeout(resolve, 1000));
  1477. ElMessage.success("举报提交成功,我们会尽快处理");
  1478. reportDialogVisible.value = false;
  1479. } catch (error) {
  1480. ElMessage.error("举报提交失败");
  1481. } finally {
  1482. reportSubmitting.value = false;
  1483. }
  1484. };
  1485. // 关闭举报对话框
  1486. const handleCloseReportDialog = () => {
  1487. reportForm.reason = "";
  1488. reportForm.description = "";
  1489. reportForm.fileList = [];
  1490. reportForm.agreed = false;
  1491. };
  1492. // 加载用户主页信息
  1493. const loadUserInfo = async () => {
  1494. try {
  1495. // 获取当前用户的手机号,并在前面拼接 "store_"
  1496. const phone = userStore.userInfo?.phone || "";
  1497. const phoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1498. // 调用接口获取主页信息
  1499. const res: any = await getHomePageInfo({
  1500. phoneId: phoneId
  1501. });
  1502. if (res.code === 200 && res.data) {
  1503. userInfo.followCount = res.data.friendNum;
  1504. userInfo.fansCount = res.data.followNum;
  1505. userInfo.likeCount = res.data.fansNum;
  1506. console.log("加载用户信息成功:", userInfo);
  1507. }
  1508. } catch (error) {
  1509. console.error("加载用户信息失败:", error);
  1510. }
  1511. };
  1512. // 判断是否是视频项
  1513. const isVideoItem = (item: any) => {
  1514. if (!item.imagePath) return false;
  1515. const files = item.imagePath
  1516. .split(",")
  1517. .map((url: string) => url.trim())
  1518. .filter((url: string) => url);
  1519. const firstFile = files[0] || "";
  1520. return firstFile.toLowerCase().endsWith(".mp4") || firstFile.toLowerCase().includes(".mp4");
  1521. };
  1522. // 获取封面图片
  1523. const getCoverImage = (item: any) => {
  1524. console.log(item.imagePath);
  1525. if (!item.imagePath) return "";
  1526. const files = item.imagePath
  1527. .split(",")
  1528. .map((url: string) => url.trim())
  1529. .filter((url: string) => url);
  1530. // 检查第一个文件是否是视频
  1531. const firstFile = files[0] || "";
  1532. const isVideo = firstFile.toLowerCase().endsWith(".mp4") || firstFile.toLowerCase().includes(".mp4");
  1533. // 如果第一个文件是视频,取第二个文件(jpg缩略图)
  1534. if (isVideo && files.length > 1) {
  1535. return files[1]; // 第二个是jpg缩略图
  1536. }
  1537. // 如果是图片或只有一个文件,取第一个
  1538. return files[0] || "";
  1539. };
  1540. // 加载草稿数量
  1541. const loadDraftCount = async () => {
  1542. try {
  1543. // 获取当前用户的手机号,并在前面拼接 "store_"
  1544. const phone = userStore.userInfo?.phone || "";
  1545. const phoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1546. // 调用接口获取草稿列表
  1547. const res: any = await getUserDraftDynamics({
  1548. phoneId: phoneId,
  1549. page: 1,
  1550. size: 1000
  1551. });
  1552. if (res.code === 200) {
  1553. const draftList = res.data?.records || res.data?.list || [];
  1554. draftCount.value = draftList.length;
  1555. console.log("加载草稿数量成功:", draftCount.value);
  1556. }
  1557. } catch (error) {
  1558. console.error("加载草稿数量失败:", error);
  1559. }
  1560. };
  1561. const dianZanList = ref<any[]>([]);
  1562. const getDianZan = async () => {
  1563. const phone = userStore.userInfo?.phone || "";
  1564. const phoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1565. const res: any = await getDianZanList({
  1566. phoneId: phoneId
  1567. });
  1568. if (res.code === 200) {
  1569. dianZanList.value = res.data;
  1570. }
  1571. };
  1572. const getDyanmicList = async () => {
  1573. const phone = userStore.userInfo?.phone || "";
  1574. const phoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1575. const res: any = await getUserDynamics({
  1576. phoneId: phoneId,
  1577. type: 2, // 2表示动态类型
  1578. myself: 1, // 1表示自己的动态
  1579. page: 1,
  1580. size: 1000
  1581. });
  1582. if (res.code === 200) {
  1583. const dataList = res.data?.records || res.data?.list || [];
  1584. contentList.value = dataList.map((item: any) => ({
  1585. id: item.id,
  1586. title: item.title || item.context || "",
  1587. coverUrl: item.imagePath ? item.imagePath.split(",")[0] : "", // 取第一张图片作为封面
  1588. type: item.imagePath && item.imagePath.toLowerCase().includes(".mp4") ? "video" : "image",
  1589. viewCount: item.viewCount || item.browseNum || 0,
  1590. showLabel: false,
  1591. labelText: "",
  1592. createTime: item.createTime || item.createdTime || new Date().toISOString(),
  1593. // 保留原始数据,用于详情展示
  1594. ...item
  1595. }));
  1596. }
  1597. };
  1598. // 打开关系对话框
  1599. const openRelationDialog = (type: "friend" | "follow" | "fans") => {
  1600. relationActiveTab.value = type;
  1601. if (relationActiveTab.value == "friend") {
  1602. handleFriendList();
  1603. } else if (relationActiveTab.value == "follow") {
  1604. handleFollowList();
  1605. } else {
  1606. handleFansList();
  1607. }
  1608. relationDialogVisible.value = true;
  1609. };
  1610. // 关系标签切换
  1611. const handleRelationTabClick = (tab: any) => {
  1612. relationSearch.value = "";
  1613. // 从 tab 对象中获取当前点击的标签名称
  1614. const tabName = tab?.props?.name || tab?.paneName;
  1615. console.log("切换标签:", tabName);
  1616. if (tabName === "friend") {
  1617. handleFriendList();
  1618. } else if (tabName === "follow") {
  1619. handleFollowList();
  1620. } else if (tabName === "fans") {
  1621. handleFansList();
  1622. }
  1623. };
  1624. //好友列表
  1625. const mapRecordToRelationUser = (item: any, defaultStatus: "following" | "mutual" | "none" = "none"): RelationUser => ({
  1626. id: item.id || item.userId,
  1627. name: item.userName || item.nickname || item.name || "用户",
  1628. avatar: item.image || item.userImage || item.avatar || item.headImg || "",
  1629. description: item.blurb || item.accountBlurb || item.description || item.bio || item.signature || "",
  1630. relationStatus: item.isFollowThis === 1 ? ("mutual" as const) : defaultStatus,
  1631. phoneId: item.phoneId || item.fansId || ""
  1632. });
  1633. const handleFriendList = async (append = false) => {
  1634. if (!append) {
  1635. relationPage.value = 1;
  1636. relationList.value = [];
  1637. }
  1638. const phone = userStore.userInfo?.phone || "";
  1639. const fansId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1640. relationLoading.value = true;
  1641. try {
  1642. const res: any = await getMutualAttention({
  1643. page: relationPage.value,
  1644. size: relationPageSize,
  1645. fansId,
  1646. name: relationSearch.value || ""
  1647. });
  1648. if (res.code == 200) {
  1649. const data = res.data;
  1650. const dataList = data?.records || data?.list || data || [];
  1651. const mapped = dataList.map((item: any) => mapRecordToRelationUser(item, "mutual"));
  1652. if (append) relationList.value.push(...mapped);
  1653. else relationList.value = mapped;
  1654. const currentLen = relationList.value.length;
  1655. if (dataList.length === 0) relationTotal.value = currentLen;
  1656. else if (typeof data?.total === "number" && currentLen >= data.total) relationTotal.value = data.total;
  1657. else relationTotal.value = currentLen + 1;
  1658. }
  1659. } finally {
  1660. relationLoading.value = false;
  1661. }
  1662. };
  1663. const handleFollowList = async (append = false) => {
  1664. if (!append) {
  1665. relationPage.value = 1;
  1666. relationList.value = [];
  1667. }
  1668. const phone = userStore.userInfo?.phone || "";
  1669. const fansId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1670. relationLoading.value = true;
  1671. try {
  1672. const res: any = await getMyFollowed({
  1673. page: relationPage.value,
  1674. size: relationPageSize,
  1675. fansId,
  1676. name: relationSearch.value || ""
  1677. });
  1678. if (res.code === 200) {
  1679. const data = res.data;
  1680. const dataList = data?.records || data?.list || data || [];
  1681. const mapped = dataList.map((item: any) => mapRecordToRelationUser(item, "following"));
  1682. if (append) relationList.value.push(...mapped);
  1683. else relationList.value = mapped;
  1684. const currentLen = relationList.value.length;
  1685. if (dataList.length === 0) relationTotal.value = currentLen;
  1686. else if (typeof data?.total === "number" && currentLen >= data.total) relationTotal.value = data.total;
  1687. else relationTotal.value = currentLen + 1;
  1688. }
  1689. } finally {
  1690. relationLoading.value = false;
  1691. }
  1692. };
  1693. const handleFansList = async (append = false) => {
  1694. if (!append) {
  1695. relationPage.value = 1;
  1696. relationList.value = [];
  1697. }
  1698. const phone = userStore.userInfo?.phone || "";
  1699. const fansId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1700. const name = relationSearch.value || "";
  1701. const listParams = { page: append ? relationPage.value : 1, size: append ? relationPageSize : 1000, fansId, name };
  1702. relationLoading.value = true;
  1703. try {
  1704. let dataList: any[] = [];
  1705. if (!append) {
  1706. const res1: any = await getMyStoreFans(listParams);
  1707. const res2: any = await getMyUserFans(listParams);
  1708. const records1 = res1?.code === 200 ? res1.data?.records || res1.data?.list || res1.data || [] : [];
  1709. const records2 = res2?.code === 200 ? res2.data?.records || res2.data?.list || res2.data || [] : [];
  1710. dataList = [...records1, ...records2];
  1711. const createdId = localGet("createdId") || userStore.userInfo?.storeId || "";
  1712. if (createdId) dataList = dataList.filter((item: any) => String(item.id) !== String(createdId));
  1713. } else {
  1714. const res: any = await getMyUserFans(listParams);
  1715. if (res.code === 200) {
  1716. const data = res.data;
  1717. dataList = data?.records || data?.list || data || [];
  1718. const createdId = localGet("createdId") || userStore.userInfo?.storeId || "";
  1719. if (createdId) dataList = dataList.filter((item: any) => String(item.id) !== String(createdId));
  1720. }
  1721. }
  1722. if (!append || dataList.length > 0) {
  1723. const mapped = dataList.map((item: any) => mapRecordToRelationUser(item, "none"));
  1724. if (append) relationList.value.push(...mapped);
  1725. else relationList.value = mapped;
  1726. const currentLen = relationList.value.length;
  1727. if (dataList.length === 0) relationTotal.value = currentLen;
  1728. else if (!append) relationTotal.value = currentLen;
  1729. else relationTotal.value = currentLen + 1;
  1730. }
  1731. } finally {
  1732. relationLoading.value = false;
  1733. }
  1734. };
  1735. const loadMoreRelationList = () => {
  1736. if (!relationHasMore.value) return;
  1737. relationPage.value++;
  1738. if (relationActiveTab.value === "friend") handleFriendList(true);
  1739. else if (relationActiveTab.value === "follow") handleFollowList(true);
  1740. else handleFansList(true);
  1741. };
  1742. // 搜索关系列表
  1743. const handleRelationSearch = () => {
  1744. if (relationActiveTab.value === "friend") {
  1745. handleFriendList();
  1746. } else if (relationActiveTab.value === "follow") {
  1747. handleFollowList();
  1748. } else if (relationActiveTab.value === "fans") {
  1749. handleFansList();
  1750. }
  1751. };
  1752. // 关注用户
  1753. const handleFollow = async (user: RelationUser) => {
  1754. try {
  1755. // TODO: 集成真实接口时,取消下面的注释
  1756. // await followUser({ userId: user.id });
  1757. user.relationStatus = "following";
  1758. ElMessage.success("关注成功");
  1759. // 更新用户统计信息
  1760. if (relationActiveTab.value === "fans") {
  1761. userInfo.followCount++;
  1762. }
  1763. } catch (error) {
  1764. ElMessage.error("关注失败");
  1765. }
  1766. };
  1767. // 取消关注用户
  1768. const handleUnfollow = async (user: RelationUser) => {
  1769. try {
  1770. await ElMessageBox.confirm("确定要取消关注吗?", "提示", {
  1771. confirmButtonText: "确定",
  1772. cancelButtonText: "取消",
  1773. type: "warning"
  1774. });
  1775. // TODO: 集成真实接口时,取消下面的注释
  1776. // await unfollowUser({ userId: user.id });
  1777. user.relationStatus = "none";
  1778. ElMessage.success("已取消关注");
  1779. // 更新用户统计信息
  1780. if (relationActiveTab.value === "follow") {
  1781. userInfo.followCount--;
  1782. }
  1783. } catch {
  1784. // 用户取消操作
  1785. }
  1786. };
  1787. // 关闭关系对话框
  1788. const handleCloseRelationDialog = () => {
  1789. relationSearch.value = "";
  1790. relationList.value = [];
  1791. relationPage.value = 1;
  1792. relationTotal.value = 0;
  1793. unbindRelationScroll();
  1794. };
  1795. // 打开添加好友对话框
  1796. const addFriend = () => {
  1797. addFriendDialogVisible.value = true;
  1798. };
  1799. // 关闭添加好友对话框
  1800. const handleCloseAddFriendDialog = () => {
  1801. // 清空防抖定时器
  1802. if (searchDebounceTimer) {
  1803. clearTimeout(searchDebounceTimer);
  1804. searchDebounceTimer = null;
  1805. }
  1806. addFriendSearchKeyword.value = "";
  1807. addFriendSearchResults.value = [];
  1808. addFriendSearching.value = false;
  1809. };
  1810. // 搜索输入防抖定时器
  1811. let searchDebounceTimer: NodeJS.Timeout | null = null;
  1812. // 搜索输入处理(带防抖)
  1813. const handleSearchInput = () => {
  1814. // 清空之前的定时器
  1815. if (searchDebounceTimer) {
  1816. clearTimeout(searchDebounceTimer);
  1817. }
  1818. // 如果输入框为空,清空搜索结果
  1819. if (!addFriendSearchKeyword.value.trim()) {
  1820. addFriendSearchResults.value = [];
  1821. return;
  1822. }
  1823. // 设置防抖,500ms后执行搜索
  1824. searchDebounceTimer = setTimeout(() => {
  1825. handleSearchFriend();
  1826. }, 200);
  1827. };
  1828. // 搜索好友
  1829. const handleSearchFriend = async () => {
  1830. if (!addFriendSearchKeyword.value.trim()) {
  1831. addFriendSearchResults.value = [];
  1832. return;
  1833. }
  1834. addFriendSearching.value = true;
  1835. addFriendSearchResults.value = [];
  1836. try {
  1837. const phone = userStore.userInfo?.phone || "";
  1838. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1839. const userId = userStore.userInfo?.id || userStore.userInfo?.userId || "";
  1840. const res: any = await getStoreAndUserByName({
  1841. page: 1,
  1842. size: 100,
  1843. phoneId: currentUserPhoneId,
  1844. userId: userId,
  1845. searchName: addFriendSearchKeyword.value.trim()
  1846. });
  1847. if (res && res.code === 200) {
  1848. // 处理搜索结果数据
  1849. const dataList = res.data?.records || [];
  1850. addFriendSearchResults.value = dataList;
  1851. } else {
  1852. ElMessage.error(res?.msg || res?.message || "搜索失败");
  1853. }
  1854. } catch (error: any) {
  1855. console.error("搜索好友失败:", error);
  1856. ElMessage.error(error?.message || "搜索失败,请重试");
  1857. } finally {
  1858. addFriendSearching.value = false;
  1859. }
  1860. };
  1861. // 清空搜索
  1862. const handleClearSearch = () => {
  1863. // 清空防抖定时器
  1864. if (searchDebounceTimer) {
  1865. clearTimeout(searchDebounceTimer);
  1866. searchDebounceTimer = null;
  1867. }
  1868. addFriendSearchResults.value = [];
  1869. };
  1870. // 在搜索结果中关注用户
  1871. const handleFollowInSearch = async (user: any) => {
  1872. try {
  1873. const phone = userStore.userInfo?.phone || "";
  1874. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1875. if (!user.phoneId) {
  1876. ElMessage.error("用户信息不完整");
  1877. return;
  1878. }
  1879. await toggleFollowUser({
  1880. followedId: user.phoneId,
  1881. fansId: currentUserPhoneId,
  1882. fansType: 2
  1883. });
  1884. // 更新关注状态
  1885. user.isFollowed = 1;
  1886. user.isFollowThis = 1;
  1887. ElMessage.success("关注成功");
  1888. } catch (error: any) {
  1889. console.error("关注失败:", error);
  1890. ElMessage.error(error?.message || "关注失败,请重试");
  1891. }
  1892. };
  1893. // 在搜索结果中取消关注用户
  1894. const handleUnfollowInSearch = async (user: any) => {
  1895. try {
  1896. await ElMessageBox.confirm("确定要取消关注吗?", "提示", {
  1897. confirmButtonText: "确定",
  1898. cancelButtonText: "取消",
  1899. type: "warning"
  1900. });
  1901. const phone = userStore.userInfo?.phone || "";
  1902. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1903. if (!user.phoneId) {
  1904. ElMessage.error("用户信息不完整");
  1905. return;
  1906. }
  1907. await cancelFollewed({
  1908. followedId: user.phoneId,
  1909. fansId: currentUserPhoneId
  1910. });
  1911. // 更新关注状态
  1912. user.isFollowed = 0;
  1913. user.isFollowThis = 0;
  1914. ElMessage.success("已取消关注");
  1915. } catch (error: any) {
  1916. if (error !== "cancel") {
  1917. console.error("取消关注失败:", error);
  1918. ElMessage.error(error?.message || "取消关注失败,请重试");
  1919. }
  1920. }
  1921. };
  1922. // 初始化
  1923. onMounted(() => {
  1924. loadUserInfo();
  1925. getDyanmicList();
  1926. loadDraftCount();
  1927. // 为统计数据添加点击事件监听
  1928. // 这部分通过模板中的 @click 直接处理
  1929. });
  1930. </script>
  1931. <style scoped lang="scss">
  1932. // 详情 Drawer
  1933. :deep(.detail-drawer) {
  1934. .el-drawer__header {
  1935. position: absolute;
  1936. top: 0;
  1937. right: 0;
  1938. left: 0;
  1939. z-index: 10;
  1940. padding: 0;
  1941. margin: 0;
  1942. background: transparent;
  1943. }
  1944. .el-drawer__body {
  1945. padding: 0;
  1946. background: #000000;
  1947. }
  1948. .drawer-header {
  1949. padding: 20px;
  1950. .close-btn {
  1951. padding: 8px;
  1952. font-size: 24px;
  1953. color: #ffffff;
  1954. background: #ffffff;
  1955. }
  1956. }
  1957. .detail-content {
  1958. position: relative;
  1959. display: flex;
  1960. width: 100%;
  1961. height: 100%;
  1962. // 主内容区域
  1963. .detail-main {
  1964. display: flex;
  1965. flex: 1;
  1966. flex-direction: column;
  1967. align-items: center;
  1968. justify-content: center;
  1969. padding: 80px 120px 40px 40px;
  1970. .media-container {
  1971. position: relative;
  1972. display: flex;
  1973. flex: 1;
  1974. align-items: center;
  1975. justify-content: center;
  1976. width: 100%;
  1977. max-width: 800px;
  1978. min-height: 400px;
  1979. .media-carousel {
  1980. width: 100%;
  1981. height: 100%;
  1982. min-height: 400px;
  1983. max-height: 70vh;
  1984. :deep(.el-carousel__container) {
  1985. height: 100% !important;
  1986. min-height: 400px;
  1987. }
  1988. :deep(.el-carousel__item) {
  1989. display: flex;
  1990. align-items: center;
  1991. justify-content: center;
  1992. background: transparent;
  1993. }
  1994. :deep(.el-carousel__arrow) {
  1995. width: 48px;
  1996. height: 48px;
  1997. font-size: 24px;
  1998. color: #ffffff;
  1999. background-color: rgb(0 0 0 / 40%);
  2000. border: none;
  2001. &:hover {
  2002. background-color: rgb(0 0 0 / 60%);
  2003. }
  2004. }
  2005. :deep(.el-carousel__indicators) {
  2006. bottom: -30px;
  2007. .el-carousel__indicator {
  2008. .el-carousel__button {
  2009. width: 8px;
  2010. height: 8px;
  2011. background-color: rgb(255 255 255 / 40%);
  2012. border-radius: 50%;
  2013. }
  2014. &.is-active .el-carousel__button {
  2015. background-color: #409eff;
  2016. }
  2017. }
  2018. }
  2019. }
  2020. .detail-media {
  2021. max-width: 100%;
  2022. max-height: 65vh;
  2023. object-fit: contain;
  2024. border-radius: 8px;
  2025. }
  2026. .detail-image {
  2027. max-width: 100%;
  2028. max-height: 65vh;
  2029. object-fit: contain;
  2030. border-radius: 8px;
  2031. }
  2032. .detail-video {
  2033. width: 100%;
  2034. max-height: 65vh;
  2035. background: #000000;
  2036. border-radius: 8px;
  2037. }
  2038. .media-placeholder {
  2039. display: flex;
  2040. align-items: center;
  2041. justify-content: center;
  2042. width: 400px;
  2043. height: 400px;
  2044. background: rgb(255 255 255 / 5%);
  2045. border-radius: 8px;
  2046. }
  2047. .media-counter {
  2048. position: absolute;
  2049. right: 16px;
  2050. bottom: -24px;
  2051. padding: 4px 12px;
  2052. font-size: 14px;
  2053. color: #ffffff;
  2054. background: rgb(0 0 0 / 50%);
  2055. border-radius: 12px;
  2056. }
  2057. }
  2058. .detail-info {
  2059. width: 100%;
  2060. max-width: 800px;
  2061. padding: 20px 0;
  2062. .author-info {
  2063. display: flex;
  2064. gap: 12px;
  2065. align-items: center;
  2066. margin-bottom: 16px;
  2067. .author-avatar {
  2068. display: flex;
  2069. align-items: center;
  2070. justify-content: center;
  2071. width: 40px;
  2072. height: 40px;
  2073. overflow: hidden;
  2074. background: rgb(255 255 255 / 10%);
  2075. border-radius: 50%;
  2076. img {
  2077. width: 100%;
  2078. height: 100%;
  2079. object-fit: cover;
  2080. }
  2081. }
  2082. .author-details {
  2083. flex: 1;
  2084. .author-name {
  2085. margin-bottom: 4px;
  2086. font-size: 16px;
  2087. font-weight: 500;
  2088. color: #ffffff;
  2089. }
  2090. .publish-time {
  2091. font-size: 13px;
  2092. color: rgb(255 255 255 / 60%);
  2093. }
  2094. }
  2095. }
  2096. .detail-description {
  2097. position: relative;
  2098. font-size: 15px;
  2099. line-height: 1.6;
  2100. color: #ffffff;
  2101. p {
  2102. margin: 0;
  2103. word-break: break-word;
  2104. &.text-ellipsis {
  2105. display: -webkit-box;
  2106. overflow: hidden;
  2107. text-overflow: ellipsis;
  2108. -webkit-line-clamp: 2;
  2109. line-clamp: 2;
  2110. -webkit-box-orient: vertical;
  2111. }
  2112. }
  2113. .expand-btn {
  2114. display: inline-block;
  2115. margin-top: 8px;
  2116. font-size: 14px;
  2117. color: #409eff;
  2118. cursor: pointer;
  2119. user-select: none;
  2120. &:hover {
  2121. color: #66b1ff;
  2122. }
  2123. }
  2124. }
  2125. }
  2126. }
  2127. // 右侧操作栏
  2128. .action-bar {
  2129. position: fixed;
  2130. right: 40px;
  2131. bottom: 100px;
  2132. z-index: 10;
  2133. display: flex;
  2134. flex-direction: column;
  2135. gap: 24px;
  2136. .action-item {
  2137. display: flex;
  2138. flex-direction: column;
  2139. gap: 6px;
  2140. align-items: center;
  2141. cursor: pointer;
  2142. transition: transform 0.3s;
  2143. &:hover {
  2144. transform: scale(1.1);
  2145. }
  2146. &.author-action {
  2147. cursor: pointer;
  2148. &:hover {
  2149. transform: scale(1.1);
  2150. }
  2151. }
  2152. .action-avatar {
  2153. position: relative;
  2154. display: flex;
  2155. align-items: center;
  2156. justify-content: center;
  2157. width: 48px;
  2158. height: 48px;
  2159. overflow: visible;
  2160. cursor: pointer;
  2161. background: rgb(255 255 255 / 20%);
  2162. border: 2px solid #ffffff;
  2163. border-radius: 50%;
  2164. img {
  2165. width: 100%;
  2166. height: 100%;
  2167. object-fit: cover;
  2168. border-radius: 50%;
  2169. }
  2170. }
  2171. .action-icon {
  2172. display: flex;
  2173. align-items: center;
  2174. justify-content: center;
  2175. width: 48px;
  2176. height: 48px;
  2177. background: rgb(0 0 0 / 50%);
  2178. backdrop-filter: blur(10px);
  2179. border-radius: 50%;
  2180. &.follow-icon {
  2181. background: #409eff;
  2182. }
  2183. }
  2184. .action-count {
  2185. font-size: 13px;
  2186. color: #ffffff;
  2187. text-align: center;
  2188. text-shadow: 0 1px 3px rgb(0 0 0 / 50%);
  2189. }
  2190. }
  2191. }
  2192. }
  2193. }
  2194. // 更多操作 Popover
  2195. :deep(.more-actions-popover) {
  2196. min-width: 120px;
  2197. padding: 8px 0;
  2198. background: rgb(0 0 0 / 90%);
  2199. backdrop-filter: blur(10px);
  2200. border: 1px solid rgb(255 255 255 / 20%);
  2201. .more-actions-menu {
  2202. .menu-item {
  2203. display: flex;
  2204. gap: 8px;
  2205. align-items: center;
  2206. padding: 10px 16px;
  2207. font-size: 14px;
  2208. color: #ffffff;
  2209. cursor: pointer;
  2210. transition: background 0.3s;
  2211. .el-icon {
  2212. font-size: 18px;
  2213. }
  2214. }
  2215. }
  2216. }
  2217. .my-dynamic-container {
  2218. min-height: calc(100vh - 120px);
  2219. padding: 20px;
  2220. background: #ffffff;
  2221. // 用户信息卡片
  2222. .user-card {
  2223. padding: 24px;
  2224. margin-bottom: 20px;
  2225. background: #ffffff;
  2226. border: 1px solid #e4e7ed;
  2227. border-radius: 8px;
  2228. .user-header {
  2229. margin-bottom: 16px;
  2230. .user-avatar-section {
  2231. display: flex;
  2232. gap: 16px;
  2233. align-items: center;
  2234. .user-avatar-large {
  2235. display: flex;
  2236. flex-shrink: 0;
  2237. align-items: center;
  2238. justify-content: center;
  2239. width: 80px;
  2240. height: 80px;
  2241. overflow: hidden;
  2242. background: #f5f7fa;
  2243. border-radius: 50%;
  2244. img {
  2245. width: 100%;
  2246. height: 100%;
  2247. object-fit: cover;
  2248. }
  2249. }
  2250. .user-info-text {
  2251. flex: 1;
  2252. .user-name {
  2253. margin-bottom: 8px;
  2254. font-size: 20px;
  2255. font-weight: 600;
  2256. color: #303133;
  2257. }
  2258. .user-stats {
  2259. display: flex;
  2260. gap: 8px;
  2261. align-items: center;
  2262. font-size: 14px;
  2263. color: #606266;
  2264. .stat-item {
  2265. cursor: pointer;
  2266. transition: color 0.3s;
  2267. &:hover {
  2268. color: #409eff;
  2269. }
  2270. }
  2271. .stat-divider {
  2272. color: #dcdfe6;
  2273. }
  2274. }
  2275. }
  2276. .add-friend-btn {
  2277. display: flex;
  2278. flex-shrink: 0;
  2279. align-items: center;
  2280. margin-left: auto;
  2281. .btn-icon {
  2282. margin-right: 4px;
  2283. }
  2284. }
  2285. }
  2286. }
  2287. .user-bio {
  2288. font-size: 14px;
  2289. line-height: 1.6;
  2290. color: #606266;
  2291. }
  2292. }
  2293. // 标签页区域
  2294. .tabs-section {
  2295. margin-bottom: 20px;
  2296. border-bottom: 1px solid #e4e7ed;
  2297. :deep(.el-tabs) {
  2298. .el-tabs__header {
  2299. margin-bottom: 0;
  2300. }
  2301. .el-tabs__nav-wrap::after {
  2302. display: none;
  2303. }
  2304. }
  2305. }
  2306. // 内容区域
  2307. .content-section {
  2308. margin-top: 20px;
  2309. }
  2310. // 内容网格布局
  2311. .content-grid {
  2312. display: grid;
  2313. grid-template-columns: repeat(4, 1fr);
  2314. gap: 16px;
  2315. margin-bottom: 20px;
  2316. .draft-card {
  2317. display: flex;
  2318. flex-direction: column;
  2319. align-items: center;
  2320. justify-content: center;
  2321. height: 255px;
  2322. padding: 20px;
  2323. text-align: center;
  2324. cursor: pointer;
  2325. background: #f5f7fa;
  2326. border: 1px dashed #dcdfe6;
  2327. border-radius: 8px;
  2328. transition: all 0.3s;
  2329. &:hover {
  2330. background: #ecf5ff;
  2331. border-color: #409eff;
  2332. .el-icon {
  2333. color: #409eff !important;
  2334. }
  2335. }
  2336. .draft-title {
  2337. margin-top: 12px;
  2338. font-size: 16px;
  2339. font-weight: 500;
  2340. color: #303133;
  2341. }
  2342. .draft-count {
  2343. margin-top: 8px;
  2344. font-size: 14px;
  2345. color: #909399;
  2346. }
  2347. }
  2348. @media (width <= 1400px) {
  2349. grid-template-columns: repeat(3, 1fr);
  2350. }
  2351. @media (width <= 1024px) {
  2352. grid-template-columns: repeat(2, 1fr);
  2353. }
  2354. @media (width <= 768px) {
  2355. grid-template-columns: repeat(1, 1fr);
  2356. }
  2357. }
  2358. // 内容卡片
  2359. .content-card {
  2360. cursor: pointer;
  2361. border: 1px solid #e4e7ed;
  2362. border-radius: 8px;
  2363. transition: all 0.3s;
  2364. &:hover {
  2365. box-shadow: 0 2px 12px rgb(0 0 0 / 10%);
  2366. transform: translateY(-2px);
  2367. .content-cover-wrapper {
  2368. .play-overlay {
  2369. opacity: 1;
  2370. }
  2371. }
  2372. }
  2373. // 封面区域
  2374. .content-cover-wrapper {
  2375. position: relative;
  2376. width: 100%;
  2377. aspect-ratio: 16 / 9;
  2378. overflow: hidden;
  2379. background: #f5f7fa;
  2380. border-top-left-radius: 8px;
  2381. border-top-right-radius: 8px;
  2382. .content-cover {
  2383. width: 100%;
  2384. height: 100%;
  2385. object-fit: cover;
  2386. }
  2387. .cover-placeholder {
  2388. display: flex;
  2389. align-items: center;
  2390. justify-content: center;
  2391. width: 100%;
  2392. height: 100%;
  2393. background: #f5f7fa;
  2394. }
  2395. // 播放按钮覆盖层
  2396. .play-overlay {
  2397. position: absolute;
  2398. inset: 0;
  2399. display: flex;
  2400. align-items: center;
  2401. justify-content: center;
  2402. background: rgb(0 0 0 / 30%);
  2403. opacity: 0;
  2404. transition: opacity 0.3s;
  2405. .el-icon {
  2406. filter: drop-shadow(0 2px 4px rgb(0 0 0 / 20%));
  2407. }
  2408. }
  2409. // 标题标签
  2410. .content-label {
  2411. position: absolute;
  2412. top: 8px;
  2413. left: 8px;
  2414. padding: 4px 12px;
  2415. font-size: 12px;
  2416. color: #ffffff;
  2417. background: rgb(0 0 0 / 60%);
  2418. backdrop-filter: blur(4px);
  2419. border-radius: 4px;
  2420. }
  2421. }
  2422. // 底部信息
  2423. .content-footer {
  2424. display: flex;
  2425. align-items: center;
  2426. justify-content: space-between;
  2427. padding: 0 4px;
  2428. .footer-left {
  2429. display: flex;
  2430. gap: 4px;
  2431. align-items: center;
  2432. padding-top: 5px;
  2433. }
  2434. .footer-right {
  2435. display: flex;
  2436. gap: 4px;
  2437. align-items: center;
  2438. padding-top: 5px;
  2439. }
  2440. .view-count,
  2441. .like-count {
  2442. font-size: 13px;
  2443. color: #666666;
  2444. }
  2445. }
  2446. }
  2447. // 空状态
  2448. .empty-section {
  2449. padding: 80px 0;
  2450. text-align: center;
  2451. }
  2452. // 详情 Drawer
  2453. :deep(.detail-drawer) {
  2454. .el-drawer__header {
  2455. position: absolute;
  2456. top: 0;
  2457. right: 0;
  2458. left: 0;
  2459. z-index: 10;
  2460. padding: 0;
  2461. margin: 0;
  2462. background: transparent;
  2463. }
  2464. .el-drawer__body {
  2465. padding: 0;
  2466. background: #000000;
  2467. }
  2468. .drawer-header {
  2469. padding: 20px;
  2470. .close-btn {
  2471. padding: 8px;
  2472. font-size: 24px;
  2473. color: #ffffff;
  2474. }
  2475. }
  2476. .detail-content {
  2477. position: relative;
  2478. display: flex;
  2479. width: 100%;
  2480. height: 100%;
  2481. // 主内容区域
  2482. .detail-main {
  2483. display: flex;
  2484. flex: 1;
  2485. flex-direction: column;
  2486. align-items: center;
  2487. justify-content: center;
  2488. padding: 80px 120px 40px 40px;
  2489. .media-container {
  2490. display: flex;
  2491. flex: 1;
  2492. align-items: center;
  2493. justify-content: center;
  2494. width: 100%;
  2495. max-width: 800px;
  2496. .detail-media {
  2497. max-width: 100%;
  2498. max-height: 100%;
  2499. object-fit: contain;
  2500. border-radius: 8px;
  2501. }
  2502. .media-placeholder {
  2503. display: flex;
  2504. align-items: center;
  2505. justify-content: center;
  2506. width: 400px;
  2507. height: 400px;
  2508. background: rgb(255 255 255 / 5%);
  2509. border-radius: 8px;
  2510. }
  2511. }
  2512. .detail-info {
  2513. width: 100%;
  2514. max-width: 800px;
  2515. padding: 20px 0;
  2516. .author-info {
  2517. display: flex;
  2518. gap: 12px;
  2519. align-items: center;
  2520. margin-bottom: 16px;
  2521. .author-avatar {
  2522. display: flex;
  2523. align-items: center;
  2524. justify-content: center;
  2525. width: 40px;
  2526. height: 40px;
  2527. overflow: hidden;
  2528. background: rgb(255 255 255 / 10%);
  2529. border-radius: 50%;
  2530. img {
  2531. width: 100%;
  2532. height: 100%;
  2533. object-fit: cover;
  2534. }
  2535. }
  2536. .author-details {
  2537. flex: 1;
  2538. .author-name {
  2539. margin-bottom: 4px;
  2540. font-size: 16px;
  2541. font-weight: 500;
  2542. color: #ffffff;
  2543. }
  2544. .publish-time {
  2545. font-size: 13px;
  2546. color: rgb(255 255 255 / 60%);
  2547. }
  2548. }
  2549. }
  2550. .detail-description {
  2551. position: relative;
  2552. font-size: 15px;
  2553. line-height: 1.6;
  2554. color: #ffffff;
  2555. p {
  2556. margin: 0;
  2557. word-break: break-word;
  2558. &.text-ellipsis {
  2559. display: -webkit-box;
  2560. overflow: hidden;
  2561. text-overflow: ellipsis;
  2562. -webkit-line-clamp: 2;
  2563. line-clamp: 2;
  2564. -webkit-box-orient: vertical;
  2565. }
  2566. }
  2567. .expand-btn {
  2568. display: inline-block;
  2569. margin-top: 8px;
  2570. font-size: 14px;
  2571. color: #409eff;
  2572. cursor: pointer;
  2573. user-select: none;
  2574. &:hover {
  2575. color: #66b1ff;
  2576. }
  2577. }
  2578. }
  2579. }
  2580. }
  2581. // 右侧操作栏
  2582. .action-bar {
  2583. position: fixed;
  2584. right: 40px;
  2585. bottom: 100px;
  2586. z-index: 10;
  2587. display: flex;
  2588. flex-direction: column;
  2589. gap: 24px;
  2590. .action-item {
  2591. display: flex;
  2592. flex-direction: column;
  2593. gap: 6px;
  2594. align-items: center;
  2595. cursor: pointer;
  2596. transition: transform 0.3s;
  2597. &:hover {
  2598. transform: scale(1.1);
  2599. }
  2600. &.author-action {
  2601. cursor: default;
  2602. &:hover {
  2603. transform: none;
  2604. }
  2605. }
  2606. .action-avatar {
  2607. display: flex;
  2608. align-items: center;
  2609. justify-content: center;
  2610. width: 48px;
  2611. height: 48px;
  2612. overflow: hidden;
  2613. background: rgb(255 255 255 / 20%);
  2614. border: 2px solid #ffffff;
  2615. border-radius: 50%;
  2616. img {
  2617. width: 100%;
  2618. height: 100%;
  2619. object-fit: cover;
  2620. }
  2621. }
  2622. .action-icon {
  2623. display: flex;
  2624. align-items: center;
  2625. justify-content: center;
  2626. width: 48px;
  2627. height: 48px;
  2628. background: rgb(0 0 0 / 50%);
  2629. backdrop-filter: blur(10px);
  2630. border-radius: 50%;
  2631. }
  2632. .action-count {
  2633. font-size: 13px;
  2634. color: #ffffff;
  2635. text-align: center;
  2636. text-shadow: 0 1px 3px rgb(0 0 0 / 50%);
  2637. }
  2638. }
  2639. }
  2640. }
  2641. }
  2642. // 更多操作 Popover
  2643. :deep(.more-actions-popover) {
  2644. min-width: 120px;
  2645. padding: 8px 0;
  2646. background: rgb(0 0 0 / 90%);
  2647. backdrop-filter: blur(10px);
  2648. border: 1px solid rgb(255 255 255 / 10%);
  2649. .el-popper__arrow::before {
  2650. background: rgb(0 0 0 / 90%);
  2651. border: 1px solid rgb(255 255 255 / 10%);
  2652. }
  2653. .more-actions-menu {
  2654. .menu-item {
  2655. display: flex;
  2656. gap: 12px;
  2657. align-items: center;
  2658. padding: 12px 16px;
  2659. font-size: 14px;
  2660. color: #ffffff;
  2661. cursor: pointer;
  2662. transition: all 0.3s;
  2663. .el-icon {
  2664. color: #ffffff;
  2665. }
  2666. span {
  2667. flex: 1;
  2668. }
  2669. }
  2670. }
  2671. }
  2672. // 对话框样式(关系对话框 + 举报对话框)
  2673. :deep(.el-dialog) {
  2674. // 关系对话框
  2675. .relation-dialog-content {
  2676. display: flex;
  2677. flex-direction: column;
  2678. max-height: 70vh;
  2679. overflow: hidden;
  2680. .el-tabs {
  2681. flex-shrink: 0;
  2682. margin-bottom: 16px;
  2683. .el-tabs__header {
  2684. margin-bottom: 16px;
  2685. }
  2686. }
  2687. .search-box {
  2688. flex-shrink: 0;
  2689. margin-bottom: 16px;
  2690. }
  2691. .relation-list {
  2692. flex: 1;
  2693. min-height: 0;
  2694. max-height: 320px;
  2695. overflow: hidden auto;
  2696. -webkit-overflow-scrolling: touch;
  2697. .relation-item {
  2698. display: flex;
  2699. align-items: center;
  2700. justify-content: space-between;
  2701. padding: 12px 0;
  2702. border-bottom: 1px solid #f5f7fa;
  2703. &:last-child {
  2704. border-bottom: none;
  2705. }
  2706. .user-info-row {
  2707. display: flex;
  2708. flex: 1;
  2709. gap: 12px;
  2710. align-items: center;
  2711. .user-avatar-small {
  2712. display: flex;
  2713. flex-shrink: 0;
  2714. align-items: center;
  2715. justify-content: center;
  2716. width: 48px;
  2717. height: 48px;
  2718. overflow: hidden;
  2719. background: #f5f7fa;
  2720. border-radius: 50%;
  2721. img {
  2722. width: 100%;
  2723. height: 100%;
  2724. object-fit: cover;
  2725. }
  2726. }
  2727. .user-details {
  2728. flex: 1;
  2729. min-width: 0;
  2730. .user-name-text {
  2731. margin-bottom: 4px;
  2732. font-size: 15px;
  2733. font-weight: 500;
  2734. color: #303133;
  2735. }
  2736. .user-desc {
  2737. overflow: hidden;
  2738. font-size: 13px;
  2739. color: #909399;
  2740. text-overflow: ellipsis;
  2741. white-space: nowrap;
  2742. }
  2743. }
  2744. }
  2745. .action-button {
  2746. margin-left: 12px;
  2747. .el-button {
  2748. min-width: 80px;
  2749. }
  2750. }
  2751. }
  2752. .relation-load-more {
  2753. padding: 12px 0;
  2754. text-align: center;
  2755. }
  2756. }
  2757. }
  2758. // 举报对话框
  2759. .report-dialog-content {
  2760. .report-tip {
  2761. margin-bottom: 20px;
  2762. font-size: 14px;
  2763. line-height: 1.6;
  2764. color: #606266;
  2765. }
  2766. .report-reasons {
  2767. margin-bottom: 20px;
  2768. .el-radio-group {
  2769. display: flex;
  2770. flex-wrap: wrap;
  2771. gap: 12px 16px;
  2772. .el-radio {
  2773. height: auto;
  2774. margin-right: 0;
  2775. white-space: nowrap;
  2776. .el-radio__label {
  2777. font-size: 14px;
  2778. color: #303133;
  2779. }
  2780. }
  2781. }
  2782. }
  2783. .report-description {
  2784. margin-bottom: 20px;
  2785. :deep(.el-textarea__inner) {
  2786. font-size: 14px;
  2787. }
  2788. }
  2789. .report-upload {
  2790. margin-bottom: 20px;
  2791. .upload-title {
  2792. margin-bottom: 12px;
  2793. font-size: 14px;
  2794. font-weight: 500;
  2795. color: #303133;
  2796. }
  2797. :deep(.el-upload-list) {
  2798. display: flex;
  2799. flex-wrap: wrap;
  2800. gap: 8px;
  2801. }
  2802. :deep(.el-upload--picture-card) {
  2803. width: 100px;
  2804. height: 100px;
  2805. border-radius: 4px;
  2806. }
  2807. :deep(.el-upload-list--picture-card .el-upload-list__item) {
  2808. width: 100px;
  2809. height: 100px;
  2810. margin: 0;
  2811. border-radius: 4px;
  2812. }
  2813. }
  2814. .report-agreement {
  2815. .el-checkbox {
  2816. .el-checkbox__label {
  2817. font-size: 14px;
  2818. color: #606266;
  2819. }
  2820. }
  2821. }
  2822. }
  2823. .dialog-footer {
  2824. display: flex;
  2825. gap: 12px;
  2826. justify-content: flex-end;
  2827. }
  2828. }
  2829. // 评论侧边栏样式
  2830. .comment-list-container {
  2831. flex: 1;
  2832. height: calc(100vh - 200px);
  2833. padding: 0 20px;
  2834. overflow-y: auto;
  2835. .comment-list {
  2836. .comment-item {
  2837. display: flex;
  2838. gap: 12px;
  2839. padding: 16px 0;
  2840. border-bottom: 1px solid #f0f0f0;
  2841. &:last-child {
  2842. border-bottom: none;
  2843. }
  2844. .comment-avatar {
  2845. display: flex;
  2846. flex-shrink: 0;
  2847. align-items: center;
  2848. justify-content: center;
  2849. width: 40px;
  2850. height: 40px;
  2851. overflow: hidden;
  2852. background: #f5f5f5;
  2853. border-radius: 50%;
  2854. img {
  2855. width: 100%;
  2856. height: 100%;
  2857. object-fit: cover;
  2858. }
  2859. }
  2860. .comment-content-wrapper {
  2861. flex: 1;
  2862. min-width: 0;
  2863. .comment-header,
  2864. .store-comment-header {
  2865. display: flex;
  2866. align-items: center;
  2867. justify-content: space-between;
  2868. margin-bottom: 8px;
  2869. .comment-user-name {
  2870. font-size: 14px;
  2871. font-weight: 500;
  2872. color: #303133;
  2873. }
  2874. .comment-time {
  2875. font-size: 12px;
  2876. color: #909399;
  2877. }
  2878. }
  2879. .comment-text {
  2880. margin-bottom: 8px;
  2881. font-size: 14px;
  2882. line-height: 1.6;
  2883. color: #606266;
  2884. word-break: break-all;
  2885. }
  2886. // 商家回复样式
  2887. .store-comment-wrapper {
  2888. padding: 12px;
  2889. margin-top: 12px;
  2890. background: #f5f7fa;
  2891. border-radius: 8px;
  2892. .store-comment-item {
  2893. display: flex;
  2894. gap: 10px;
  2895. .store-comment-avatar {
  2896. display: flex;
  2897. flex-shrink: 0;
  2898. align-items: center;
  2899. justify-content: center;
  2900. width: 32px;
  2901. height: 32px;
  2902. overflow: hidden;
  2903. background: #ffffff;
  2904. border-radius: 50%;
  2905. img {
  2906. width: 100%;
  2907. height: 100%;
  2908. object-fit: cover;
  2909. }
  2910. }
  2911. .store-comment-content {
  2912. flex: 1;
  2913. min-width: 0;
  2914. .store-comment-header {
  2915. display: flex;
  2916. align-items: center;
  2917. justify-content: space-between;
  2918. margin-bottom: 6px;
  2919. .store-comment-user-name {
  2920. font-size: 13px;
  2921. font-weight: 500;
  2922. color: #409eff;
  2923. }
  2924. .store-comment-time {
  2925. font-size: 11px;
  2926. color: #909399;
  2927. }
  2928. }
  2929. .store-comment-text {
  2930. display: flex;
  2931. align-items: center;
  2932. justify-content: space-between;
  2933. font-size: 13px;
  2934. line-height: 1.5;
  2935. color: #606266;
  2936. word-break: break-all;
  2937. }
  2938. }
  2939. }
  2940. }
  2941. .comment-actions {
  2942. display: flex;
  2943. gap: 20px;
  2944. .comment-action-item {
  2945. display: flex;
  2946. gap: 4px;
  2947. align-items: center;
  2948. font-size: 13px;
  2949. color: #909399;
  2950. cursor: pointer;
  2951. transition: color 0.3s;
  2952. &:hover {
  2953. color: #409eff;
  2954. }
  2955. span {
  2956. font-size: 13px;
  2957. }
  2958. }
  2959. }
  2960. }
  2961. }
  2962. }
  2963. }
  2964. .comment-input-wrapper {
  2965. position: absolute;
  2966. right: 0;
  2967. bottom: 0;
  2968. left: 0;
  2969. padding: 16px 20px;
  2970. background: #ffffff;
  2971. border-top: 1px solid #e4e7ed;
  2972. box-shadow: 0 -2px 8px rgb(0 0 0 / 5%);
  2973. .reply-hint {
  2974. display: flex;
  2975. align-items: center;
  2976. justify-content: space-between;
  2977. padding: 8px 12px;
  2978. margin-bottom: 8px;
  2979. background: #f5f7fa;
  2980. border-radius: 4px;
  2981. .reply-text {
  2982. font-size: 13px;
  2983. color: #409eff;
  2984. }
  2985. .cancel-reply {
  2986. font-size: 16px;
  2987. color: #909399;
  2988. cursor: pointer;
  2989. transition: color 0.3s;
  2990. &:hover {
  2991. color: #f56c6c;
  2992. }
  2993. }
  2994. }
  2995. :deep(.el-textarea) {
  2996. margin-bottom: 12px;
  2997. }
  2998. .el-button {
  2999. width: 100%;
  3000. }
  3001. }
  3002. // 分享对话框
  3003. .share-dialog-content {
  3004. .search-box {
  3005. margin-bottom: 16px;
  3006. }
  3007. .share-friend-list {
  3008. max-height: 400px;
  3009. margin-bottom: 16px;
  3010. overflow-y: auto;
  3011. .share-friend-item {
  3012. display: flex;
  3013. align-items: center;
  3014. justify-content: space-between;
  3015. padding: 12px;
  3016. cursor: pointer;
  3017. border-radius: 8px;
  3018. transition: background-color 0.3s;
  3019. &:hover {
  3020. background-color: #f5f7fa;
  3021. }
  3022. .friend-info {
  3023. display: flex;
  3024. gap: 12px;
  3025. align-items: center;
  3026. .friend-avatar {
  3027. display: flex;
  3028. flex-shrink: 0;
  3029. align-items: center;
  3030. justify-content: center;
  3031. width: 40px;
  3032. height: 40px;
  3033. overflow: hidden;
  3034. background: #f5f5f5;
  3035. border-radius: 50%;
  3036. img {
  3037. width: 100%;
  3038. height: 100%;
  3039. object-fit: cover;
  3040. }
  3041. }
  3042. .friend-name {
  3043. font-size: 14px;
  3044. font-weight: 500;
  3045. color: #303133;
  3046. }
  3047. }
  3048. }
  3049. }
  3050. .selected-friends {
  3051. padding: 12px;
  3052. background: #f5f7fa;
  3053. border-radius: 8px;
  3054. .selected-title {
  3055. margin-bottom: 8px;
  3056. font-size: 13px;
  3057. color: #606266;
  3058. }
  3059. .selected-list {
  3060. display: flex;
  3061. flex-wrap: wrap;
  3062. gap: 8px;
  3063. .el-tag {
  3064. max-width: 120px;
  3065. overflow: hidden;
  3066. text-overflow: ellipsis;
  3067. white-space: nowrap;
  3068. }
  3069. }
  3070. }
  3071. }
  3072. // 添加好友对话框样式
  3073. .add-friend-dialog-content {
  3074. .search-box {
  3075. margin-bottom: 20px;
  3076. }
  3077. .search-results {
  3078. max-height: 400px;
  3079. overflow-y: auto;
  3080. .search-loading {
  3081. display: flex;
  3082. gap: 8px;
  3083. align-items: center;
  3084. justify-content: center;
  3085. padding: 40px 0;
  3086. color: #909399;
  3087. }
  3088. .search-results-count {
  3089. padding: 0 4px;
  3090. margin-bottom: 12px;
  3091. font-size: 14px;
  3092. color: #909399;
  3093. }
  3094. .search-results-list {
  3095. .search-result-item {
  3096. display: flex;
  3097. align-items: center;
  3098. justify-content: space-between;
  3099. padding: 16px;
  3100. border-bottom: 1px solid #f0f0f0;
  3101. transition: background-color 0.2s;
  3102. &:hover {
  3103. background-color: #f5f7fa;
  3104. }
  3105. &:last-child {
  3106. border-bottom: none;
  3107. }
  3108. .user-info-row {
  3109. display: flex;
  3110. flex: 1;
  3111. gap: 12px;
  3112. align-items: center;
  3113. .user-avatar-small {
  3114. display: flex;
  3115. flex-shrink: 0;
  3116. align-items: center;
  3117. justify-content: center;
  3118. width: 48px;
  3119. height: 48px;
  3120. overflow: hidden;
  3121. background-color: #f0f0f0;
  3122. border-radius: 50%;
  3123. img {
  3124. width: 100%;
  3125. height: 100%;
  3126. object-fit: cover;
  3127. }
  3128. }
  3129. .user-details {
  3130. flex: 1;
  3131. min-width: 0;
  3132. .user-name-text {
  3133. margin-bottom: 4px;
  3134. overflow: hidden;
  3135. font-size: 16px;
  3136. font-weight: 500;
  3137. color: #303133;
  3138. text-overflow: ellipsis;
  3139. white-space: nowrap;
  3140. }
  3141. .user-desc {
  3142. overflow: hidden;
  3143. font-size: 14px;
  3144. color: #909399;
  3145. text-overflow: ellipsis;
  3146. white-space: nowrap;
  3147. }
  3148. }
  3149. }
  3150. .action-button {
  3151. flex-shrink: 0;
  3152. margin-left: 12px;
  3153. }
  3154. }
  3155. }
  3156. .search-empty {
  3157. padding: 40px 0;
  3158. }
  3159. }
  3160. .search-placeholder {
  3161. padding: 40px 0;
  3162. }
  3163. }
  3164. }
  3165. </style>
  3166. <style scoped>
  3167. @import "@/assets/dianzanFont/iconfont.css";
  3168. </style>