news.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="center">
  3. <heard></heard>
  4. <view class="test_title">新闻动态</view>
  5. <view class="box" v-if="isShow">
  6. <view class="caseBox" v-for="(item, index) in newsList" @click="nav(item.id)">
  7. <view class="caseBox-img"><image :src="imgUrl + item.coverimage" mode=""></image></view>
  8. <view class="caseBox-right">
  9. <view class="title">{{ item.title }}</view>
  10. <view class="date">{{ item.createtime }}</view>
  11. <view class="content">{{ item.synopsis }}</view>
  12. </view>
  13. </view>
  14. <view class="tishi" v-if="isShowtishi">已加载全部数据~~</view>
  15. <view class="pagInation">
  16. <!-- prevText String 上一页 左侧按钮文字
  17. nextText String 下一页 右侧按钮文字
  18. current Number 1 当前页
  19. total Number 0 数据总量
  20. pageSize Number 10 每页数据量
  21. showIcon Boolean false 是否以 icon 形式展示按钮
  22. @change 点击页码按钮时触发 e={type,current} current为当前页,
  23. type值为:next/prev,表示点击的是上一页还是下一个-->
  24. <!-- <uni-pagination title="标题文字" prevText="" nextText="" pageSize="10" total="20" @change="" ></uni-pagination> -->
  25. <!-- <uni-pagination title="标题文字" show-icon="true" total="50" current="2"></uni-pagination> -->
  26. <uni-pagination
  27. class="pagination"
  28. prevText="上一页"
  29. nextText="下一页"
  30. @change="handlePage"
  31. show-icon="false"
  32. :total="total"
  33. :current="pageNum"
  34. :pageSize="pageSize"
  35. ></uni-pagination>
  36. </view>
  37. </view>
  38. <view class="xianqingye" v-html="newsDetail.content" v-else></view>
  39. <aboutUs class="aboutUs"></aboutUs>
  40. </view>
  41. </template>
  42. <script>
  43. import { changeTaber } from '@/utils/tarberChange.js';
  44. import { newslist, newsDetail } from '@/api/index.js';
  45. import { getTime } from '@/utils/time.js';
  46. import heard from '@/components/public/heard.vue';
  47. import aboutUs from '@/components/public/introduce.vue';
  48. export default {
  49. components: {
  50. aboutUs,
  51. heard
  52. },
  53. data() {
  54. return {
  55. isShowtishi: false, //false不展示
  56. isShow: true,
  57. imgUrl: 'http://tianli.liuniu946.com',
  58. newsList: [],
  59. newsCid: 30,
  60. // limit:,
  61. // page:1,
  62. total: '', //数据总量
  63. pageSize: 5, //每页数据量
  64. pageNum: 1, //当前页
  65. newsDetail: {}
  66. };
  67. },
  68. onLoad() {
  69. // this.loadData();
  70. // this.handlePage()
  71. this.getNewsList();
  72. },
  73. onShow() {
  74. this.$nextTick(function() {
  75. changeTaber(3);
  76. });
  77. },
  78. methods: {
  79. async loadData() {
  80. const obj = this;
  81. },
  82. //分页
  83. handlePage(params) {
  84. console.log(params);
  85. this.pageNum = params.current;
  86. this.getNewsList();
  87. },
  88. //获取案例
  89. getNewsList() {
  90. let obj = this;
  91. newslist({
  92. category_id: obj.newsCid,
  93. page: obj.pageNum,
  94. limit: obj.pageSize
  95. }).then(({ data }) => {
  96. data.list.forEach(e => {
  97. e.createtime = getTime(e.createtime);
  98. });
  99. console.log(data, '111111');
  100. obj.newsList = data.list;
  101. obj.total = data.count;
  102. if (data.list.length < 5) {
  103. this.isShowtishi = true;
  104. } else {
  105. this.isShowtishi = false;
  106. }
  107. });
  108. },
  109. //大概,
  110. nav(id) {
  111. this.isShow = false;
  112. newsDetail({}, id).then(res => {
  113. console.log(res, '111111');
  114. this.newsDetail = res.data;
  115. // }).catch(err => {
  116. // this.gsjj = err.data
  117. // console.log("2222222222")
  118. // console.log(err, 'cuoww')
  119. // })
  120. });
  121. }
  122. }
  123. };
  124. </script>
  125. <style lang="scss" scoped>
  126. .img {
  127. margin: 17rpx 0 17rpx 41rpx;
  128. width: 208rpx;
  129. height: 52rpx;
  130. image {
  131. width: 100%;
  132. height: 100%;
  133. }
  134. }
  135. .pagination {
  136. position: fixed;
  137. bottom: 0;
  138. left: 0;
  139. bottom: 232rpx;
  140. }
  141. .tishi {
  142. font-size: 16rpx;
  143. font-family: Adobe Heiti Std;
  144. font-weight: normal;
  145. color: #c7c9d1;
  146. line-height: 101px;
  147. }
  148. .test_title {
  149. display: flex;
  150. justify-content: center;
  151. align-items: center;
  152. width: 100%;
  153. height: 60rpx;
  154. font-size: 22rpx;
  155. font-family: Adobe Heiti Std;
  156. font-weight: normal;
  157. color: #ffffff;
  158. background-color: #0165b5;
  159. }
  160. .box {
  161. display: flex;
  162. flex-direction: column;
  163. align-items: center;
  164. .caseBox {
  165. margin-top: 20rpx;
  166. display: flex;
  167. align-items: center;
  168. width: 90%;
  169. height: 100%;
  170. .caseBox-img {
  171. flex-shrink: 1;
  172. width: 240rpx;
  173. height: 160rpx;
  174. image {
  175. width: 100%;
  176. height: 100%;
  177. }
  178. }
  179. .caseBox-right {
  180. margin-left: 30rpx;
  181. width: 440rpx;
  182. display: flex;
  183. flex-direction: column;
  184. .title {
  185. margin-top: -70rpx;
  186. font-size: 18rpx;
  187. font-family: Adobe Heiti Std;
  188. font-weight: normal;
  189. color: #535962;
  190. max-width: 420rpx;
  191. overflow: hidden;
  192. text-overflow: ellipsis;
  193. white-space: nowrap;
  194. }
  195. .date {
  196. margin-top: 10rpx;
  197. font-size: 11rpx;
  198. font-family: Adobe Heiti Std;
  199. font-weight: normal;
  200. color: #a1a1a1;
  201. line-height: 20rpx;
  202. }
  203. .content {
  204. font-size: 15rpx;
  205. font-family: Adobe Heiti Std;
  206. font-weight: normal;
  207. color: #a1a1a1;
  208. line-height: 46rpx;
  209. max-width: 420rpx;
  210. overflow: hidden;
  211. text-overflow: ellipsis;
  212. white-space: nowrap;
  213. }
  214. }
  215. }
  216. }
  217. // .uni-pagination__child-btn{
  218. // }
  219. // .pagInation > .uni-pagination>.uni-pagination__btn > .uni-pagination__child-btn > span{
  220. // }
  221. </style>