userDynamic.vue 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530
  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. @focus="loadGiftCouponList(giftCouponFormData.giftType)"
  502. @change="onGiftRowCouponChange(row)"
  503. >
  504. <el-option
  505. v-for="coupon in giftCouponList"
  506. :key="coupon.id"
  507. :label="coupon.name"
  508. :value="coupon.id"
  509. :disabled="isGiftCouponSelectedInOtherRow(coupon.id, index)"
  510. />
  511. </el-select>
  512. <div class="quantity-cell">
  513. <el-input
  514. type="number"
  515. :model-value="row.quantity"
  516. placeholder="请输入赠券数量"
  517. class="quantity-input"
  518. :min="1"
  519. :max="getGiftRowMaxQuantity(row)"
  520. @input="(val: string | number) => setGiftRowQuantity(row, val)"
  521. />
  522. <span v-if="row.couponId" class="quantity-limit-hint"> 最多可赠 {{ getGiftRowMaxQuantity(row) }} 张 </span>
  523. </div>
  524. <el-button type="danger" link :icon="Delete" circle title="删除" @click="removeGiftCouponRow(index)" />
  525. </div>
  526. <el-button type="primary" link class="add-coupon-btn" @click="addGiftCouponRow">
  527. <el-icon><Plus /></el-icon>
  528. 添加商家优惠券
  529. </el-button>
  530. </div>
  531. </div>
  532. <template #footer>
  533. <div class="dialog-footer">
  534. <el-button @click="closeGiftCouponDialog"> 取消 </el-button>
  535. <el-button type="primary" :disabled="!canSubmitGiftCoupon" @click="handleGiftCouponSubmit"> 确定 </el-button>
  536. </div>
  537. </template>
  538. </el-dialog>
  539. </div>
  540. </template>
  541. <script setup lang="ts" name="userDynamic">
  542. import { ref, reactive, computed, onMounted, watch } from "vue";
  543. import { useRoute, useRouter } from "vue-router";
  544. import { ElMessage, ElMessageBox } from "element-plus";
  545. import {
  546. Avatar,
  547. Picture,
  548. View,
  549. Close,
  550. Share,
  551. MoreFilled,
  552. Plus,
  553. Delete,
  554. Warning,
  555. CircleClose,
  556. ChatDotRound,
  557. CircleCheck
  558. } from "@element-plus/icons-vue";
  559. import {
  560. reportUserViolation,
  561. blockUser,
  562. getUserByPhone,
  563. likeDynamicNew,
  564. unlikeDynamicNew
  565. } from "@/api/modules/dynamicManagement";
  566. import {
  567. getUserDynamicsList,
  568. cancelFollewed,
  569. toggleFollowUser,
  570. getMutualAttention,
  571. addTransferCount,
  572. getCouponList,
  573. setFriendCoupon,
  574. saveComment,
  575. commentList
  576. } from "@/api/modules/newLoginApi";
  577. import { uploadImg } from "@/api/modules/upload";
  578. import { useUserStore } from "@/stores/modules/user";
  579. import { localGet } from "@/utils";
  580. import { s } from "node_modules/vite/dist/node/types.d-aGj9QkWt";
  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. let giftCouponRowKey = 0;
  1081. const giftCouponFormData = reactive<{
  1082. friendId: string | number;
  1083. giftType: "coupon" | "voucher";
  1084. rows: { key: number; couponId: string | number; quantity: number }[];
  1085. }>({
  1086. friendId: "",
  1087. giftType: "coupon",
  1088. rows: [{ key: ++giftCouponRowKey, couponId: "", quantity: 1 }]
  1089. });
  1090. const loadGiftFriendList = async () => {
  1091. giftFriendListLoading.value = true;
  1092. try {
  1093. const phone = userStore.userInfo?.phone || "";
  1094. const fansId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1095. const res: any = await getMutualAttention({ page: 1, size: 999, fansId, name: "" });
  1096. if (res?.code === 200) {
  1097. const records = res.data?.records || res.data?.list || res.data || [];
  1098. giftFriendList.value = records.map((item: any) => ({
  1099. id: item.id ?? item.userId,
  1100. name: item.username ?? item.userName ?? item.nickname ?? "用户",
  1101. phoneId: item.phoneId ?? item.fansId
  1102. }));
  1103. const target = giftFriendList.value.find(
  1104. (f: any) => String(f.phoneId) === targetPhoneId.value || String(f.id) === targetUserId.value
  1105. );
  1106. if (target) giftCouponFormData.friendId = target.id;
  1107. } else {
  1108. giftFriendList.value = [];
  1109. }
  1110. } catch {
  1111. giftFriendList.value = [];
  1112. } finally {
  1113. giftFriendListLoading.value = false;
  1114. }
  1115. };
  1116. const loadGiftCouponList = async (giftType: "coupon" | "voucher" = giftCouponFormData.giftType) => {
  1117. try {
  1118. const storeId = localGet("createdId") || userStore.userInfo?.storeId || userStore.userInfo?.createdId;
  1119. let params: any = {};
  1120. if (giftType === "coupon") {
  1121. params = { storeId, status: 0 };
  1122. } else if (giftType === "voucher") {
  1123. params = { storeId, status: 0, type: 4 };
  1124. }
  1125. const api = getCouponList;
  1126. const res: any = await api(params);
  1127. if (res?.code === 200) {
  1128. const list = res.data?.records ?? res.data?.list ?? res.data ?? [];
  1129. const rawList = Array.isArray(list) ? list : [];
  1130. if (giftType === "coupon") {
  1131. giftCouponList.value = rawList.map((item: any) => ({
  1132. id: item.id ?? item.couponId,
  1133. name: item.name ?? item.couponName ?? "",
  1134. singleQty: item.singleQty != null ? Number(item.singleQty) : 100
  1135. }));
  1136. } else if (giftType === "voucher") {
  1137. giftCouponList.value = rawList.map((item: any) => ({
  1138. id: item.voucherId,
  1139. name: item.name ?? "",
  1140. singleQty: item.singleQty != null ? Number(item.singleQty) : 100
  1141. }));
  1142. }
  1143. } else {
  1144. giftCouponList.value = [];
  1145. giftCouponListLoaded.value = true;
  1146. }
  1147. } catch {
  1148. giftCouponList.value = [];
  1149. } finally {
  1150. }
  1151. };
  1152. const addGiftCouponRow = () => {
  1153. giftCouponFormData.rows.push({
  1154. key: ++giftCouponRowKey,
  1155. couponId: "",
  1156. quantity: 1
  1157. });
  1158. };
  1159. const removeGiftCouponRow = (index: number) => {
  1160. giftCouponFormData.rows.splice(index, 1);
  1161. };
  1162. // 判断该券是否已被其他行选中(当前行可选,其他行已选则禁用)
  1163. const isGiftCouponSelectedInOtherRow = (couponId: string | number, currentRowIndex: number) => {
  1164. return giftCouponFormData.rows.some(
  1165. (row, i) => i !== currentRowIndex && row.couponId !== "" && row.couponId != null && String(row.couponId) === String(couponId)
  1166. );
  1167. };
  1168. // 根据所选券的 singleQty 限制该行数量上限
  1169. const getGiftRowMaxQuantity = (row: { couponId: string | number; quantity: number }) => {
  1170. if (row.couponId === "" || row.couponId == null) return 100;
  1171. const coupon = giftCouponList.value.find((c: any) => String(c.id) === String(row.couponId));
  1172. const max = coupon?.singleQty != null ? Number(coupon.singleQty) : 100;
  1173. return Math.max(1, max);
  1174. };
  1175. // 切换所选券时,若当前数量超过新券 singleQty 则自动压到上限
  1176. const onGiftRowCouponChange = (row: { couponId: string | number; quantity: number }) => {
  1177. const max = getGiftRowMaxQuantity(row);
  1178. if (row.quantity > max) row.quantity = max;
  1179. };
  1180. // 输入时即时限制:不允许超出最大数量,输入即截断,输入框从不显示超出的数
  1181. const setGiftRowQuantity = (row: { couponId: string | number; quantity: number }, val: string | number | undefined) => {
  1182. const max = getGiftRowMaxQuantity(row);
  1183. const num = val === "" || val == null || Number.isNaN(Number(val)) ? 1 : Number(val);
  1184. row.quantity = Math.min(Math.max(1, num), max);
  1185. };
  1186. // 严格校验:赠送对象存在 + 至少一行已选券且数量有效 + 每一行要么未选券(可忽略)要么已选券且数量有效,不允许存在「未选券但占着一行」的不完整行
  1187. const canSubmitGiftCoupon = computed(() => {
  1188. if (!giftCouponFormData.friendId) return false;
  1189. const validRows = giftCouponFormData.rows.filter(r => r.couponId !== "" && r.couponId != null && r.quantity >= 1);
  1190. if (validRows.length < 1) return false;
  1191. // 存在未选券的行则不允许提交(避免一行有券、一行没选券仍能点确定)
  1192. const hasIncompleteRow = giftCouponFormData.rows.some(r => (r.couponId === "" || r.couponId == null) && r.quantity >= 1);
  1193. return !hasIncompleteRow;
  1194. });
  1195. const closeGiftCouponDialog = () => {
  1196. giftCouponDialogVisible.value = false;
  1197. giftCouponFormData.friendId = "";
  1198. giftCouponFormData.giftType = "coupon";
  1199. giftCouponFormData.rows = [{ key: ++giftCouponRowKey, couponId: "", quantity: 1 }];
  1200. giftCouponListLoaded.value = false;
  1201. };
  1202. const handleGiftCouponSubmit = async () => {
  1203. if (!giftCouponFormData.friendId) {
  1204. ElMessage.warning("数据填写不完整,无法确定赠送对象");
  1205. return;
  1206. }
  1207. const validRows = giftCouponFormData.rows.filter(r => r.couponId !== "" && r.couponId != null && r.quantity >= 1);
  1208. if (validRows.length === 0) {
  1209. ElMessage.warning("数据填写不完整,请至少选择一张优惠券并填写数量");
  1210. return;
  1211. }
  1212. const hasIncompleteRow = giftCouponFormData.rows.some(r => (r.couponId === "" || r.couponId == null) && r.quantity >= 1);
  1213. if (hasIncompleteRow) {
  1214. ElMessage.warning("数据填写不完整,请为每一行选择优惠券或删除未选券的行");
  1215. return;
  1216. }
  1217. if (!canSubmitGiftCoupon.value) {
  1218. ElMessage.warning("数据填写不完整,请至少选择一张优惠券并填写数量");
  1219. return;
  1220. }
  1221. try {
  1222. let params: any = {};
  1223. if (giftCouponFormData.giftType === "coupon") {
  1224. params = {
  1225. couponIds: validRows.map(r => ({
  1226. couponId: r.couponId,
  1227. singleQty: r.quantity
  1228. })),
  1229. friendStoreUserId: String(giftCouponFormData.friendId)
  1230. };
  1231. } else if (giftCouponFormData.giftType === "voucher") {
  1232. params = {
  1233. voucherIds: validRows.map(r => ({
  1234. voucherId: r.couponId,
  1235. singleQty: r.quantity
  1236. })),
  1237. friendStoreUserId: String(giftCouponFormData.friendId)
  1238. };
  1239. }
  1240. const res: any = await setFriendCoupon(params);
  1241. if (res?.code === 200) {
  1242. ElMessage.success("赠送成功");
  1243. closeGiftCouponDialog();
  1244. } else {
  1245. ElMessage.error(res?.msg || "赠送失败");
  1246. }
  1247. } catch (error: any) {
  1248. console.error("赠送失败:", error);
  1249. ElMessage.error(error?.message || "赠送失败");
  1250. }
  1251. };
  1252. // 赠券:打开赠送好友优惠券弹窗(不跳转)
  1253. const handleGiftCoupon = () => {
  1254. giftCouponDialogVisible.value = true;
  1255. loadGiftFriendList();
  1256. loadGiftCouponList();
  1257. };
  1258. // 切换优惠券/代金券时:清空下拉列表、只保留一行选择,下次聚焦下拉时按类型重新加载
  1259. watch(
  1260. () => giftCouponFormData.giftType,
  1261. () => {
  1262. giftCouponList.value = [];
  1263. giftCouponListLoaded.value = false;
  1264. giftCouponFormData.rows = [{ key: ++giftCouponRowKey, couponId: "", quantity: 1 }];
  1265. }
  1266. );
  1267. // 举报用户
  1268. const handleReportUser = () => {
  1269. reportDialogVisible.value = true;
  1270. };
  1271. // 举报动态(从详情页)
  1272. const handleReportDynamic = () => {
  1273. reportDialogVisible.value = true;
  1274. };
  1275. // 拉黑用户(点击菜单项)
  1276. const handleBlockUserClick = () => {
  1277. handleBlockUser(false);
  1278. };
  1279. // 从详情页拉黑用户
  1280. const handleBlockUserFromDrawer = () => {
  1281. handleBlockUser(false);
  1282. };
  1283. // 拉黑用户
  1284. const handleBlockUser = async (skipConfirm: boolean = false) => {
  1285. try {
  1286. if (!skipConfirm) {
  1287. await ElMessageBox.confirm("拉黑后将不再看到该用户的动态,确定要拉黑吗?", "拉黑确认", {
  1288. confirmButtonText: "确定拉黑",
  1289. cancelButtonText: "取消",
  1290. type: "warning"
  1291. });
  1292. }
  1293. const phone = userStore.userInfo?.phone || "";
  1294. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1295. const currentUserId = userStore.userInfo?.id || userStore.userInfo?.userId || "";
  1296. const currentUserType = userStore.userInfo?.userType || userStore.userInfo?.type || 1;
  1297. // 从 targetPhoneId 解析被拉黑用户类型
  1298. const prefix = targetPhoneId.value.split("_")[0];
  1299. const blockedUserType = prefix === "store" ? 1 : 2;
  1300. await blockUser({
  1301. blockerType: currentUserType,
  1302. blockedType: blockedUserType,
  1303. blockerId: currentUserId,
  1304. blockedId: targetUserId.value
  1305. });
  1306. if (!skipConfirm) {
  1307. ElMessage.success("已拉黑该用户");
  1308. }
  1309. // 返回上一页
  1310. router.back();
  1311. } catch (error) {
  1312. if (!skipConfirm && error !== "cancel") {
  1313. console.error("拉黑失败:", error);
  1314. ElMessage.error("拉黑失败");
  1315. } else if (skipConfirm) {
  1316. throw error;
  1317. }
  1318. }
  1319. };
  1320. // 举报图片预览
  1321. const handleReportPreview = (uploadFile: any) => {
  1322. console.log("预览图片", uploadFile);
  1323. };
  1324. // 移除举报图片
  1325. const handleReportRemove = (uploadFile: any, uploadFiles: any[]) => {
  1326. // 已由 v-model:file-list 自动处理
  1327. };
  1328. // 举报图片上传前验证
  1329. const beforeReportUpload = (file: File) => {
  1330. const isImage = file.type.startsWith("image/");
  1331. const isLt5M = file.size / 1024 / 1024 < 5;
  1332. if (!isImage) {
  1333. ElMessage.error("只能上传图片文件!");
  1334. return false;
  1335. }
  1336. if (!isLt5M) {
  1337. ElMessage.error("图片大小不能超过 5MB!");
  1338. return false;
  1339. }
  1340. return true;
  1341. };
  1342. // 自定义举报图片上传
  1343. const handleReportUpload = async (options: any) => {
  1344. const { file, onSuccess, onError } = options;
  1345. try {
  1346. const uploadFormData = new FormData();
  1347. uploadFormData.append("file", file);
  1348. const response: any = await uploadImg(uploadFormData);
  1349. if (response && response.code === 200 && response.data && Array.isArray(response.data) && response.data.length > 0) {
  1350. onSuccess({
  1351. url: response.data[0]
  1352. });
  1353. } else {
  1354. ElMessage.error(response?.msg || "图片上传失败");
  1355. onError(new Error(response?.msg || "图片上传失败"));
  1356. }
  1357. } catch (error) {
  1358. console.error("图片上传失败:", error);
  1359. ElMessage.error("图片上传失败");
  1360. onError(error);
  1361. }
  1362. };
  1363. // 提交举报
  1364. const handleSubmitReport = async () => {
  1365. if (!reportForm.reason) {
  1366. ElMessage.warning("请选择举报原因");
  1367. return;
  1368. }
  1369. if (reportForm.reason === "其他举报" && !reportForm.description.trim()) {
  1370. ElMessage.warning("请填写详细描述");
  1371. return;
  1372. }
  1373. reportSubmitting.value = true;
  1374. try {
  1375. const violationType = violationTypeMap[reportForm.reason];
  1376. const reportEvidenceImg = reportForm.fileList
  1377. .map((f: any) => f.url || f.response?.url)
  1378. .filter(Boolean)
  1379. .join(",");
  1380. const currentUserId = userStore.userInfo?.id || userStore.userInfo?.userId || "";
  1381. const currentUserType = userStore.userInfo?.userType || userStore.userInfo?.type || 1;
  1382. // 从 targetPhoneId 解析被举报用户类型
  1383. const prefix = targetPhoneId.value.split("_")[0];
  1384. const reportedUserType = prefix === "store" ? 1 : 2;
  1385. // 根据手机号获取被举报人ID
  1386. let reportedUserId = targetUserId.value;
  1387. if (targetUserPhone.value) {
  1388. try {
  1389. const userRes = await getUserByPhone({ phone: targetUserPhone.value });
  1390. const userData = userRes.data as any;
  1391. if (userData && userData.id) {
  1392. reportedUserId = userData.id;
  1393. }
  1394. } catch (error) {
  1395. console.error("获取被举报人ID失败:", error);
  1396. }
  1397. }
  1398. await reportUserViolation({
  1399. dynamicsId: 0, // 举报用户不需要dynamicsId
  1400. reportContextType: "1", // 1表示举报用户
  1401. violationType: violationType,
  1402. otherReasonContent: reportForm.reason === "其他举报" ? reportForm.description : "",
  1403. reportEvidenceImg: reportEvidenceImg,
  1404. reportedUserId: reportedUserId,
  1405. reportedUserType: reportedUserType,
  1406. reportingUserId: currentUserId,
  1407. reportingUserType: currentUserType
  1408. });
  1409. if (reportForm.agreed) {
  1410. try {
  1411. await handleBlockUser(true);
  1412. ElMessage.success("举报提交成功,已拉黑该用户");
  1413. } catch (blockError) {
  1414. ElMessage.warning("举报提交成功,但拉黑失败");
  1415. }
  1416. } else {
  1417. ElMessage.success("举报提交成功,我们会尽快处理");
  1418. }
  1419. reportDialogVisible.value = false;
  1420. } catch (error) {
  1421. console.error("举报提交失败:", error);
  1422. ElMessage.error("举报提交失败");
  1423. } finally {
  1424. reportSubmitting.value = false;
  1425. }
  1426. };
  1427. // 关闭举报对话框
  1428. const handleCloseReportDialog = () => {
  1429. reportForm.reason = "用户头像";
  1430. reportForm.description = "";
  1431. reportForm.fileList = [];
  1432. reportForm.agreed = false;
  1433. };
  1434. // 监听举报原因变化
  1435. watch(
  1436. () => reportForm.reason,
  1437. newReason => {
  1438. if (newReason !== "其他举报") {
  1439. reportForm.description = "";
  1440. }
  1441. }
  1442. );
  1443. // 加载内容列表
  1444. const loadContentList = async () => {
  1445. try {
  1446. if (!targetPhoneId.value) {
  1447. ElMessage.warning("用户信息异常");
  1448. return;
  1449. }
  1450. // 获取当前登录用户的phoneId
  1451. const phone = userStore.userInfo?.phone || "";
  1452. const currentUserPhoneId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1453. console.log("目标用户phoneId:", targetPhoneId.value);
  1454. const res = await getUserDynamicsList({
  1455. myselfPhoneId: currentUserPhoneId, // 当前登录用户的phoneId
  1456. phoneId: targetPhoneId.value, // 目标用户的phoneId
  1457. type: 2,
  1458. page: pagination.page,
  1459. size: pagination.pageSize
  1460. });
  1461. if (res.data) {
  1462. const responseData = res.data as any;
  1463. const list = responseData.lifeUserDynamics || [];
  1464. // 更新用户信息(从 storeUser 字段)
  1465. if (responseData.storeUser) {
  1466. const storeUserData = responseData.storeUser;
  1467. userInfo.name = storeUserData.storeName || storeUserData.userName || storeUserData.name || userInfo.name;
  1468. userInfo.avatar = storeUserData.avatar || storeUserData.headImg || userInfo.avatar;
  1469. userInfo.jianjie = storeUserData.jianjie || storeUserData.storeBlurb || storeUserData.bio || userInfo.jianjie || "";
  1470. userInfo.followCount = responseData.followListSum || 0;
  1471. userInfo.fansCount = responseData.fansListSum || 0;
  1472. userInfo.likeCount = responseData.likeListSum || 0;
  1473. }
  1474. // 更新关注状态(0未关注,1已关注)
  1475. const isFollowedValue = responseData.isFollowed ?? responseData.isFollow ?? 0;
  1476. isFollowed.value = isFollowedValue === 1;
  1477. contentList.value = list.map((item: any) => ({
  1478. id: item.id || item.dynamicId,
  1479. title: item.title || item.content || item.dynamicContent || "",
  1480. coverUrl: item.imagePath || item.coverUrl || "",
  1481. likeCount: item.likeCount || item.praiseCount || 0,
  1482. isLiked: item.isLiked || item.isPraise || false,
  1483. createTime: item.createTime || item.createDate || "",
  1484. dianzanCount: item.dianzanCount || 0
  1485. }));
  1486. pagination.total = responseData.total || responseData.totalCount || list.length;
  1487. }
  1488. } catch (error) {
  1489. console.error("加载动态失败:", error);
  1490. ElMessage.error("加载动态失败");
  1491. }
  1492. };
  1493. // 加载是否与当前主页用户互为好友(用于展示赠券入口)
  1494. const loadIsFriend = async () => {
  1495. if (!targetPhoneId.value) return;
  1496. try {
  1497. const phone = userStore.userInfo?.phone || "";
  1498. const fansId = phone.startsWith("store_") ? phone : `store_${phone}`;
  1499. const res: any = await getMutualAttention({
  1500. page: 1,
  1501. size: 1000,
  1502. fansId,
  1503. name: ""
  1504. });
  1505. if (res?.code === 200) {
  1506. const dataList = res.data?.records || res.data?.list || res.data || [];
  1507. isFriend.value = dataList.some(
  1508. (item: any) => (item.phoneId || item.fansId || item.storeUserId || "") === targetPhoneId.value
  1509. );
  1510. }
  1511. } catch {
  1512. isFriend.value = false;
  1513. }
  1514. };
  1515. // 初始化
  1516. onMounted(() => {
  1517. loadContentList();
  1518. loadIsFriend();
  1519. });
  1520. </script>
  1521. <style scoped lang="scss">
  1522. .user-dynamic-container {
  1523. min-height: calc(100vh - 120px);
  1524. padding: 20px;
  1525. background: #ffffff;
  1526. // 用户信息卡片
  1527. .user-card {
  1528. padding: 24px;
  1529. margin-bottom: 20px;
  1530. background: #ffffff;
  1531. border: 1px solid #e4e7ed;
  1532. border-radius: 8px;
  1533. .user-header {
  1534. display: flex;
  1535. align-items: flex-start;
  1536. justify-content: space-between;
  1537. margin-bottom: 16px;
  1538. .user-avatar-section {
  1539. display: flex;
  1540. flex: 1;
  1541. gap: 16px;
  1542. align-items: center;
  1543. .user-avatar-large {
  1544. display: flex;
  1545. flex-shrink: 0;
  1546. align-items: center;
  1547. justify-content: center;
  1548. width: 80px;
  1549. height: 80px;
  1550. overflow: hidden;
  1551. background: #f5f7fa;
  1552. border-radius: 50%;
  1553. img {
  1554. width: 100%;
  1555. height: 100%;
  1556. object-fit: cover;
  1557. }
  1558. }
  1559. .user-info-text {
  1560. flex: 1;
  1561. .user-name {
  1562. margin-bottom: 8px;
  1563. font-size: 20px;
  1564. font-weight: 600;
  1565. color: #303133;
  1566. }
  1567. .user-stats {
  1568. display: flex;
  1569. gap: 8px;
  1570. align-items: center;
  1571. font-size: 14px;
  1572. color: #606266;
  1573. .stat-item {
  1574. cursor: pointer;
  1575. transition: color 0.3s;
  1576. &:hover {
  1577. color: #409eff;
  1578. }
  1579. }
  1580. .stat-divider {
  1581. color: #dcdfe6;
  1582. }
  1583. }
  1584. }
  1585. }
  1586. .user-actions {
  1587. display: flex;
  1588. gap: 12px;
  1589. align-items: center;
  1590. :deep(.el-button) {
  1591. min-width: 80px;
  1592. }
  1593. }
  1594. }
  1595. .user-bio {
  1596. font-size: 14px;
  1597. line-height: 1.6;
  1598. color: #606266;
  1599. }
  1600. }
  1601. // 标签页区域
  1602. .tabs-section {
  1603. margin-bottom: 20px;
  1604. border-bottom: 1px solid #e4e7ed;
  1605. :deep(.el-tabs) {
  1606. .el-tabs__header {
  1607. margin-bottom: 0;
  1608. }
  1609. .el-tabs__nav-wrap::after {
  1610. display: none;
  1611. }
  1612. }
  1613. }
  1614. // 内容区域
  1615. .content-section {
  1616. margin-top: 20px;
  1617. }
  1618. // 内容网格布局
  1619. .content-grid {
  1620. display: grid;
  1621. grid-template-columns: repeat(4, 1fr);
  1622. gap: 16px;
  1623. margin-bottom: 20px;
  1624. @media (width <= 1400px) {
  1625. grid-template-columns: repeat(3, 1fr);
  1626. }
  1627. @media (width <= 1024px) {
  1628. grid-template-columns: repeat(2, 1fr);
  1629. }
  1630. @media (width <= 768px) {
  1631. grid-template-columns: repeat(1, 1fr);
  1632. }
  1633. }
  1634. // 内容卡片
  1635. .content-card {
  1636. cursor: pointer;
  1637. border: 1px solid #e4e7ed;
  1638. border-radius: 8px;
  1639. transition: all 0.3s;
  1640. &:hover {
  1641. box-shadow: 0 2px 12px rgb(0 0 0 / 10%);
  1642. transform: translateY(-2px);
  1643. }
  1644. // 封面区域
  1645. .content-cover-wrapper {
  1646. position: relative;
  1647. width: 100%;
  1648. aspect-ratio: 16 / 9;
  1649. margin-bottom: 8px;
  1650. overflow: hidden;
  1651. background: #f5f7fa;
  1652. border-radius: 8px;
  1653. .content-cover {
  1654. width: 100%;
  1655. height: 100%;
  1656. object-fit: cover;
  1657. }
  1658. .cover-placeholder {
  1659. display: flex;
  1660. align-items: center;
  1661. justify-content: center;
  1662. width: 100%;
  1663. height: 100%;
  1664. background: #f5f7fa;
  1665. }
  1666. }
  1667. // 底部信息
  1668. .content-footer {
  1669. display: flex;
  1670. align-items: center;
  1671. justify-content: space-between;
  1672. padding: 0 4px;
  1673. .footer-left {
  1674. display: flex;
  1675. gap: 4px;
  1676. align-items: center;
  1677. padding-top: 5px;
  1678. }
  1679. .footer-right {
  1680. display: flex;
  1681. gap: 4px;
  1682. align-items: center;
  1683. padding-top: 5px;
  1684. }
  1685. .view-count,
  1686. .like-count {
  1687. font-size: 13px;
  1688. color: #666666;
  1689. }
  1690. }
  1691. }
  1692. // 空状态
  1693. .empty-section {
  1694. padding: 80px 0;
  1695. text-align: center;
  1696. }
  1697. // 分页
  1698. .pagination-section {
  1699. display: flex;
  1700. justify-content: center;
  1701. padding: 20px 0;
  1702. margin-top: 30px;
  1703. }
  1704. // 详情 Drawer
  1705. :deep(.detail-drawer) {
  1706. .el-drawer__header {
  1707. position: absolute;
  1708. top: 0;
  1709. right: 0;
  1710. left: 0;
  1711. z-index: 10;
  1712. padding: 0;
  1713. margin: 0;
  1714. background: transparent;
  1715. }
  1716. .el-drawer__body {
  1717. padding: 0;
  1718. background: #000000;
  1719. }
  1720. .drawer-header {
  1721. padding: 20px;
  1722. .close-btn {
  1723. padding: 8px;
  1724. font-size: 24px;
  1725. color: #ffffff;
  1726. background: #ffffff;
  1727. }
  1728. }
  1729. .detail-content {
  1730. position: relative;
  1731. display: flex;
  1732. width: 100%;
  1733. height: 100%;
  1734. // 主内容区域
  1735. .detail-main {
  1736. display: flex;
  1737. flex: 1;
  1738. flex-direction: column;
  1739. align-items: center;
  1740. justify-content: center;
  1741. padding: 80px 120px 40px 40px;
  1742. .media-container {
  1743. position: relative;
  1744. display: flex;
  1745. flex: 1;
  1746. align-items: center;
  1747. justify-content: center;
  1748. width: 100%;
  1749. max-width: 800px;
  1750. min-height: 400px;
  1751. .media-carousel {
  1752. width: 100%;
  1753. height: 100%;
  1754. min-height: 400px;
  1755. max-height: 70vh;
  1756. :deep(.el-carousel__container) {
  1757. height: 100% !important;
  1758. min-height: 400px;
  1759. }
  1760. :deep(.el-carousel__item) {
  1761. display: flex;
  1762. align-items: center;
  1763. justify-content: center;
  1764. background: transparent;
  1765. }
  1766. :deep(.el-carousel__arrow) {
  1767. width: 48px;
  1768. height: 48px;
  1769. font-size: 24px;
  1770. color: #ffffff;
  1771. background-color: rgb(0 0 0 / 40%);
  1772. border: none;
  1773. &:hover {
  1774. background-color: rgb(0 0 0 / 60%);
  1775. }
  1776. }
  1777. :deep(.el-carousel__indicators) {
  1778. bottom: -30px;
  1779. .el-carousel__indicator {
  1780. .el-carousel__button {
  1781. width: 8px;
  1782. height: 8px;
  1783. background-color: rgb(255 255 255 / 40%);
  1784. border-radius: 50%;
  1785. }
  1786. &.is-active .el-carousel__button {
  1787. background-color: #409eff;
  1788. }
  1789. }
  1790. }
  1791. }
  1792. .detail-media {
  1793. max-width: 100%;
  1794. max-height: 65vh;
  1795. object-fit: contain;
  1796. border-radius: 8px;
  1797. }
  1798. .detail-image {
  1799. max-width: 100%;
  1800. max-height: 65vh;
  1801. object-fit: contain;
  1802. border-radius: 8px;
  1803. }
  1804. .detail-video {
  1805. width: 100%;
  1806. max-height: 65vh;
  1807. background: #000000;
  1808. border-radius: 8px;
  1809. }
  1810. .media-placeholder {
  1811. display: flex;
  1812. align-items: center;
  1813. justify-content: center;
  1814. width: 400px;
  1815. height: 400px;
  1816. background: rgb(255 255 255 / 5%);
  1817. border-radius: 8px;
  1818. }
  1819. .media-counter {
  1820. position: absolute;
  1821. right: 16px;
  1822. bottom: -24px;
  1823. padding: 4px 12px;
  1824. font-size: 14px;
  1825. color: #ffffff;
  1826. background: rgb(0 0 0 / 50%);
  1827. border-radius: 12px;
  1828. }
  1829. }
  1830. .detail-info {
  1831. width: 100%;
  1832. max-width: 800px;
  1833. padding: 20px 0;
  1834. .author-info {
  1835. display: flex;
  1836. gap: 12px;
  1837. align-items: center;
  1838. margin-bottom: 16px;
  1839. .author-avatar {
  1840. display: flex;
  1841. align-items: center;
  1842. justify-content: center;
  1843. width: 40px;
  1844. height: 40px;
  1845. overflow: hidden;
  1846. background: rgb(255 255 255 / 10%);
  1847. border-radius: 50%;
  1848. img {
  1849. width: 100%;
  1850. height: 100%;
  1851. object-fit: cover;
  1852. }
  1853. }
  1854. .author-details {
  1855. flex: 1;
  1856. .author-name {
  1857. margin-bottom: 4px;
  1858. font-size: 16px;
  1859. font-weight: 500;
  1860. color: #ffffff;
  1861. }
  1862. .publish-time {
  1863. font-size: 13px;
  1864. color: rgb(255 255 255 / 60%);
  1865. }
  1866. }
  1867. }
  1868. .detail-description {
  1869. font-size: 15px;
  1870. line-height: 1.6;
  1871. color: #ffffff;
  1872. p {
  1873. margin: 0;
  1874. }
  1875. }
  1876. }
  1877. }
  1878. // 右侧操作栏
  1879. .action-bar {
  1880. position: fixed;
  1881. right: 40px;
  1882. bottom: 100px;
  1883. z-index: 10;
  1884. display: flex;
  1885. flex-direction: column;
  1886. gap: 24px;
  1887. .action-item {
  1888. display: flex;
  1889. flex-direction: column;
  1890. gap: 6px;
  1891. align-items: center;
  1892. cursor: pointer;
  1893. transition: transform 0.3s;
  1894. &:hover {
  1895. transform: scale(1.1);
  1896. }
  1897. &.author-action {
  1898. cursor: default;
  1899. &:hover {
  1900. transform: none;
  1901. }
  1902. }
  1903. .action-avatar {
  1904. position: relative;
  1905. display: flex;
  1906. align-items: center;
  1907. justify-content: center;
  1908. width: 48px;
  1909. height: 48px;
  1910. overflow: visible;
  1911. background: rgb(255 255 255 / 20%);
  1912. border: 2px solid #ffffff;
  1913. border-radius: 50%;
  1914. img {
  1915. width: 100%;
  1916. height: 100%;
  1917. object-fit: cover;
  1918. border-radius: 50%;
  1919. }
  1920. .follow-badge {
  1921. position: absolute;
  1922. right: -4px;
  1923. bottom: -4px;
  1924. z-index: 2;
  1925. display: flex;
  1926. align-items: center;
  1927. justify-content: center;
  1928. width: 24px;
  1929. height: 24px;
  1930. cursor: pointer;
  1931. background: #409eff;
  1932. border: 2px solid #ffffff;
  1933. border-radius: 50%;
  1934. transition: transform 0.2s;
  1935. &:hover {
  1936. transform: scale(1.15);
  1937. }
  1938. }
  1939. }
  1940. .action-icon {
  1941. display: flex;
  1942. align-items: center;
  1943. justify-content: center;
  1944. width: 48px;
  1945. height: 48px;
  1946. background: rgb(0 0 0 / 50%);
  1947. backdrop-filter: blur(10px);
  1948. border-radius: 50%;
  1949. &.follow-icon {
  1950. background: #409eff;
  1951. }
  1952. }
  1953. .action-count {
  1954. font-size: 13px;
  1955. color: #ffffff;
  1956. text-align: center;
  1957. text-shadow: 0 1px 3px rgb(0 0 0 / 50%);
  1958. }
  1959. }
  1960. }
  1961. }
  1962. }
  1963. // 更多操作 Popover
  1964. :deep(.more-actions-popover) {
  1965. min-width: 120px;
  1966. padding: 8px 0;
  1967. background: rgb(0 0 0 / 90%);
  1968. backdrop-filter: blur(10px);
  1969. border: 1px solid rgb(255 255 255 / 20%);
  1970. .more-actions-menu {
  1971. .menu-item {
  1972. display: flex;
  1973. gap: 8px;
  1974. align-items: center;
  1975. padding: 10px 16px;
  1976. font-size: 14px;
  1977. color: #ffffff;
  1978. cursor: pointer;
  1979. transition: background 0.3s;
  1980. &:hover {
  1981. background: rgb(255 255 255 / 10%);
  1982. }
  1983. .el-icon {
  1984. font-size: 18px;
  1985. }
  1986. }
  1987. }
  1988. }
  1989. // 举报对话框和分享对话框
  1990. :deep(.el-dialog) {
  1991. .report-dialog-content {
  1992. .report-tip {
  1993. margin-bottom: 20px;
  1994. font-size: 14px;
  1995. line-height: 1.6;
  1996. color: #606266;
  1997. }
  1998. .report-reasons {
  1999. margin-bottom: 20px;
  2000. .el-radio-group {
  2001. display: flex;
  2002. flex-wrap: wrap;
  2003. gap: 12px 16px;
  2004. .el-radio {
  2005. height: auto;
  2006. margin-right: 0;
  2007. white-space: nowrap;
  2008. .el-radio__label {
  2009. font-size: 14px;
  2010. color: #303133;
  2011. }
  2012. }
  2013. }
  2014. }
  2015. .report-description {
  2016. margin-bottom: 20px;
  2017. :deep(.el-textarea__inner) {
  2018. font-size: 14px;
  2019. }
  2020. }
  2021. .report-upload {
  2022. margin-bottom: 20px;
  2023. .upload-title {
  2024. margin-bottom: 12px;
  2025. font-size: 14px;
  2026. font-weight: 500;
  2027. color: #303133;
  2028. }
  2029. :deep(.el-upload-list) {
  2030. display: flex;
  2031. flex-wrap: wrap;
  2032. gap: 8px;
  2033. }
  2034. :deep(.el-upload--picture-card) {
  2035. width: 100px;
  2036. height: 100px;
  2037. border-radius: 4px;
  2038. }
  2039. :deep(.el-upload-list--picture-card .el-upload-list__item) {
  2040. width: 100px;
  2041. height: 100px;
  2042. margin: 0;
  2043. border-radius: 4px;
  2044. }
  2045. }
  2046. .report-agreement {
  2047. .el-checkbox {
  2048. .el-checkbox__label {
  2049. font-size: 14px;
  2050. color: #606266;
  2051. }
  2052. }
  2053. }
  2054. }
  2055. // 分享对话框
  2056. .share-dialog-content {
  2057. .search-box {
  2058. margin-bottom: 16px;
  2059. }
  2060. .share-friend-list {
  2061. max-height: 400px;
  2062. margin-bottom: 16px;
  2063. overflow-y: auto;
  2064. .share-friend-item {
  2065. display: flex;
  2066. align-items: center;
  2067. justify-content: space-between;
  2068. padding: 12px;
  2069. cursor: pointer;
  2070. border-radius: 8px;
  2071. transition: background-color 0.3s;
  2072. &:hover {
  2073. background-color: #f5f7fa;
  2074. }
  2075. .friend-info {
  2076. display: flex;
  2077. gap: 12px;
  2078. align-items: center;
  2079. .friend-avatar {
  2080. display: flex;
  2081. flex-shrink: 0;
  2082. align-items: center;
  2083. justify-content: center;
  2084. width: 40px;
  2085. height: 40px;
  2086. overflow: hidden;
  2087. background: #f5f5f5;
  2088. border-radius: 50%;
  2089. img {
  2090. width: 100%;
  2091. height: 100%;
  2092. object-fit: cover;
  2093. }
  2094. }
  2095. .friend-name {
  2096. font-size: 14px;
  2097. font-weight: 500;
  2098. color: #303133;
  2099. }
  2100. }
  2101. }
  2102. }
  2103. .selected-friends {
  2104. padding: 12px;
  2105. background: #f5f7fa;
  2106. border-radius: 8px;
  2107. .selected-title {
  2108. margin-bottom: 8px;
  2109. font-size: 13px;
  2110. color: #606266;
  2111. }
  2112. .selected-list {
  2113. display: flex;
  2114. flex-wrap: wrap;
  2115. gap: 8px;
  2116. .el-tag {
  2117. max-width: 120px;
  2118. overflow: hidden;
  2119. text-overflow: ellipsis;
  2120. white-space: nowrap;
  2121. }
  2122. }
  2123. }
  2124. }
  2125. .dialog-footer {
  2126. display: flex;
  2127. gap: 12px;
  2128. justify-content: flex-end;
  2129. }
  2130. }
  2131. // 评论侧边栏样式
  2132. .comment-list-container {
  2133. flex: 1;
  2134. height: calc(100vh - 200px);
  2135. padding: 0 20px;
  2136. overflow-y: auto;
  2137. .comment-list {
  2138. .comment-item {
  2139. display: flex;
  2140. gap: 12px;
  2141. padding: 16px 0;
  2142. border-bottom: 1px solid #f0f0f0;
  2143. &:last-child {
  2144. border-bottom: none;
  2145. }
  2146. .comment-avatar {
  2147. display: flex;
  2148. flex-shrink: 0;
  2149. align-items: center;
  2150. justify-content: center;
  2151. width: 40px;
  2152. height: 40px;
  2153. overflow: hidden;
  2154. background: #f5f5f5;
  2155. border-radius: 50%;
  2156. img {
  2157. width: 100%;
  2158. height: 100%;
  2159. object-fit: cover;
  2160. }
  2161. }
  2162. .comment-content-wrapper {
  2163. flex: 1;
  2164. min-width: 0;
  2165. .comment-header,
  2166. .store-comment-header {
  2167. display: flex;
  2168. align-items: center;
  2169. justify-content: space-between;
  2170. margin-bottom: 8px;
  2171. .comment-user-name {
  2172. font-size: 14px;
  2173. font-weight: 500;
  2174. color: #303133;
  2175. }
  2176. .comment-time {
  2177. font-size: 12px;
  2178. color: #909399;
  2179. }
  2180. }
  2181. .comment-text {
  2182. margin-bottom: 8px;
  2183. font-size: 14px;
  2184. line-height: 1.6;
  2185. color: #606266;
  2186. word-break: break-all;
  2187. }
  2188. // 商家回复样式
  2189. .store-comment-wrapper {
  2190. padding: 12px;
  2191. margin-top: 12px;
  2192. background: #f5f7fa;
  2193. border-radius: 8px;
  2194. .store-comment-item {
  2195. display: flex;
  2196. gap: 10px;
  2197. .store-comment-avatar {
  2198. display: flex;
  2199. flex-shrink: 0;
  2200. align-items: center;
  2201. justify-content: center;
  2202. width: 32px;
  2203. height: 32px;
  2204. overflow: hidden;
  2205. background: #ffffff;
  2206. border-radius: 50%;
  2207. img {
  2208. width: 100%;
  2209. height: 100%;
  2210. object-fit: cover;
  2211. }
  2212. }
  2213. .store-comment-content {
  2214. flex: 1;
  2215. min-width: 0;
  2216. .store-comment-header {
  2217. display: flex;
  2218. align-items: center;
  2219. justify-content: space-between;
  2220. margin-bottom: 6px;
  2221. .store-comment-user-name {
  2222. font-size: 13px;
  2223. font-weight: 500;
  2224. color: #409eff;
  2225. }
  2226. .store-comment-time {
  2227. font-size: 11px;
  2228. color: #909399;
  2229. }
  2230. }
  2231. .store-comment-text {
  2232. display: flex;
  2233. align-items: center;
  2234. justify-content: space-between;
  2235. font-size: 13px;
  2236. line-height: 1.5;
  2237. color: #606266;
  2238. word-break: break-all;
  2239. }
  2240. }
  2241. }
  2242. }
  2243. .comment-actions {
  2244. display: flex;
  2245. gap: 20px;
  2246. .comment-action-item {
  2247. display: flex;
  2248. gap: 4px;
  2249. align-items: center;
  2250. font-size: 13px;
  2251. color: #909399;
  2252. cursor: pointer;
  2253. transition: color 0.3s;
  2254. &:hover {
  2255. color: #409eff;
  2256. }
  2257. span {
  2258. font-size: 13px;
  2259. }
  2260. }
  2261. }
  2262. }
  2263. }
  2264. }
  2265. }
  2266. .comment-input-wrapper {
  2267. position: absolute;
  2268. right: 0;
  2269. bottom: 0;
  2270. left: 0;
  2271. padding: 16px 20px;
  2272. background: #ffffff;
  2273. border-top: 1px solid #e4e7ed;
  2274. box-shadow: 0 -2px 8px rgb(0 0 0 / 5%);
  2275. .reply-hint {
  2276. display: flex;
  2277. align-items: center;
  2278. justify-content: space-between;
  2279. padding: 8px 12px;
  2280. margin-bottom: 8px;
  2281. background: #f5f7fa;
  2282. border-radius: 4px;
  2283. .reply-text {
  2284. font-size: 13px;
  2285. color: #409eff;
  2286. }
  2287. .cancel-reply {
  2288. font-size: 16px;
  2289. color: #909399;
  2290. cursor: pointer;
  2291. transition: color 0.3s;
  2292. &:hover {
  2293. color: #f56c6c;
  2294. }
  2295. }
  2296. }
  2297. :deep(.el-textarea) {
  2298. margin-bottom: 12px;
  2299. }
  2300. .el-button {
  2301. width: 100%;
  2302. }
  2303. }
  2304. }
  2305. .gift-coupon-dialog-body {
  2306. .gift-type-section,
  2307. .coupon-rows-section {
  2308. margin-bottom: 20px;
  2309. }
  2310. .section-label {
  2311. margin-bottom: 12px;
  2312. font-size: 14px;
  2313. font-weight: 500;
  2314. color: var(--el-text-color-primary);
  2315. }
  2316. .coupon-row {
  2317. display: flex;
  2318. gap: 12px;
  2319. align-items: center;
  2320. align-items: start;
  2321. margin-bottom: 12px;
  2322. .quantity-cell {
  2323. display: flex;
  2324. flex-shrink: 0;
  2325. flex-direction: column;
  2326. gap: 4px;
  2327. }
  2328. .quantity-input {
  2329. width: 140px;
  2330. }
  2331. .quantity-limit-hint {
  2332. font-size: 12px;
  2333. line-height: 1.2;
  2334. color: var(--el-color-warning);
  2335. }
  2336. }
  2337. .add-coupon-btn {
  2338. display: inline-flex;
  2339. gap: 4px;
  2340. align-items: center;
  2341. padding-left: 0;
  2342. color: var(--el-color-primary);
  2343. }
  2344. }
  2345. </style>
  2346. <style scoped>
  2347. @import "@/assets/dianzanFont/iconfont.css";
  2348. </style>