news.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view>
  3. <u-navbar :title="title">
  4. <view class="slot-wrap">
  5. <u-icon name="search"
  6. @click="gotoUrl('pages/search/searchResult?type='+listForm.typeId)"
  7. size="48" color="#777777"></u-icon>
  8. </view>
  9. </u-navbar>
  10. <view class="news">
  11. <view class="news-item" v-for="(item,i) in list" @click="ckInfo(item.id)" :key="i">
  12. <view class="content">
  13. <view class="news-title">
  14. {{item.title}}
  15. </view>
  16. <view class="information">
  17. <view class="classify">
  18. {{item.typeName}}
  19. </view>
  20. <view class="date">
  21. {{substrDate(item.createTime)}}
  22. </view>
  23. </view>
  24. </view>
  25. <view class="img">
  26. <img v-if="item.pic" :src="imgurl+item.pic" alt="">
  27. <img v-else src="@/assets/img/default_img.png" alt="">
  28. </view>
  29. </view>
  30. </view>
  31. <u-divider v-if="list.length==recordsTotal"
  32. :isnone="list.length==0" nonetext="没有找到相关内容"
  33. border-color="#CFD2D5">已经到底了</u-divider>
  34. </view>
  35. </template>
  36. <script>
  37. import * as API from '@/apis/pagejs/news.js'
  38. export default {
  39. data() {
  40. return {
  41. title:"列表",
  42. list:[],
  43. listForm:{
  44. pageIndex:1,
  45. typeId:"",
  46. title:"",
  47. pageSize:20,
  48. },
  49. recordsTotal:0,
  50. imgurl:'',
  51. }
  52. },
  53. onLoad(op){
  54. if(op.title){
  55. this.title=op.title
  56. }
  57. this.listForm.typeId=op.id
  58. this.getList()
  59. },
  60. onReachBottom() {
  61. if (this.list.length < this.recordsTotal) {
  62. this.myLoadmore();
  63. }
  64. },
  65. methods: {
  66. ckInfo(id){
  67. var url="/pages/news/articleDetails?id="+id;
  68. uni.navigateTo({
  69. url:url
  70. })
  71. },
  72. myLoadmore(){
  73. this.listForm.pageIndex += 1;
  74. this.getList();
  75. },
  76. getList(){
  77. uni.showLoading({
  78. title: "加载中",
  79. mask: true,
  80. })
  81. API.pageList(this.listForm).then((res) => {
  82. uni.hideLoading();
  83. this.list = [
  84. ...this.list,
  85. ...res.data.data
  86. ];
  87. this.recordsTotal = res.data.recordsTotal;
  88. }).catch(error => {
  89. uni.showToast({
  90. title: error,
  91. icon: "none"
  92. })
  93. })
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. page{
  100. background-color: #ffffff;
  101. font-family: 'Regular';
  102. }
  103. /deep/.u-slot-content {
  104. display: block;
  105. text-align: right !important;
  106. margin-right: 16px;
  107. color: #333333;
  108. }
  109. .news{
  110. padding: 40rpx 32rpx;
  111. .news-item{
  112. display: flex;
  113. justify-content: space-between;
  114. margin-bottom: 40rpx;
  115. max-height:100px;
  116. .content{
  117. display: flex;
  118. flex-direction: column;
  119. justify-content: space-between;
  120. .news-title{
  121. color: rgba(51, 51, 51, 1);
  122. font-size: 16px;
  123. text-align: justify;
  124. width: 438rpx;
  125. // white-space: nowrap;
  126. overflow: hidden;
  127. text-overflow: ellipsis;
  128. font-weight: bold;
  129. }
  130. .information{
  131. margin-top: 8rpx;
  132. display: flex;
  133. justify-content: space-between;
  134. color: #777777;
  135. }
  136. }
  137. }
  138. .img{
  139. width: 224rpx;
  140. border-radius: 5px;
  141. overflow: hidden;
  142. img{
  143. border-radius: 5px;
  144. width: 100%;
  145. height: 100%;
  146. }
  147. }
  148. }
  149. /deep/.u-divider{
  150. background-color: #ffffff !important;
  151. color: rgba(182, 189, 195, 1);
  152. font-size: 12px;
  153. font-weight: bold;
  154. }
  155. </style>