articleDetails.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  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" 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" >
  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. </view>
  77. </view>
  78. </view>
  79. <u-popup v-model="showMessage" border-radius="34" mode="bottom" >
  80. <view class="showMessage">
  81. <view class="showMessage1"><h3>发表评论</h3></view>
  82. <view class="showMessage2">
  83. <textarea name="" id=""
  84. v-model="content"
  85. cols="30" rows="5" placeholder="填写内容"></textarea>
  86. </view>
  87. <view class="showMessage3">
  88. <u-button type="primary" @click="submitMessage()">提交</u-button>
  89. </view>
  90. </view>
  91. </u-popup>
  92. </view>
  93. </template>
  94. <script>
  95. import * as API from '@/apis/pagejs/news.js'
  96. export default {
  97. data() {
  98. return {
  99. id:"",
  100. content:"",
  101. info:{},
  102. showMessage:false,
  103. userInfo:null,
  104. list:[],
  105. recordsTotal:0,
  106. }
  107. },
  108. onLoad(op){
  109. this.id=op.id
  110. this.userInfo=this.carhelp.getPersonInfo()
  111. this.getInfo(true)
  112. },
  113. methods: {
  114. newsCommentsdelete(id){
  115. uni.showModal({
  116. title: '提示',
  117. content: '是否删除评论?',
  118. success: res=>{
  119. if (res.confirm) {
  120. this.newsCommentsdeletemethods(id)
  121. } else if (res.cancel) {
  122. //('用户点击取消');
  123. }
  124. }
  125. });
  126. },
  127. newsCommentsdeletemethods(id){
  128. uni.showLoading({
  129. title: "加载中",
  130. mask: true,
  131. })
  132. API.newsCommentsdelete(id).then((res) => {
  133. uni.showToast({
  134. title: "删除成功",
  135. icon: "none"
  136. })
  137. this.getInfo();
  138. }).catch(error => {
  139. uni.showToast({
  140. title: error,
  141. icon: "none"
  142. })
  143. })
  144. },
  145. submitMessage(){
  146. if(!this.content){
  147. uni.showToast({
  148. title: "请填写内容",
  149. icon: "none"
  150. })
  151. return
  152. }
  153. uni.showLoading({
  154. title: "加载中",
  155. mask: true,
  156. })
  157. API.commentNews({
  158. newsId:this.id,
  159. content:this.content,
  160. }).then((res) => {
  161. this.content=""
  162. uni.showToast({
  163. title: "提交成功",
  164. icon: "none"
  165. })
  166. this.getInfo();
  167. }).catch(error => {
  168. uni.showToast({
  169. title: error,
  170. icon: "none"
  171. })
  172. })
  173. },
  174. changeLikes(){
  175. uni.showLoading({
  176. title: "加载中",
  177. mask: true,
  178. })
  179. API.changeLikes({
  180. newsId:this.id
  181. }).then((res) => {
  182. uni.hideLoading();
  183. this.getInfo()
  184. }).catch(error => {
  185. uni.showToast({
  186. title: error,
  187. icon: "none"
  188. })
  189. })
  190. },
  191. getInfo(bl){
  192. if(bl){
  193. uni.showLoading({
  194. title: "加载中",
  195. mask: true,
  196. })
  197. }
  198. var userId=null
  199. if(this.userInfo){
  200. userId=this.userInfo.id
  201. }
  202. API.detail(this.id,userId).then((res) => {
  203. if(bl){
  204. uni.hideLoading();
  205. }
  206. this.info=res.data;
  207. }).catch(error => {
  208. uni.showToast({
  209. title: error,
  210. icon: "none"
  211. })
  212. })
  213. }
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. page{
  219. padding-bottom:100px;
  220. }
  221. // 新闻内容
  222. .content{
  223. padding: 32rpx 32rpx 48rpx 32rpx;
  224. background-color: #fff;
  225. .title{
  226. color: rgba(16, 16, 16, 1);
  227. font-size: 20px;
  228. text-align: justify;
  229. font-weight: 550;
  230. }
  231. .infos{
  232. display: flex;
  233. justify-content: space-between;
  234. padding: 24rpx 0 32rpx 0;
  235. border-bottom: 1px solid rgba(241, 241, 241, 1);
  236. color: rgba(119, 119, 119, 1);
  237. font-size: 12px;
  238. .pageview{
  239. display: flex;
  240. }
  241. .icon{
  242. margin-right:8rpx ;
  243. }
  244. }
  245. .text{
  246. margin-top: 40rpx;
  247. line-height: 28px;
  248. color: rgba(51, 51, 51, 1);
  249. }
  250. .picture{
  251. margin-top: 40rpx;
  252. img{
  253. width: 100%;
  254. height: 155px;
  255. }
  256. .pic-title{
  257. margin-top: 7px;
  258. color: rgba(119, 119, 119, 1);
  259. font-size: 12px;
  260. text-align: center;
  261. }
  262. }
  263. }
  264. .showMessage{
  265. padding: 60rpx 50rpx ;
  266. .showMessage2{
  267. background-color: #E5E7EA;
  268. margin: 40rpx 0;
  269. textarea{
  270. padding: 8rpx;
  271. border-radius:34px;
  272. }
  273. }
  274. }
  275. // 评论
  276. .comment{
  277. margin-top:24rpx;
  278. background-color: #fff;
  279. padding: 32rpx 32rpx 48rpx 32rpx;
  280. .title{
  281. color: rgba(51, 51, 51, 1);
  282. font-size: 18px;
  283. }
  284. .comment-item:last-of-type{
  285. .comment-content{
  286. border: none;
  287. }
  288. }
  289. .comment-item{
  290. display: flex;
  291. padding-top: 58rpx;
  292. .photo{
  293. margin-top: -12px;
  294. img{
  295. width: 80rpx;
  296. height: 80rpx;
  297. border-radius: 50px;
  298. }
  299. }
  300. .details{
  301. margin-left: 24rpx;
  302. width: 100%;
  303. .name-date{
  304. display: flex;
  305. justify-content: space-between;
  306. .name{
  307. color: rgba(51, 51, 51, 1);
  308. font-size: 16px;
  309. }
  310. .date{
  311. color: rgba(119, 119, 119, 1);
  312. font-size: 12px;
  313. }
  314. }
  315. }
  316. .comment-content{
  317. margin-top: 16rpx;
  318. color: rgba(51, 51, 51, 1);
  319. line-height: 20px;
  320. border-bottom: 1px solid rgba(232, 232, 232, 1);
  321. padding-bottom: 40rpx;
  322. .mine{
  323. margin-top: 16rpx;
  324. display: flex;
  325. justify-content: space-between;
  326. line-height: 20px;
  327. .my-comment{
  328. color: rgba(119, 119, 119, 1);
  329. font-size: 12px;
  330. border: 1px solid rgba(153, 153, 153, 1);
  331. padding: 0rpx 12rpx;
  332. border-radius: 4px;
  333. }
  334. .delete{
  335. color: rgba(119, 119, 119, 1);
  336. font-size: 12px;
  337. }
  338. }
  339. }
  340. }
  341. }
  342. .red{
  343. color: red !important;
  344. }
  345. .bottom{
  346. position: fixed;
  347. left: 0;
  348. right: 0;
  349. bottom: 0;
  350. background-color: #fff;
  351. padding: 16rpx 32rpx;
  352. display: flex;
  353. justify-content: space-between;
  354. align-items: center;
  355. .input{
  356. background-color: rgba(229, 231, 234, 1);
  357. height: 32px;
  358. line-height: 32px;
  359. border-radius: 8rpx;
  360. width: 520rpx;
  361. padding-left: 16rpx;
  362. }
  363. /deep/.uni-input-placeholder{
  364. text-indent: 28rpx;
  365. }
  366. /deep/.uni-input-input{
  367. text-indent: 28rpx;
  368. }
  369. .like{
  370. display: flex;
  371. .number{
  372. margin-left: 16rpx;
  373. }
  374. }
  375. }
  376. </style>