news.vue 5.4 KB

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