businessDistrictDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <div class="mainBox">
  3. <div class="layerBox">
  4. <tableTitle :name="tableDivTitle" />
  5. <el-row>
  6. <template>
  7. <!-- 在此位置下面写 -->
  8. <div class="article-detail">
  9. <div class="article-card">
  10. <div class="article-title">
  11. {{ dataInfo.title }}
  12. <el-tag type="info" class="article-tag">{{ dataInfo.topicname }}</el-tag>
  13. </div>
  14. <div class="article-meta">
  15. <span class="article-meta-item1">{{ dataInfo.nickname }}</span>
  16. <span class="article-meta-item2">{{ dataInfo.group_name }}</span>
  17. <el-button class="top-button" type="primary" @click="viewGroupChat">查看群聊</el-button>
  18. </div>
  19. <el-divider></el-divider>
  20. <div class="background-color">
  21. <div class="article-author">
  22. <div class="article_box">
  23. <div
  24. class="article_panel"
  25. :class="{ collapsed: !isExpanded }"
  26. >
  27. <div v-html="dataInfo.content"></div>
  28. </div>
  29. <span
  30. class="article_panel_btn"
  31. v-if="!isExpanded"
  32. @click="toggleExpand"
  33. >阅读全文
  34. <i class="el-icon-arrow-down" ></i>
  35. </span>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="comment-section">
  41. <div class="box_1 clearfix">
  42. <div class="box_in">评论:</div>
  43. </div>
  44. <div class="comment-list">
  45. <div class="comment_li" v-for="(per_obj,keys) in replyList" :key="keys">
  46. <el-avatar
  47. class="comment_li_img"
  48. :src="per_obj.avatar"
  49. />
  50. <div class="comment_li_name">{{ per_obj.nickname }}:</div>
  51. <div class="comment_li_text">
  52. {{ per_obj.content }}
  53. </div>
  54. <div class="comment_li_time">{{ per_obj.created_at }}</div>
  55. </div>
  56. </div>
  57. <div class="alignBox">
  58. <el-row>
  59. <el-col :span="24">
  60. <el-pagination :current-page="getApiData.page" @size-change="handleSizeChange"
  61. @current-change="handleCurrentChange" :page-size="5" layout="total, prev, pager, next, jumper"
  62. :total="allCount"></el-pagination>
  63. </el-col>
  64. </el-row>
  65. </div>
  66. <div class="comment-actions">
  67. <el-button @click="goBack">返回</el-button>
  68. <el-button type="primary" @click="viewGroupChat">查看群聊</el-button>
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. </el-row>
  74. </div>
  75. </div>
  76. </template>
  77. <script>
  78. //表格标题
  79. import tableTitle from './components/tableTitle';
  80. //引入公用样式
  81. import '@/styles/global.less';
  82. import InputTag from '@/components/InputTag'
  83. import { getTopicDataInfo,getTopicReply} from '@/api/chat'
  84. import emitter from '@/eventBus';
  85. export default {
  86. components: {
  87. tableTitle,//表格标题
  88. InputTag
  89. },
  90. data() {
  91. let self = this;
  92. return {
  93. id:'',
  94. dataInfo:{},
  95. isExpanded: false, // btn添加展开状态
  96. //1.列表和分页相关 start ------------------------------------------------------------>
  97. tableDivTitle: "商圈详情",
  98. getApiData: {
  99. page: 1,//当前是第几页
  100. pageSize: 5,//一共多少条
  101. },
  102. allCount: 0,//总条数
  103. replyList:[],
  104. currentGroupId: null
  105. }
  106. },
  107. methods: {
  108. //1.4 列表内容分页
  109. //直接跳转
  110. handleSizeChange(val) {
  111. this.getApiData.page = val;
  112. this.getTopicReplyList();
  113. },
  114. //1.5 点击分页
  115. handleCurrentChange(val) {
  116. this.getApiData.page = val;
  117. this.getTopicReplyList();
  118. },
  119. toggleExpand() { // 添加切换方法
  120. this.isExpanded = true;
  121. },
  122. getDataINfo(){
  123. getTopicDataInfo({
  124. id:self.id
  125. }).then(data => {
  126. // this.loading=false;
  127. console.log("返回数据",data.data);
  128. this.dataInfo = data.data;
  129. console.log("赋值:",self.dataInfo)
  130. })
  131. },
  132. getTopicReplyList(){
  133. getTopicReply({
  134. id:self.id,
  135. page:this.getApiData.page,
  136. page_size:this.getApiData.pageSize
  137. }).then(data => {
  138. this.replyList = data.data.data;
  139. this.allCount = data.data.total;
  140. })
  141. },
  142. goBack() {
  143. this.$router.back();
  144. },
  145. viewGroupChat() {
  146. console.log('[businessDistrictDetail] 触发 view-group-chat 事件,id1:', this.dataInfo);
  147. emitter.emit('view-group-chat', this.dataInfo);
  148. },
  149. handleViewGroupChat(ids) {
  150. console.log('[businessDistrictDetail] 收到 view-group-chat 事件,id2:', ids);
  151. // 这里一般不需要监听自己发的事件,除非有特殊需求
  152. }
  153. },
  154. mounted() {
  155. // 1.获取详情数据
  156. self.id = this.$route.query.id+'';
  157. this.getDataINfo();
  158. this.getTopicReplyList();
  159. // 可选:如果你需要监听(一般只在调试时用)
  160. emitter.on('view-group-chat', this.handleViewGroupChat);
  161. },
  162. beforeDestroy() {
  163. emitter.off('view-group-chat', this.handleViewGroupChat);
  164. }
  165. }
  166. </script>
  167. <style scoped lang="less">
  168. .article-detail {
  169. // padding: 24px;
  170. // background: #f5f7fa;
  171. min-height: 100vh;
  172. .article-card {
  173. margin-bottom: 24px;
  174. padding: 24px 0px;
  175. background: #fff;
  176. // border-radius: 8px;
  177. // box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  178. .article-title {
  179. font-family: Microsoft YaHei, Microsoft YaHei;
  180. font-weight: bold;
  181. font-size: 28px;
  182. color: #333333;
  183. display: flex;
  184. align-items: center;
  185. .article-tag {
  186. background: rgba(85,112,241,0.16) !important;
  187. border-radius: 3px 3px 3px 3px !important;
  188. margin-left: 12px;
  189. font-size: 14px;
  190. height: 22px;
  191. line-height: 22px;
  192. padding: 0 10px;
  193. border-radius: 4px;
  194. font-weight: 400;
  195. font-size: 14px;
  196. color: #5570F1;
  197. }
  198. }
  199. .article-meta {
  200. margin-top: 31px;
  201. color: #888;
  202. font-size: 16px;
  203. display: flex;
  204. align-items: center;
  205. .article-link {
  206. margin-left: 12px;
  207. }
  208. }
  209. .article-content {
  210. // margin: 18px 0 12px 0;
  211. color: #444;
  212. font-size: 15px;
  213. line-height: 1.8;
  214. word-break: break-all;
  215. }
  216. .article-author {
  217. margin-top: 12px;
  218. color: #999;
  219. font-size: 18px;
  220. span {
  221. font-weight: 400;
  222. font-size: 18px;
  223. color: #6A82F3;
  224. text-align: center;
  225. // margin-right: 16px;
  226. display:block;
  227. line-height:30px;
  228. }
  229. }
  230. }
  231. .comment-section {
  232. // padding: 24px 32px;
  233. background: #fff;
  234. border-radius: 8px;
  235. .comment-title {
  236. font-weight: bold;
  237. font-size: 22px;
  238. color: #5570F1;
  239. // font-size: 16px;
  240. // font-weight: bold;
  241. // color: #333;
  242. margin-bottom: 8px;
  243. text-align: left;
  244. }
  245. // 蓝色短分割线,宽度10%,居中
  246. .el-divider {
  247. margin: 8px auto 16px auto;
  248. border: none;
  249. height: 0;
  250. width: 10%;
  251. min-width: 40px;
  252. max-width: 100px;
  253. border-top: 2px solid #5570F1;
  254. border-radius: 2px;
  255. background: transparent;
  256. }
  257. .comment-list {
  258. margin-top:40px;
  259. .comment_li{background:#FAFAFA;border:solid 1px #E1E1E1;overflow:hidden;margin-bottom:20px;}
  260. .comment_li_img{float:left;width:52px;height:52px;border-radius:50%;margin:30px 0px 30px 30px;}
  261. .comment_li_name{float:left;margin:44px 0px 44px 20px;color:#333;font-size:16px;line-height:24px;}
  262. .comment_li_text{float:left;margin:45px 0px 11px 20px;color:#333;font-size:16px;line-height:24px; font-weight:bold;width:1000px; }
  263. .comment_li_time{float:right;margin:44px 30px 44px 0px;color:#999;font-size:16px;line-height:24px; }
  264. margin-bottom: 16px;
  265. .comment-item {
  266. display: flex;
  267. align-items: center;
  268. padding: 12px 0;
  269. border-bottom: 1px solid #f0f0f0;
  270. &:last-child {
  271. border-bottom: none;
  272. }
  273. .comment-avatar {
  274. width: 36px;
  275. height: 36px;
  276. margin-right: 12px;
  277. }
  278. .comment-content {
  279. .comment-user {
  280. font-size: 15px;
  281. color: #555;
  282. font-weight: 500;
  283. }
  284. .comment-time {
  285. font-size: 12px;
  286. color: #aaa;
  287. margin-top: 2px;
  288. }
  289. }
  290. }
  291. }
  292. .comment-actions {
  293. display: flex;
  294. justify-content: center;
  295. gap: 16px;
  296. margin-top: 12px;
  297. }
  298. }
  299. .article-meta-item1 {
  300. position: relative;
  301. padding-left: 27px;
  302. &::before {
  303. content: '';
  304. display: inline-block;
  305. width: 20px;
  306. height: 20px;
  307. background: url('http://img.bjzxtw.org.cn/master/www/admin/renwu.png') no-repeat center center;
  308. background-size: contain;
  309. position: absolute;
  310. left: 0;
  311. top: 50%;
  312. transform: translateY(-50%);
  313. margin-right: 4px;
  314. }
  315. }
  316. .article-meta-item2 {
  317. position: relative;
  318. padding-left: 27px;
  319. margin-left:40px;
  320. &::before {
  321. content: '';
  322. display: inline-block;
  323. width: 20px;
  324. height: 20px;
  325. background: url('http://img.bjzxtw.org.cn/master/www/admin/wechat.png') no-repeat center center;
  326. background-size: contain;
  327. position: absolute;
  328. left: 0;
  329. top: 50%;
  330. transform: translateY(-50%);
  331. margin-right: 4px;
  332. }
  333. }
  334. .top-button{
  335. margin-left: 30px;
  336. }
  337. .background-color{
  338. background: #f0f2f5;
  339. padding: 10px 20px 0px 20px;
  340. }
  341. .clearfix::after{
  342. content:'';
  343. display: block;height: 0;
  344. visibility: hidden;
  345. clear: both;
  346. }
  347. .box_1{
  348. border-bottom:solid 1px #E9EDF7;
  349. box-sizing:border-box;
  350. }
  351. .box_in{
  352. font-weight: bold;
  353. float:left;
  354. font-size:22px;
  355. color:#5570F1;
  356. height:33px;
  357. line-height:33px;
  358. border-bottom:solid 2px #5570F1;
  359. margin-bottom:-1px;
  360. }
  361. }
  362. .article_box{margin-top:11;overflow:hidden;}
  363. .article_panel {
  364. transition: max-height 0.3s;
  365. overflow: hidden;
  366. position: relative;
  367. max-height: none;
  368. // 展开时无高度限制
  369. &.collapsed {
  370. max-height: 270px; // 固定高度
  371. // 可选:加渐变遮罩
  372. &::after {
  373. content: '';
  374. position: absolute;
  375. left: 0; right: 0; bottom: 0;
  376. // height: 36px;
  377. background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 80%);
  378. pointer-events: none;
  379. }
  380. }
  381. }
  382. .article_panel_btn {
  383. display: inline-block;
  384. color: #5570F1;
  385. cursor: pointer;
  386. margin-top: 8px;
  387. font-size: 15px;
  388. }
  389. .dot1{word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  390. }
  391. </style>