qus.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="main">
  3. <view class="container">
  4. <view class="list">
  5. <view class="infobox" v-for="(item , index) in articleList" :key="index" @click="articleDetails(item.id)">
  6. <view class="left">
  7. <view class="infoname">{{item.title}}</view>
  8. <view class="infotxt">{{item.gist == null? '': item.gist}}</view>
  9. <view class="infolook">
  10. <image src="../../static/index/look.png"></image>
  11. <view>{{ item.virtual_view + item.view }}</view>
  12. </view>
  13. </view>
  14. <view class="right">
  15. <image :src="item.image"></image>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. name: 'articleList',
  25. data() {
  26. return {
  27. cate_id: null,
  28. articleList: [],
  29. page: 1,
  30. }
  31. },
  32. onLoad(option) {
  33. console.log(option)
  34. this.cate_id = option.cate_id
  35. },
  36. mounted() {
  37. this.articleListData()
  38. },
  39. methods: {
  40. // 下拉刷新数据
  41. onPullDownRefresh: function() {
  42. this.page = 1
  43. this.articleList = []
  44. this.articleListData()
  45. setTimeout(function() {
  46. uni.stopPullDownRefresh();
  47. }, 1000);
  48. },
  49. articleListData: async function() {
  50. let res = await this.$request.get(`/api/Article/articleList?page=${this.page}&size=10&cate_id=` + this.cate_id);
  51. console.log(res.data.data)
  52. if (res.code == 200) {
  53. if (this.page > res.data.last_page) {
  54. uni.showToast({
  55. title: "没有更多了",
  56. icon: "none"
  57. })
  58. } else {
  59. this.page++
  60. this.articleList = this.articleList.concat(res.data.data)
  61. }
  62. } else {
  63. uni.showToast({
  64. icon: 'none',
  65. title: res.message
  66. });
  67. }
  68. },
  69. // 跳转到文章详情
  70. articleDetails(id) {
  71. uni.navigateTo({
  72. url: '/pages/index/articleDetails?id=' + id
  73. })
  74. },
  75. // 下拉刷新
  76. onReachBottom() {
  77. this.articleListData()
  78. }
  79. }
  80. }
  81. </script>
  82. <style>
  83. page {
  84. background: #F5F5F5;
  85. }
  86. .main {
  87. width: 100vw;
  88. height: auto;
  89. margin-bottom: 20px;
  90. }
  91. .container {
  92. padding: 0 15px;
  93. }
  94. .list {
  95. width: 100%;
  96. height: auto;
  97. margin-top: 20px;
  98. }
  99. .list .infobox {
  100. width: 100%;
  101. height: 200rpx;
  102. margin: 15px 0;
  103. padding: 15rpx;
  104. display: flex;
  105. justify-content: space-between;
  106. background: #fff;
  107. border-radius: 5px;
  108. }
  109. .infobox .left {
  110. width: 54vw;
  111. }
  112. .infobox .right {
  113. width: 34vw;
  114. }
  115. .infobox .right .right-img-item {
  116. border-radius: 12rpx;
  117. }
  118. .right image {
  119. width: 100%;
  120. height: 100%;
  121. }
  122. .left .infoname {
  123. /* width: 100%; */
  124. height: 80rpx;
  125. font-size: 32rpx;
  126. font-weight: 400;
  127. color: rgba(85, 88, 100, 1);
  128. font-family: PingFangSC-Regular, sans-serif;
  129. overflow: hidden;
  130. }
  131. .left .infotxt {
  132. width: 100%;
  133. height: 50rpx;
  134. line-height: 50rpx;
  135. color: #999;
  136. font-size: 24rpx;
  137. font-family: PingFangSC-Regular, sans-serif;
  138. overflow: hidden;
  139. text-overflow: ellipsis;
  140. white-space: nowrap;
  141. }
  142. .left .infolook {
  143. width: 100%;
  144. height: 50rpx;
  145. display: flex;
  146. align-items: center;
  147. }
  148. .infolook image {
  149. width: 34rpx;
  150. height: 34rpx;
  151. margin: 2px;
  152. border-radius: 12rpx;
  153. }
  154. .infolook view {
  155. width: auto;
  156. height: 30px;
  157. line-height: 30px;
  158. padding: 0 5px;
  159. color: #999;
  160. }
  161. </style>