articleDetails.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. <template>
  2. <view>
  3. <u-navbar :isBack="back" ></u-navbar>
  4. <share-server ref="share" ></share-server>
  5. <!-- 新闻内容 -->
  6. <view class="content">
  7. <view class="title">
  8. {{info.title}}
  9. </view>
  10. <view class="infos">
  11. <view class="date">
  12. {{info.createTime}}
  13. </view>
  14. <view class="pageview" >
  15. <view class="icon">
  16. <u-icon name="eye" size="32"></u-icon>
  17. </view>
  18. <view class="number">
  19. {{info.hits}}
  20. </view>
  21. </view>
  22. </view>
  23. <view class="text news-content" v-html="info.content">
  24. </view>
  25. <view class="picture" v-if="info.pic">
  26. <img :src="info.pic" style="width: 100%;" alt="">
  27. </view>
  28. </view>
  29. <!-- 评论 -->
  30. <template v-if="info.typeName!=='通知公告'">
  31. <view class="comment" v-if="info.title&&info.listComment&&info.listComment.length" >
  32. <view class="title">
  33. 精华评论
  34. </view>
  35. <view class="comment-item" v-for="(item,i) in info.listComment" :key="i" >
  36. <view class="photo">
  37. <img v-if="item.headImg" :src="item.headImg" alt="">
  38. <u-avatar v-else size="80" ></u-avatar>
  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. 我的评论<span style="color:red;margin-left: 2px;" v-if="item.status==0">[审批中]</span>
  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. <view class="bottom" v-else >
  81. <view class="input" @click="issueMethod()">
  82. <view class="inputT">未登录,前往登录</view>
  83. </view>
  84. <view class="like" :class="{
  85. red:info.iLike
  86. }" >
  87. <view class="icon">
  88. <u-icon name="thumb-up" size="32"></u-icon>
  89. </view>
  90. <view class="number">
  91. {{info.likesNum}}
  92. </view>
  93. </view>
  94. </view>
  95. </template>
  96. <u-popup v-model="showMessage" border-radius="34" mode="bottom" >
  97. <view class="showMessage">
  98. <view class="showMessage1"><h3>发表评论({{content.length}}/50)</h3></view>
  99. <view class="showMessage2">
  100. <textarea name="" id="" style=" width:100%"
  101. v-model="content" maxlength="50"
  102. cols="30" rows="5" placeholder="填写内容"></textarea>
  103. </view>
  104. <view class="showMessage3">
  105. <u-button type="primary" @click="submitMessage()">提交</u-button>
  106. </view>
  107. </view>
  108. </u-popup>
  109. </view>
  110. </template>
  111. <script>
  112. import * as API from '@/apis/pagejs/news.js'
  113. import ShareServer from '@/components/ShareServer.vue'
  114. export default {
  115. components: {
  116. ShareServer
  117. },
  118. data() {
  119. return {
  120. id:"",
  121. content:"",
  122. info:{},
  123. showMessage:false,
  124. userInfo:null,
  125. list:[],
  126. back:true,
  127. recordsTotal:0,
  128. }
  129. },
  130. onLoad(op){
  131. if(op.back&&op.back=="share"){
  132. this.back=false
  133. }
  134. this.id=op.id
  135. this.userInfo=this.carhelp.getPersonInfo()
  136. this.getInfo(true)
  137. },
  138. methods: {
  139. issueMethod(){
  140. uni.showModal({
  141. title:"提示",
  142. content:"未登录,登录后参与评论",
  143. confirmText:"前往登录",
  144. showCancel:true,
  145. success: function (res) {
  146. if(res.confirm){
  147. uni.navigateTo({
  148. url:'/pages/login/index'
  149. })
  150. }
  151. }
  152. })
  153. },
  154. newsCommentsdelete(id){
  155. uni.showModal({
  156. title: '提示',
  157. content: '是否删除评论?',
  158. success: res=>{
  159. if (res.confirm) {
  160. this.newsCommentsdeletemethods(id)
  161. } else if (res.cancel) {
  162. //('用户点击取消');
  163. }
  164. }
  165. });
  166. },
  167. newsCommentsdeletemethods(id){
  168. uni.showLoading({
  169. title: "加载中",
  170. mask: true,
  171. })
  172. API.newsCommentsdelete(id).then((res) => {
  173. uni.showToast({
  174. title: "删除成功",
  175. icon: "none"
  176. })
  177. this.getInfo();
  178. }).catch(error => {
  179. uni.showToast({
  180. title: error,
  181. icon: "none"
  182. })
  183. })
  184. },
  185. submitMessage(){
  186. if(!this.content){
  187. uni.showToast({
  188. title: "请填写内容",
  189. icon: "none"
  190. })
  191. return
  192. }
  193. uni.showLoading({
  194. title: "加载中",
  195. mask: true,
  196. })
  197. API.commentNews({
  198. newsId:this.id,
  199. content:this.content,
  200. }).then((res) => {
  201. this.content=""
  202. uni.showToast({
  203. title: "提交成功",
  204. icon: "none"
  205. })
  206. this.showMessage=false
  207. this.getInfo();
  208. }).catch(error => {
  209. uni.showToast({
  210. title: error,
  211. icon: "none"
  212. })
  213. })
  214. },
  215. changeLikes(){
  216. uni.showLoading({
  217. title: "加载中",
  218. mask: true,
  219. })
  220. API.changeLikes({
  221. newsId:this.id
  222. }).then((res) => {
  223. this.getInfo(true)
  224. }).catch(error => {
  225. uni.showToast({
  226. title: error,
  227. icon: "none"
  228. })
  229. })
  230. },
  231. getInfo(bl){
  232. if(bl){
  233. uni.showLoading({
  234. title: "加载中",
  235. mask: true,
  236. })
  237. }
  238. var userId=null
  239. if(this.userInfo){
  240. userId=this.userInfo.id
  241. }
  242. API.detail({
  243. id:this.id,
  244. userId:userId
  245. }).then((res) => {
  246. if(bl){
  247. uni.hideLoading();
  248. }
  249. this.info=res.data;
  250. this.$refs.share.setUrl("/pages/news/articleDetails?back=share&id="+this.id);
  251. this.$refs.share.setTitle(this.info.title,this.id);
  252. this.$nextTick(()=>{
  253. var list =document.getElementsByClassName("news-content")[0].getElementsByTagName("img");
  254. for(var i=0;i<list.length;i++){
  255. list[i].style='width: 100%;height: 100%;'
  256. }
  257. })
  258. }).catch(error => {
  259. uni.showToast({
  260. title: error,
  261. icon: "none"
  262. })
  263. })
  264. }
  265. }
  266. }
  267. </script>
  268. <style lang="scss" scoped>
  269. page{
  270. padding-bottom:100px;
  271. font-family: 'Regular';
  272. }
  273. // 新闻内容
  274. .content{
  275. padding: 32rpx 32rpx 48rpx 32rpx;
  276. background-color: #fff;
  277. .title{
  278. color: rgba(16, 16, 16, 1);
  279. font-size: 20px;
  280. text-align: justify;
  281. font-weight: 550;
  282. font-family: 'SemiBold';
  283. }
  284. .infos{
  285. display: flex;
  286. justify-content: space-between;
  287. padding: 24rpx 0 32rpx 0;
  288. border-bottom: 1px solid rgba(241, 241, 241, 1);
  289. color: rgba(119, 119, 119, 1);
  290. font-size: 12px;
  291. .pageview{
  292. display: flex;
  293. }
  294. .icon{
  295. margin-right:8rpx ;
  296. }
  297. }
  298. .text{
  299. margin-top: 40rpx;
  300. line-height: 28px;
  301. color: rgba(51, 51, 51, 1);
  302. }
  303. .picture{
  304. margin-top: 40rpx;
  305. img{
  306. width: 100%;
  307. height: 155px;
  308. }
  309. .pic-title{
  310. margin-top: 7px;
  311. color: rgba(119, 119, 119, 1);
  312. font-size: 12px;
  313. text-align: center;
  314. }
  315. }
  316. }
  317. .showMessage{
  318. padding: 60rpx 50rpx ;
  319. .showMessage2{
  320. background-color: #E5E7EA;
  321. margin: 40rpx 0;
  322. textarea{
  323. padding: 8rpx;
  324. border-radius:34px;
  325. }
  326. }
  327. }
  328. // 评论
  329. .comment{
  330. margin-top:24rpx;
  331. background-color: #fff;
  332. padding: 32rpx 32rpx 48rpx 32rpx;
  333. .title{
  334. color: rgba(51, 51, 51, 1);
  335. font-size: 18px;
  336. }
  337. .comment-item:last-of-type{
  338. .comment-content{
  339. border: none;
  340. }
  341. }
  342. .comment-item{
  343. display: flex;
  344. padding-top: 58rpx;
  345. .photo{
  346. margin-top: -12px;
  347. img{
  348. width: 80rpx;
  349. height: 80rpx;
  350. border-radius: 50px;
  351. }
  352. }
  353. .details{
  354. margin-left: 24rpx;
  355. width: 100%;
  356. .name-date{
  357. display: flex;
  358. justify-content: space-between;
  359. .name{
  360. color: rgba(51, 51, 51, 1);
  361. font-size: 16px;
  362. }
  363. .date{
  364. color: rgba(119, 119, 119, 1);
  365. font-size: 12px;
  366. }
  367. }
  368. }
  369. .comment-content{
  370. margin-top: 16rpx;
  371. color: rgba(51, 51, 51, 1);
  372. line-height: 20px;
  373. border-bottom: 1px solid rgba(232, 232, 232, 1);
  374. padding-bottom: 40rpx;
  375. .mine{
  376. margin-top: 16rpx;
  377. display: flex;
  378. justify-content: space-between;
  379. line-height: 20px;
  380. .my-comment{
  381. color: rgba(119, 119, 119, 1);
  382. font-size: 12px;
  383. border: 1px solid rgba(153, 153, 153, 1);
  384. padding: 0rpx 12rpx;
  385. border-radius: 4px;
  386. }
  387. .delete{
  388. color: rgba(119, 119, 119, 1);
  389. font-size: 12px;
  390. }
  391. }
  392. }
  393. }
  394. }
  395. .red{
  396. color: red !important;
  397. }
  398. .bottom{
  399. position: fixed;
  400. left: 0;
  401. right: 0;
  402. bottom: 0;
  403. background-color: #fff;
  404. padding: 16rpx 32rpx;
  405. display: flex;
  406. justify-content: space-between;
  407. align-items: center;
  408. .input{
  409. background-color: rgba(229, 231, 234, 1);
  410. height: 32px;
  411. line-height: 32px;
  412. border-radius: 8rpx;
  413. width: 520rpx;
  414. padding-left: 16rpx;
  415. }
  416. /deep/.uni-input-placeholder{
  417. text-indent: 28rpx;
  418. }
  419. /deep/.uni-input-input{
  420. text-indent: 28rpx;
  421. }
  422. .like{
  423. display: flex;
  424. .number{
  425. margin-left: 16rpx;
  426. }
  427. }
  428. }
  429. </style>