artList.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="jj-wrap">
  3. <view class="jj" v-for="cp in list" @click="navto('/pages/index/artDetail?id=' + cp.id)">
  4. <image :src="cp.image_input[0]" mode="" class="jj-img"></image>
  5. <view class="jj-info">
  6. <view class="jj-tit-tit clamp2">
  7. {{cp.title}}
  8. </view>
  9. <view class="jj-val clamp">
  10. 更新时间{{cp.add_time}}
  11. </view>
  12. </view>
  13. </view>
  14. <uni-load-more :status="loadingType"></uni-load-more>
  15. </view>
  16. </template>
  17. <script>
  18. import { article,articleList } from '@/api/user.js';
  19. import {
  20. loadIndexs,
  21. getArticleList
  22. } from '@/api/index.js';
  23. export default {
  24. data() {
  25. return {
  26. list: [],
  27. page: 1,
  28. limit: 10,
  29. loadingType: 'more',
  30. cid: 0,
  31. }
  32. },
  33. onLoad(opt) {
  34. this.cid = opt.cid
  35. this.tit = decodeURI(opt.tit)
  36. uni.setNavigationBarTitle({
  37. title: this.tit
  38. })
  39. this.getArticleList()
  40. },
  41. methods: {
  42. navto(url) {
  43. uni.navigateTo({
  44. url: url
  45. })
  46. },
  47. getArticleList() {
  48. let obj = this
  49. if(obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
  50. return
  51. }
  52. obj.loadingType = 'loading'
  53. article({
  54. page: obj.page,
  55. limit: obj.limit
  56. },obj.cid).then(({data}) => {
  57. obj.list = obj.list.concat(data)
  58. obj.page++
  59. if(data.length == obj.limit) {
  60. obj.loadingType = 'more'
  61. }else {
  62. obj.loadingType = 'noMore'
  63. }
  64. })
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. page {
  71. background-color: #fff;
  72. min-height: 100%;
  73. }
  74. .jj-wrap {
  75. background-color: #fff;
  76. // margin: 20rpx 0;
  77. .jj {
  78. margin: auto;
  79. width: 689rpx;
  80. height: 202rpx;
  81. border-bottom: 1px solid #e5e5e5;
  82. padding: 20rpx;
  83. padding-left: 0;
  84. display: flex;
  85. &:last-of-type {
  86. border-bottom: none;
  87. }
  88. .jj-img {
  89. flex-shrink: 0;
  90. width: 222rpx;
  91. height: 158rpx;
  92. background-color: #bfa;
  93. border-radius: 10rpx;
  94. }
  95. .jj-info {
  96. width: 450rpx;
  97. // flex-shrink: 0;
  98. padding: 10rpx;
  99. padding-left: 15rpx;
  100. font-size: 32rpx;
  101. font-weight: bold;
  102. display: flex;
  103. flex-direction: column;
  104. justify-content: space-between;
  105. .jj-tit-tit {
  106. }
  107. .jj-val {
  108. padding-top: 20rpx;
  109. font-size: 28rpx;
  110. font-weight: 500;
  111. }
  112. }
  113. }
  114. }
  115. </style>