myDynamic.vue 98 KB

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