userDynamic.vue 75 KB

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