articleDetails.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <view>
  3. <u-navbar></u-navbar>
  4. <!-- 新闻内容 -->
  5. <view class="content">
  6. <view class="title">
  7. {{info.title}}
  8. </view>
  9. <view class="infos">
  10. <view class="date">
  11. {{info.createTime}}
  12. </view>
  13. <view class="pageview" >
  14. <view class="icon">
  15. <u-icon name="eye" size="32"></u-icon>
  16. </view>
  17. <view class="number">
  18. {{info.hits}}
  19. </view>
  20. </view>
  21. </view>
  22. <view class="text news-content" v-html="info.content">
  23. </view>
  24. <!-- <view class="picture">
  25. <img src="../../assets/img/articlePic.png" alt="">
  26. <view class="pic-title">
  27. 鲍威尔称美联储应“迅速”行动以收紧政策
  28. </view>
  29. </view> -->
  30. </view>
  31. <!-- 评论 -->
  32. <view class="comment" v-if="info.title&&info.listComment&&info.listComment.length" >
  33. <view class="title">
  34. 精华评论
  35. </view>
  36. <view class="comment-item" v-for="(item,i) in info.listComment" :key="i" >
  37. <view class="photo">
  38. <img :src="item.headImg" alt="">
  39. </view>
  40. <view class="details">
  41. <view class="name-date">
  42. <view class="name" :class="{
  43. red:!item.name
  44. }" >
  45. {{item.name?item.name:'用户异常'}}
  46. </view>
  47. <view class="date">
  48. {{item.date}}
  49. </view>
  50. </view>
  51. <view class="comment-content">
  52. {{item.content}}
  53. <view class="mine" v-if="item.isMine">
  54. <view class="my-comment">
  55. 我的评论
  56. </view>
  57. <view class="delete" @click="newsCommentsdelete(item.id)">
  58. 删除
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="bottom" v-if="userInfo" >
  66. <view class="input" @click="showMessage=true">
  67. <view class="inputT">发表评论</view>
  68. </view>
  69. <view class="like" :class="{
  70. red:info.iLike
  71. }" @click="changeLikes()">
  72. <view class="icon">
  73. <u-icon name="thumb-up" size="32"></u-icon>
  74. </view>
  75. <view class="number">
  76. {{info.likesNum}}
  77. </view>
  78. </view>
  79. </view>
  80. <u-popup v-model="showMessage" border-radius="34" mode="bottom" >
  81. <view class="showMessage">
  82. <view class="showMessage1"><h3>发表评论</h3></view>
  83. <view class="showMessage2">
  84. <textarea name="" id=""
  85. v-model="content"
  86. cols="30" rows="5" placeholder="填写内容"></textarea>
  87. </view>
  88. <view class="showMessage3">
  89. <u-button type="primary" @click="submitMessage()">提交</u-button>
  90. </view>
  91. </view>
  92. </u-popup>
  93. </view>
  94. </template>
  95. <script>
  96. import * as API from '@/apis/pagejs/news.js'
  97. export default {
  98. data() {
  99. return {
  100. id:"",
  101. content:"",
  102. info:{},
  103. showMessage:false,
  104. userInfo:null,
  105. list:[],
  106. recordsTotal:0,
  107. }
  108. },
  109. onLoad(op){
  110. this.id=op.id
  111. this.userInfo=this.carhelp.getPersonInfo()
  112. this.getInfo(true)
  113. },
  114. methods: {
  115. newsCommentsdelete(id){
  116. uni.showModal({
  117. title: '提示',
  118. content: '是否删除评论?',
  119. success: res=>{
  120. if (res.confirm) {
  121. this.newsCommentsdeletemethods(id)
  122. } else if (res.cancel) {
  123. //('用户点击取消');
  124. }
  125. }
  126. });
  127. },
  128. newsCommentsdeletemethods(id){
  129. uni.showLoading({
  130. title: "加载中",
  131. mask: true,
  132. })
  133. API.newsCommentsdelete(id).then((res) => {
  134. uni.showToast({
  135. title: "删除成功",
  136. icon: "none"
  137. })
  138. this.getInfo();
  139. }).catch(error => {
  140. uni.showToast({
  141. title: error,
  142. icon: "none"
  143. })
  144. })
  145. },
  146. submitMessage(){
  147. if(!this.content){
  148. uni.showToast({
  149. title: "请填写内容",
  150. icon: "none"
  151. })
  152. return
  153. }
  154. uni.showLoading({
  155. title: "加载中",
  156. mask: true,
  157. })
  158. API.commentNews({
  159. newsId:this.id,
  160. content:this.content,
  161. }).then((res) => {
  162. this.content=""
  163. uni.showToast({
  164. title: "提交成功",
  165. icon: "none"
  166. })
  167. this.showMessage=false
  168. this.getInfo();
  169. }).catch(error => {
  170. uni.showToast({
  171. title: error,
  172. icon: "none"
  173. })
  174. })
  175. },
  176. changeLikes(){
  177. uni.showLoading({
  178. title: "加载中",
  179. mask: true,
  180. })
  181. API.changeLikes({
  182. newsId:this.id
  183. }).then((res) => {
  184. uni.hideLoading();
  185. this.getInfo()
  186. }).catch(error => {
  187. uni.showToast({
  188. title: error,
  189. icon: "none"
  190. })
  191. })
  192. },
  193. getInfo(bl){
  194. if(bl){
  195. uni.showLoading({
  196. title: "加载中",
  197. mask: true,
  198. })
  199. }
  200. var userId=null
  201. if(this.userInfo){
  202. userId=this.userInfo.id
  203. }
  204. API.detail({
  205. id:this.id,
  206. userId:userId
  207. }).then((res) => {
  208. if(bl){
  209. uni.hideLoading();
  210. }
  211. this.info=res.data;
  212. this.$nextTick(()=>{
  213. var list =document.getElementsByClassName("news-content")[0].getElementsByTagName("img");
  214. for(var i=0;i<list.length;i++){
  215. list[i].style='width: 100%;height: 100%;'
  216. }
  217. })
  218. }).catch(error => {
  219. uni.showToast({
  220. title: error,
  221. icon: "none"
  222. })
  223. })
  224. }
  225. }
  226. }
  227. </script>
  228. <style lang="scss" scoped>
  229. img{
  230. width: 100% !important;
  231. }
  232. page{
  233. padding-bottom:100px;
  234. }
  235. // 新闻内容
  236. .content{
  237. padding: 32rpx 32rpx 48rpx 32rpx;
  238. background-color: #fff;
  239. .title{
  240. color: rgba(16, 16, 16, 1);
  241. font-size: 20px;
  242. text-align: justify;
  243. font-weight: 550;
  244. }
  245. .infos{
  246. display: flex;
  247. justify-content: space-between;
  248. padding: 24rpx 0 32rpx 0;
  249. border-bottom: 1px solid rgba(241, 241, 241, 1);
  250. color: rgba(119, 119, 119, 1);
  251. font-size: 12px;
  252. .pageview{
  253. display: flex;
  254. }
  255. .icon{
  256. margin-right:8rpx ;
  257. }
  258. }
  259. .text{
  260. margin-top: 40rpx;
  261. line-height: 28px;
  262. color: rgba(51, 51, 51, 1);
  263. }
  264. .picture{
  265. margin-top: 40rpx;
  266. img{
  267. width: 100%;
  268. height: 155px;
  269. }
  270. .pic-title{
  271. margin-top: 7px;
  272. color: rgba(119, 119, 119, 1);
  273. font-size: 12px;
  274. text-align: center;
  275. }
  276. }
  277. }
  278. .showMessage{
  279. padding: 60rpx 50rpx ;
  280. .showMessage2{
  281. background-color: #E5E7EA;
  282. margin: 40rpx 0;
  283. textarea{
  284. padding: 8rpx;
  285. border-radius:34px;
  286. }
  287. }
  288. }
  289. // 评论
  290. .comment{
  291. margin-top:24rpx;
  292. background-color: #fff;
  293. padding: 32rpx 32rpx 48rpx 32rpx;
  294. .title{
  295. color: rgba(51, 51, 51, 1);
  296. font-size: 18px;
  297. }
  298. .comment-item:last-of-type{
  299. .comment-content{
  300. border: none;
  301. }
  302. }
  303. .comment-item{
  304. display: flex;
  305. padding-top: 58rpx;
  306. .photo{
  307. margin-top: -12px;
  308. img{
  309. width: 80rpx;
  310. height: 80rpx;
  311. border-radius: 50px;
  312. }
  313. }
  314. .details{
  315. margin-left: 24rpx;
  316. width: 100%;
  317. .name-date{
  318. display: flex;
  319. justify-content: space-between;
  320. .name{
  321. color: rgba(51, 51, 51, 1);
  322. font-size: 16px;
  323. }
  324. .date{
  325. color: rgba(119, 119, 119, 1);
  326. font-size: 12px;
  327. }
  328. }
  329. }
  330. .comment-content{
  331. margin-top: 16rpx;
  332. color: rgba(51, 51, 51, 1);
  333. line-height: 20px;
  334. border-bottom: 1px solid rgba(232, 232, 232, 1);
  335. padding-bottom: 40rpx;
  336. .mine{
  337. margin-top: 16rpx;
  338. display: flex;
  339. justify-content: space-between;
  340. line-height: 20px;
  341. .my-comment{
  342. color: rgba(119, 119, 119, 1);
  343. font-size: 12px;
  344. border: 1px solid rgba(153, 153, 153, 1);
  345. padding: 0rpx 12rpx;
  346. border-radius: 4px;
  347. }
  348. .delete{
  349. color: rgba(119, 119, 119, 1);
  350. font-size: 12px;
  351. }
  352. }
  353. }
  354. }
  355. }
  356. .red{
  357. color: red !important;
  358. }
  359. .bottom{
  360. position: fixed;
  361. left: 0;
  362. right: 0;
  363. bottom: 0;
  364. background-color: #fff;
  365. padding: 16rpx 32rpx;
  366. display: flex;
  367. justify-content: space-between;
  368. align-items: center;
  369. .input{
  370. background-color: rgba(229, 231, 234, 1);
  371. height: 32px;
  372. line-height: 32px;
  373. border-radius: 8rpx;
  374. width: 520rpx;
  375. padding-left: 16rpx;
  376. }
  377. /deep/.uni-input-placeholder{
  378. text-indent: 28rpx;
  379. }
  380. /deep/.uni-input-input{
  381. text-indent: 28rpx;
  382. }
  383. .like{
  384. display: flex;
  385. .number{
  386. margin-left: 16rpx;
  387. }
  388. }
  389. }
  390. </style>