myDynamic.vue 98 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392
  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. getMutualAttention,
  703. getMyFollowed,
  704. addTransferCount,
  705. getMyUserFans,
  706. getMyStoreFans,
  707. blockUser,
  708. likeDynamicNew,
  709. unlikeDynamicNew,
  710. getStoreAndUserByName,
  711. toggleFollowUser,
  712. cancelFollewed
  713. } from "@/api/modules/newLoginApi";
  714. import {} from "@/api/modules/dynamicManagement";
  715. import { useUserStore } from "@/stores/modules/user";
  716. import FriendCoupon from "./friendCoupon.vue";
  717. import { localGet } from "@/utils";
  718. const router = useRouter();
  719. const userStore = useUserStore();
  720. // 接口定义
  721. interface UserInfo {
  722. name: string;
  723. avatar: string;
  724. bio: string;
  725. followCount: number;
  726. fansCount: number;
  727. likeCount: number;
  728. }
  729. interface MediaItem {
  730. url: string;
  731. type: "image" | "video";
  732. }
  733. interface ContentItem {
  734. id: number;
  735. title: string;
  736. coverUrl: string;
  737. imagePath?: string;
  738. type: "image" | "video";
  739. viewCount: number;
  740. liulanCount?: number;
  741. isLike?: string;
  742. dianzanCount?: number;
  743. showLabel?: boolean;
  744. labelText?: string;
  745. createTime: string;
  746. mediaList?: MediaItem[];
  747. }
  748. interface DetailItem extends ContentItem {
  749. author?: {
  750. id: number;
  751. name: string;
  752. avatar: string;
  753. };
  754. userAvatar?: string;
  755. userName?: string;
  756. description: string;
  757. publishTime: string;
  758. likeCount: number;
  759. commentCount: number;
  760. isLiked: boolean;
  761. isLike?: string; // 点赞状态:'0'未点赞,'1'已点赞
  762. dianzanCount?: number; // 点赞数量
  763. userId?: string | number; // 发布者ID
  764. phoneId?: string; // 发布者店铺ID
  765. storeUserId?: string | number; // 小店用户ID(用于举报和拉黑)
  766. userType?: number; // 发布者用户类型:1商家,2用户
  767. imagePath?: string; // 图片路径
  768. }
  769. interface RelationUser {
  770. id: number;
  771. name: string;
  772. avatar: string;
  773. description: string;
  774. relationStatus: "following" | "mutual" | "none"; // following: 已关注, mutual: 互相关注, none: 未关注
  775. phoneId?: string; // 用户的 phoneId,用于后续操作
  776. }
  777. // 响应式数据
  778. const activeTab = ref("dynamic");
  779. const contentList = ref<ContentItem[]>([]);
  780. const draftCount = ref(0); // 草稿数量
  781. // 详情 Drawer 相关
  782. const detailDrawerVisible = ref(false);
  783. const currentDetail = ref<DetailItem | null>(null);
  784. // 描述展开/收起状态
  785. const isDescriptionExpanded = ref(false);
  786. // 视频轮播相关
  787. const videoRefs = ref<HTMLVideoElement[]>([]);
  788. const currentCarouselIndex = ref(0);
  789. // 切换描述展开/收起
  790. const toggleDescription = () => {
  791. isDescriptionExpanded.value = !isDescriptionExpanded.value;
  792. };
  793. // 评论相关
  794. const commentDrawerVisible = ref(false);
  795. const commentListData = ref<any[]>([]);
  796. const commentInput = ref("");
  797. const commentSubmitting = ref(false);
  798. const replyingComment = ref<any>(null);
  799. // 关系对话框相关
  800. const relationDialogVisible = ref(false);
  801. const relationActiveTab = ref("friend");
  802. const relationSearch = ref("");
  803. const relationList = ref<RelationUser[]>([]);
  804. const relationPage = ref(1);
  805. const relationPageSize = 5;
  806. const relationTotal = ref(0);
  807. const relationLoading = ref(false);
  808. const relationHasMore = computed(() => relationList.value.length < relationTotal.value && !relationLoading.value);
  809. const relationListScrollRef = ref<HTMLElement | null>(null);
  810. const relationScrollTargets: HTMLElement[] = [];
  811. const onRelationListScroll = (e: Event) => {
  812. const el = e.target as HTMLElement;
  813. if (!el || !relationHasMore.value) return;
  814. const { scrollTop, scrollHeight, clientHeight } = el;
  815. const distanceToBottom = scrollHeight - scrollTop - clientHeight;
  816. if (distanceToBottom < 80) {
  817. loadMoreRelationList();
  818. }
  819. };
  820. const bindRelationScroll = () => {
  821. nextTick(() => {
  822. setTimeout(() => {
  823. const listEl = relationListScrollRef.value;
  824. if (!listEl) return;
  825. unbindRelationScroll();
  826. listEl.addEventListener("scroll", onRelationListScroll, { passive: true });
  827. relationScrollTargets.push(listEl);
  828. const dialogBody = listEl.closest(".el-dialog")?.querySelector(".el-dialog__body") as HTMLElement | null;
  829. if (dialogBody && dialogBody !== listEl) {
  830. dialogBody.addEventListener("scroll", onRelationListScroll, { passive: true });
  831. relationScrollTargets.push(dialogBody);
  832. }
  833. }, 100);
  834. });
  835. };
  836. const unbindRelationScroll = () => {
  837. relationScrollTargets.splice(0, relationScrollTargets.length).forEach(el => {
  838. el.removeEventListener("scroll", onRelationListScroll);
  839. });
  840. };
  841. watch(relationDialogVisible, visible => {
  842. if (visible) bindRelationScroll();
  843. else unbindRelationScroll();
  844. });
  845. //点击本地草稿
  846. const handleDraftClick = () => {
  847. router.push({
  848. path: "/dynamicManagement/draftDynamic"
  849. });
  850. };
  851. // 举报对话框相关
  852. const reportDialogVisible = ref(false);
  853. const reportSubmitting = ref(false);
  854. const reportForm = reactive({
  855. reason: "",
  856. description: "",
  857. fileList: [] as any[],
  858. agreed: false
  859. });
  860. // 分享对话框相关
  861. interface ShareFriend {
  862. id: number;
  863. name: string;
  864. avatar: string;
  865. phoneId?: string;
  866. }
  867. const shareDialogVisible = ref(false);
  868. const shareSubmitting = ref(false);
  869. const shareSearch = ref("");
  870. const shareFriendList = ref<ShareFriend[]>([]);
  871. const selectedFriends = ref<number[]>([]);
  872. // 添加好友对话框相关
  873. const addFriendDialogVisible = ref(false);
  874. const addFriendSearchKeyword = ref("");
  875. const addFriendSearchResults = ref<any[]>([]);
  876. const addFriendSearching = ref(false);
  877. // 过滤后的好友列表
  878. const filteredShareFriendList = computed(() => {
  879. if (shareSearch.value == null || shareSearch.value === "") {
  880. return shareFriendList.value;
  881. }
  882. const keyword = String(shareSearch.value).toLowerCase();
  883. return shareFriendList.value.filter(friend => (friend.name ?? "").toLowerCase().includes(keyword));
  884. });
  885. // 用户信息
  886. const userInfo = reactive<UserInfo>({
  887. name: "白己的流浪主页",
  888. avatar: "",
  889. bio: "一家好吃的火锅店",
  890. followCount: 19,
  891. fansCount: 10,
  892. likeCount: 10
  893. });
  894. // 头像优先取缓存 geeker-user 的 headImg
  895. const cachedHeadImg = computed(() => localGet("geeker-user")?.userInfo?.headImg || userInfo.avatar || "");
  896. // 对话框标题
  897. const relationDialogTitle = computed(() => {
  898. const titles = {
  899. friend: "好友",
  900. follow: "关注",
  901. fans: "粉丝"
  902. };
  903. return titles[relationActiveTab.value as keyof typeof titles];
  904. });
  905. // 过滤后的关系列表
  906. const filteredRelationList = computed(() => {
  907. if (relationSearch.value == null || relationSearch.value === "") {
  908. return relationList.value;
  909. }
  910. const keyword = String(relationSearch.value).toLowerCase();
  911. return relationList.value.filter(
  912. user => (user.name ?? "").toLowerCase().includes(keyword) || (user.description ?? "").toLowerCase().includes(keyword)
  913. );
  914. });
  915. // 判断当前详情是否是当前用户的动态
  916. const isMyDynamic = computed(() => {
  917. if (!currentDetail.value) return false;
  918. // 获取当前用户的 storeId
  919. const currentUserStoreId = userStore.userInfo?.storeId;
  920. // 获取动态的 storeUserId 或 userId
  921. const dynamicStoreUserId = currentDetail.value.storeUserId || currentDetail.value.userId;
  922. // 通过 storeId 判断是否是当前用户的动态
  923. const result = currentUserStoreId == dynamicStoreUserId;
  924. console.log("是否是自己发布的作品:", result, {
  925. currentUserStoreId,
  926. dynamicStoreUserId
  927. });
  928. return result;
  929. });
  930. // 标签切换
  931. const handleTabClick = (pane: any) => {
  932. const tabName = pane.props.name;
  933. if (tabName === "liked") {
  934. getDianZan();
  935. } else if (tabName === "dynamic") {
  936. getDyanmicList();
  937. }
  938. };
  939. // 点击卡片
  940. const handleCardClick = async (item: any) => {
  941. try {
  942. // 重置描述展开状态
  943. isDescriptionExpanded.value = false;
  944. // 解析媒体列表(支持多张图片和视频)
  945. const mediaUrl = item.imagePath || "";
  946. const mediaUrls = mediaUrl
  947. .split(",")
  948. .map((url: string) => url.trim())
  949. .filter((url: string) => url);
  950. const mediaList: MediaItem[] = mediaUrls.map((url: string) => ({
  951. url,
  952. type: url.toLowerCase().endsWith(".mp4") ? ("video" as const) : ("image" as const)
  953. }));
  954. const firstUrl = mediaUrls[0] || "";
  955. const isVideo = firstUrl.toLowerCase().endsWith(".mp4");
  956. currentDetail.value = {
  957. ...item,
  958. mediaList,
  959. coverUrl: firstUrl,
  960. type: isVideo ? "video" : "image",
  961. author: {
  962. id: item.userId || 0,
  963. name: item.userName || "用户",
  964. avatar: item.userAvatar || item.userImage || ""
  965. },
  966. userAvatar: item.userAvatar || item.userImage || "",
  967. userName: item.userName || "用户",
  968. description: item.context || item.title || "",
  969. publishTime: item.createTime || item.createdTime || "",
  970. likeCount: item.likeCount || item.praiseNum || 0,
  971. commentCount: item.commentCount || 0,
  972. isLiked: item.isLiked || false
  973. };
  974. detailDrawerVisible.value = true;
  975. // 重置轮播索引
  976. currentCarouselIndex.value = 0;
  977. } catch (error) {
  978. console.error("加载详情失败:", error);
  979. ElMessage.error("加载详情失败");
  980. }
  981. };
  982. // 关闭详情
  983. const handleCloseDetail = () => {
  984. detailDrawerVisible.value = false;
  985. // 暂停所有视频
  986. videoRefs.value.forEach(video => {
  987. if (video && !video.paused) {
  988. video.pause();
  989. }
  990. });
  991. setTimeout(() => {
  992. currentDetail.value = null;
  993. videoRefs.value = [];
  994. }, 300);
  995. };
  996. // 设置视频引用
  997. const setVideoRef = (el: any, index: number) => {
  998. if (el) {
  999. videoRefs.value[index] = el as HTMLVideoElement;
  1000. }
  1001. };
  1002. // 轮播切换
  1003. const handleCarouselChange = (newIndex: number) => {
  1004. // 暂停所有视频
  1005. videoRefs.value.forEach(video => {
  1006. if (video && !video.paused) {
  1007. video.pause();
  1008. }
  1009. });
  1010. currentCarouselIndex.value = newIndex;
  1011. };
  1012. // 视频播放
  1013. const handleVideoPlay = (index: number) => {
  1014. // 暂停其他视频
  1015. videoRefs.value.forEach((video, i) => {
  1016. if (i !== index && video && !video.paused) {
  1017. video.pause();
  1018. }
  1019. });
  1020. };
  1021. // 查看用户主页
  1022. const handleViewUserProfile = () => {
  1023. // ElMessage.info("查看用户主页功能开发中");
  1024. };
  1025. // 详情页点赞
  1026. const handleDetailLike = async () => {
  1027. if (!currentDetail.value) return;
  1028. try {
  1029. // 获取当前用户的手机号,并在前面拼接 "store_"
  1030. const phone = userStore.userInfo?.phone || "";
  1031. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1032. const params = {
  1033. userId: currentUserPhoneId, // 当前用户phoneId
  1034. huifuId: currentDetail.value.id, // 动态ID
  1035. type: 2 // 2表示点赞动态
  1036. };
  1037. // 根据当前点赞状态调用不同的接口
  1038. if (currentDetail.value.isLike == "1") {
  1039. // 已点赞,调用取消点赞接口
  1040. await unlikeDynamicNew(params);
  1041. currentDetail.value.isLike = "0";
  1042. currentDetail.value.dianzanCount = Math.max(0, (currentDetail.value.dianzanCount || 1) - 1);
  1043. } else {
  1044. // 未点赞,调用点赞接口
  1045. await likeDynamicNew(params);
  1046. currentDetail.value.isLike = "1";
  1047. currentDetail.value.dianzanCount = (currentDetail.value.dianzanCount || 0) + 1;
  1048. }
  1049. // 同步更新列表中的数据
  1050. const listItem = contentList.value.find(item => item.id === currentDetail.value?.id);
  1051. if (listItem) {
  1052. listItem.isLike = currentDetail.value.isLike;
  1053. listItem.dianzanCount = currentDetail.value.dianzanCount;
  1054. }
  1055. // 同步更新点赞列表中的数据
  1056. const dianZanItem = dianZanList.value.find(item => item.id === currentDetail.value?.id);
  1057. if (dianZanItem) {
  1058. dianZanItem.isLike = currentDetail.value.isLike;
  1059. dianZanItem.dianzanCount = currentDetail.value.dianzanCount;
  1060. }
  1061. ElMessage.success(currentDetail.value.isLike == "1" ? "点赞成功" : "取消点赞");
  1062. } catch (error) {
  1063. console.error("点赞操作失败:", error);
  1064. ElMessage.error("操作失败");
  1065. }
  1066. };
  1067. // 分享
  1068. const handleShare = async () => {
  1069. shareDialogVisible.value = true;
  1070. await loadShareFriendList();
  1071. };
  1072. // 加载好友列表
  1073. const loadShareFriendList = async () => {
  1074. try {
  1075. // 获取当前用户的手机号,并在前面拼接 "store_"
  1076. const phone = userStore.userInfo?.phone || "";
  1077. const fansId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1078. const res: any = await getMutualAttention({
  1079. page: 1,
  1080. size: 1000,
  1081. fansId: fansId,
  1082. name: ""
  1083. });
  1084. if (res.code === 200) {
  1085. const dataList = res.data?.records || res.data?.list || res.data || [];
  1086. shareFriendList.value = dataList.map((item: any) => ({
  1087. id: item.id || item.userId,
  1088. name: item.userName || item.nickname || item.name || "用户",
  1089. avatar: item.userImage || item.avatar || item.headImg || "",
  1090. phoneId: item.phoneId || item.fansId || ""
  1091. }));
  1092. console.log("加载好友列表成功:", shareFriendList.value);
  1093. }
  1094. } catch (error) {
  1095. console.error("加载好友列表失败:", error);
  1096. ElMessage.error("加载好友列表失败");
  1097. shareFriendList.value = [];
  1098. }
  1099. };
  1100. // 搜索好友
  1101. const handleShareSearch = () => {
  1102. // 搜索由计算属性自动处理
  1103. };
  1104. // 选择好友
  1105. const handleSelectFriend = (friend: ShareFriend) => {
  1106. const index = selectedFriends.value.indexOf(friend.id);
  1107. if (index > -1) {
  1108. // 已选择,取消选择
  1109. selectedFriends.value.splice(index, 1);
  1110. } else {
  1111. // 未选择,添加选择
  1112. selectedFriends.value.push(friend.id);
  1113. }
  1114. };
  1115. // 移除已选择的好友
  1116. const handleRemoveFriend = (friendId: number) => {
  1117. const index = selectedFriends.value.indexOf(friendId);
  1118. if (index > -1) {
  1119. selectedFriends.value.splice(index, 1);
  1120. }
  1121. };
  1122. // 确认分享
  1123. const handleConfirmShare = async () => {
  1124. if (selectedFriends.value.length === 0) {
  1125. ElMessage.warning("请选择要分享的好友");
  1126. return;
  1127. }
  1128. if (!currentDetail.value) {
  1129. ElMessage.error("动态信息不存在");
  1130. return;
  1131. }
  1132. try {
  1133. shareSubmitting.value = true;
  1134. // 调用 addTransferCount 接口,传递动态 id
  1135. const res: any = await addTransferCount({
  1136. id: currentDetail.value.id
  1137. });
  1138. if (res.code === 200) {
  1139. ElMessage.success(`已分享给 ${selectedFriends.value.length} 位好友`);
  1140. shareDialogVisible.value = false;
  1141. // 可以在这里更新动态的分享数(如果需要的话)
  1142. console.log("分享成功,动态ID:", currentDetail.value.id);
  1143. } else {
  1144. ElMessage.error(res.message || "分享失败");
  1145. }
  1146. } catch (error) {
  1147. console.error("分享失败:", error);
  1148. ElMessage.error("分享失败");
  1149. } finally {
  1150. shareSubmitting.value = false;
  1151. }
  1152. };
  1153. // 关闭分享对话框
  1154. const handleCloseShareDialog = () => {
  1155. shareSearch.value = "";
  1156. selectedFriends.value = [];
  1157. shareFriendList.value = [];
  1158. };
  1159. // 显示评论
  1160. const handleShowComments = async () => {
  1161. if (!currentDetail.value) return;
  1162. commentDrawerVisible.value = true;
  1163. await loadCommentList();
  1164. };
  1165. // 加载评论列表
  1166. const loadCommentList = async () => {
  1167. if (!currentDetail.value) return;
  1168. try {
  1169. const phone = userStore.userInfo?.phone || "";
  1170. const phoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1171. let params = {
  1172. businessId: String(currentDetail.value.id),
  1173. businessType: "2",
  1174. replyStatus: 0,
  1175. pageNum: 1,
  1176. pageSize: 100,
  1177. commentType: 0,
  1178. days: "",
  1179. phoneId: phoneId
  1180. };
  1181. const res: any = await commentList(params);
  1182. if (res.code === 200) {
  1183. commentListData.value = res.data.records || [];
  1184. // 更新评论总数(包括回复数)
  1185. if (currentDetail.value) {
  1186. const baseCommentCount = res.data.total || 0;
  1187. // 计算所有回复的总数
  1188. const replyCount = commentListData.value.reduce((total, comment) => {
  1189. return total + (comment.storeComment?.length || 0);
  1190. }, 0);
  1191. // 评论总数 = 评论数 + 回复数
  1192. currentDetail.value.commentCount = baseCommentCount + replyCount;
  1193. }
  1194. console.log("评论列表:", commentListData.value);
  1195. console.log("评论总数:", res.data.total);
  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 : "", // 回复评论时传评论ID,否则为空
  1265. commentContent: commentInput.value,
  1266. businessType: "2",
  1267. businessId: String(currentDetail.value.id),
  1268. storeId: userStore.userInfo?.storeId || userStore.userInfo?.createdId,
  1269. commentStar: "",
  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.userImage || item.avatar || item.headImg || "",
  1614. description: 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>