semDetail.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <div id="semDetail">
  3. <el-row>
  4. <div class="w_1200">
  5. <el-col :span="24" class="main">
  6. <el-col :span="24" class="one">
  7. <el-image :src="gongqiuImage"></el-image>
  8. </el-col>
  9. <el-col :span="24" class="two">
  10. <el-col :span="24" class="twoTop">
  11. <el-col :span="3" class="left">
  12. 浏览次数:1
  13. </el-col>
  14. <el-col :span="21" class="right"> [专题] {{ detail.title }} </el-col>
  15. </el-col>
  16. <el-col :span="24" class="twoInfo">
  17. <el-col :span="24" class="list">
  18. <el-col :span="3" class="left">
  19. <el-col :span="24" class="leftTop">
  20. 会员名称
  21. </el-col>
  22. <el-col :span="24" class="leftDown">
  23. <el-image :src="squareImage"></el-image>
  24. <el-col :span="24" class="jobname">
  25. {{ detail.uname }}
  26. </el-col>
  27. </el-col>
  28. </el-col>
  29. <el-col :span="21" class="right">
  30. <el-col :span="24" class="date">
  31. <i class="el-icon-user icon"></i>
  32. <span>文章发表于{{ detail.meta | getDate }}</span>
  33. <span>1楼</span>
  34. </el-col>
  35. <el-col :span="24" class="info">
  36. <p v-html="detail.content"></p>
  37. </el-col>
  38. <el-col :span="24" class="jubao">
  39. <span>举报</span>
  40. </el-col>
  41. </el-col>
  42. </el-col>
  43. <el-col :span="24" class="list" v-for="(item, index) in list" :key="index">
  44. <el-col :span="3" class="left">
  45. <el-col :span="24" class="leftTop">
  46. 会员名称
  47. </el-col>
  48. <el-col :span="24" class="leftDown">
  49. <el-image :src="squareImage"></el-image>
  50. <el-col :span="24" class="jobname">
  51. {{ item.uname }}
  52. </el-col>
  53. </el-col>
  54. </el-col>
  55. <el-col :span="21" class="right">
  56. <el-col :span="24" class="date">
  57. <i class="el-icon-user icon"></i>
  58. <span>评论发布于{{ item.meta | getDate }}</span>
  59. <span>{{ index + 2 }}楼</span>
  60. </el-col>
  61. <el-col :span="24" class="info">
  62. <p v-html="item.content"></p>
  63. </el-col>
  64. <el-col :span="24" class="jubao">
  65. <span>举报</span>
  66. </el-col>
  67. </el-col>
  68. </el-col>
  69. </el-col>
  70. <el-col :span="24" class="twoPage">
  71. <p>
  72. <span> <page :limit="limit" :total="total" position="right" @query="search"></page></span>
  73. </p>
  74. </el-col>
  75. <el-col :span="24" class="twoInput">
  76. <el-col :span="3" class="left"> </el-col>
  77. <el-col :span="21" class="right">
  78. <el-col :span="24" class="waneditor">
  79. <wang-editor v-model="form.content" ref="editor"></wang-editor>
  80. </el-col>
  81. <el-col :span="24" class="btn">
  82. <el-button type="primary" @click="submit">发表评论</el-button>
  83. </el-col>
  84. </el-col>
  85. </el-col>
  86. </el-col>
  87. </el-col>
  88. </div>
  89. </el-row>
  90. </div>
  91. </template>
  92. <script>
  93. import wangEditor from '@/components/wang-editor.vue';
  94. import page from '@/components/pages.vue';
  95. import { mapState, createNamespacedHelpers } from 'vuex';
  96. const { mapActions: comment } = createNamespacedHelpers('comment');
  97. const { mapActions: news } = createNamespacedHelpers('news');
  98. export default {
  99. name: 'semDetail',
  100. props: {
  101. newsid: null,
  102. },
  103. components: { page, wangEditor },
  104. data: () => ({
  105. gongqiuImage: require('@/assets/live/111.png'),
  106. squareImage: require('@/assets/live/222.png'),
  107. detail: {},
  108. list: [{ name: 'dsadas' }],
  109. total: 0,
  110. form: {},
  111. inputInfo: '',
  112. limit: 4,
  113. }),
  114. created() {
  115. this.search();
  116. this.searchinfo();
  117. },
  118. computed: {
  119. id() {
  120. return this.$route.query.id;
  121. },
  122. ...mapState(['user']),
  123. pageTitle() {
  124. return `${this.$route.meta.title}`;
  125. },
  126. },
  127. metaInfo() {
  128. return { title: this.$route.meta.title };
  129. },
  130. methods: {
  131. ...news(['fetch']),
  132. ...comment({ commentquery: 'query', commentCreate: 'create', commentUpdate: 'update' }),
  133. async searchinfo() {
  134. let id = this.newsid;
  135. console.log(id);
  136. const res = await this.fetch(id);
  137. this.$set(this, `detail`, res.data);
  138. },
  139. async search({ skip = 0, limit = this.limit, newsid = this.newsid } = { skip: 0, limit: this.limit }) {
  140. let res = await this.commentquery({ skip, limit, newsid });
  141. console.log(res);
  142. this.$set(this, `list`, res.data);
  143. this.$set(this, `total`, res.total);
  144. },
  145. async submit() {
  146. if (!this.user.uid) {
  147. this.$message.error('游客身份无法评论,请先登录');
  148. return;
  149. } else {
  150. this.form.newsid = this.newsid;
  151. this.form.uid = this.user.uid;
  152. let data = this.form;
  153. let res = await this.commentCreate(data);
  154. console.log(res);
  155. this.$checkRes(res, '评论成功', '评论失败');
  156. this.search();
  157. }
  158. },
  159. },
  160. filters: {
  161. getDate(meta) {
  162. let createdAt = _.get(meta, `createdAt`);
  163. let date = new Date(createdAt)
  164. .toLocaleDateString()
  165. .replace('/', '-')
  166. .replace('/', '-');
  167. return date;
  168. },
  169. },
  170. };
  171. </script>
  172. <style lang="less" scoped>
  173. .w_1200 {
  174. width: 95%;
  175. margin: 0 auto;
  176. }
  177. .main {
  178. float: left;
  179. width: 100%;
  180. min-height: 600px;
  181. margin: 30px 0;
  182. }
  183. .main .one {
  184. float: left;
  185. width: 100%;
  186. height: 160px;
  187. margin: 0 0 30px 0;
  188. }
  189. .main .two {
  190. float: left;
  191. width: 100%;
  192. }
  193. .main .two .twoTop {
  194. float: left;
  195. width: 100%;
  196. height: 60px;
  197. }
  198. .main .two .twoTop .left {
  199. float: left;
  200. height: 60px;
  201. line-height: 50px;
  202. text-align: center;
  203. font-size: 18px;
  204. color: #00316e;
  205. background: #a5d2f5;
  206. border-bottom: 10px solid #044b79;
  207. }
  208. .main .two .twoTop .right {
  209. float: left;
  210. height: 60px;
  211. line-height: 50px;
  212. padding: 0 15px;
  213. font-size: 20px;
  214. color: #023658;
  215. border-bottom: 10px solid #5096d2;
  216. }
  217. .main .two .twoInfo {
  218. float: left;
  219. width: 100%;
  220. }
  221. .main .two .twoInfo .left {
  222. background: #5096d2;
  223. border-bottom: 10px solid #044b79;
  224. }
  225. .main .two .twoInfo .left .leftTop {
  226. height: 60px;
  227. line-height: 60px;
  228. text-align: center;
  229. color: #fff;
  230. font-size: 22px;
  231. border-bottom: 1px dashed #ccc;
  232. }
  233. .main .two .twoInfo .left .leftDown {
  234. height: 420px;
  235. }
  236. .main .two .twoInfo .left .leftDown .el-image {
  237. margin: 40px 18px;
  238. width: auto;
  239. height: auto;
  240. max-width: 100%;
  241. max-height: 100%;
  242. }
  243. .main .two .twoInfo .left .leftDown .jobname {
  244. text-align: center;
  245. font-size: 22px;
  246. color: #fffcae;
  247. }
  248. .main .two .twoInfo .right {
  249. padding: 0 20px;
  250. }
  251. .main .two .twoInfo .right .date {
  252. padding: 0 20px;
  253. height: 60px;
  254. line-height: 60px;
  255. border-bottom: 1px dashed #ccc;
  256. }
  257. .main .two .twoInfo .right .date .icon {
  258. font-size: 30px;
  259. color: #b6dd59;
  260. }
  261. .main .two .twoInfo .right .date span:nth-child(2) {
  262. font-size: 20px;
  263. padding: 0px 10px;
  264. position: relative;
  265. top: -2px;
  266. }
  267. .main .two .twoInfo .right .date span:last-child {
  268. font-size: 20px;
  269. float: right;
  270. }
  271. .main .two .twoInfo .right .info {
  272. height: 300px;
  273. border: 2px solid #044b79;
  274. border-radius: 10px;
  275. margin: 30px 0;
  276. padding: 20px;
  277. }
  278. .main .two .twoInfo .right .info p {
  279. font-size: 20px;
  280. overflow: auto;
  281. text-overflow: ellipsis;
  282. -webkit-line-clamp: 8;
  283. word-break: break-all;
  284. display: -webkit-box;
  285. -webkit-box-orient: vertical;
  286. line-height: 33px;
  287. height: 260px;
  288. }
  289. .main .two .twoInfo .right .jubao {
  290. height: 70px;
  291. line-height: 60px;
  292. border-top: 1px dashed #ff8b0f;
  293. border-bottom: 10px solid #5096d2;
  294. }
  295. .main .two .twoInfo .right .jubao span {
  296. float: right;
  297. color: #ff0000;
  298. font-size: 20px;
  299. }
  300. .main .two .twoPage {
  301. margin: 20px 0;
  302. }
  303. .main .two .twoInput {
  304. height: 270px;
  305. border: 2px solid #5096d2;
  306. }
  307. .main .two .twoInput .left {
  308. height: 266px;
  309. background-color: #5096d2;
  310. }
  311. .main .two .twoInput .right {
  312. padding: 20px 20px 0 20px;
  313. }
  314. /deep/.main .two .twoInput .right .waneditor .w-e-text-container {
  315. height: 140px !important;
  316. }
  317. .main .two .twoInput .right .btn {
  318. margin: 10px 0;
  319. }
  320. /deep/.main .two .twoInput .right .btn .el-button {
  321. margin: 10px 0;
  322. }
  323. .pages {
  324. float: right;
  325. width: 100px;
  326. }
  327. </style>