oneIndex.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view>
  3. <view class="searchType" style="background: #fff;">
  4. <view class="input-view">
  5. <uni-icon type="search" size="22" color="#666666" />
  6. <input confirm-type="search" class="input" type="text" placeholder="搜索文章" @confirm="confirm" />
  7. </view>
  8. </view>
  9. <view>
  10. <van-tabs :active="active" @change="onChange">
  11. <van-tab v-for="(item,index) in typelist" :key="index" :name="index" :title="item.ac_name"></van-tab>
  12. </van-tabs>
  13. </view>
  14. <scroll-view class="floor-list"
  15. :scroll-top="scrollTop" style="height: 90vh;" scroll-y="true" @scroll="scroll" @scrolltoupper="upper" @scrolltolower="lower"
  16. refresher-enabled="true">
  17. <view v-for="(item,indedx) in acrelist" :key="indedx" @click="goIndex(item)">
  18. <view class="hotelList">
  19. <view class="hotleLeft">
  20. <image style="width: 214upx;height: 152upx;" :src=" pictureUrl + '/' + item.article_thumb"/>
  21. </view>
  22. <view class="hotelright">
  23. <view style="font-size: 28upx;color: #303133;">{{item.article_title}}</view>
  24. <view>
  25. {{item.article_time}}
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </scroll-view>
  31. </view>
  32. </template>
  33. <script>
  34. import uniIcon from '@/component/uni-icon/uni-icon.vue'
  35. export default {
  36. components: {
  37. uniIcon
  38. },
  39. data() {
  40. return {
  41. pictureUrl: this.pictureUrl,
  42. page: 1,
  43. page_size: 10,
  44. ac_id:'',
  45. keyword:'',
  46. active: 0,
  47. scrollTop: 0,
  48. old: {
  49. scrollTop: 0
  50. },
  51. typelist:[],
  52. acrelist:[],
  53. ispull: true
  54. }
  55. },
  56. onLoad() {
  57. this.getype(); // 获取文章分类
  58. this.getlist(); // 获取文章列表
  59. },
  60. methods: {
  61. goIndex(items) {
  62. let article_id = items.article_id;
  63. let ac_id = items.ac_id;
  64. let name = '';
  65. this.typelist.forEach((item, index) => {
  66. if(item.ac_id == ac_id) {
  67. name = item.ac_name;
  68. }
  69. })
  70. uni.navigateTo({
  71. url: `/pages/myone/onedetail?id=${article_id}&name=${name}`
  72. });
  73. },
  74. getype() {
  75. this.request({
  76. url: '/v1/entry/news_cate',
  77. method:'POST',
  78. success: (res) => {
  79. let array = [{ac_name:'全部'}];
  80. this.typelist = array.concat(res.data.data);
  81. }
  82. })
  83. },
  84. getlist() {
  85. this.request({
  86. url: '/v1/entry/news',
  87. method:'POST',
  88. data: {
  89. page: this.page,
  90. page_size: this.page_size,
  91. ac_id: this.ac_id,
  92. keyword: this.keyword
  93. },
  94. success: (res) => {
  95. let { data } = res.data;
  96. if(data.total_page == data.current_page) {
  97. this.ispull = false;
  98. }
  99. this.acrelist = this.acrelist.concat(data.new_list);
  100. }
  101. })
  102. },
  103. confirm() {
  104. },
  105. onChange(event) {
  106. this.active = event.detail.name;
  107. if( event.detail.name == 0) {
  108. this.ac_id = '';
  109. }else {
  110. let items = this.typelist[this.active];
  111. this.ac_id = items.ac_id;
  112. }
  113. this.active = event.detail.name;
  114. this.ispull = true;
  115. this.page = 1;
  116. this.acrelist = [];
  117. this.getlist();
  118. },
  119. // 滚动到顶部
  120. upper(e) {
  121. console.log(e)
  122. console.log("顶部")
  123. },
  124. // 滚到底部
  125. lower(e) {
  126. this.page = this.page + 1;
  127. if(this.ispull) {
  128. this.getlist();
  129. }
  130. },
  131. // 滚动时触发
  132. scroll(e) {
  133. this.old.scrollTop = e.detail.scrollTop
  134. },
  135. }
  136. }
  137. </script>
  138. <style>
  139. .hotelList {
  140. display: flex;
  141. flex-direction: row;
  142. padding: 24upx 32upx;
  143. }
  144. .hotleLeft {
  145. width: 214upx;
  146. height: 152upx;
  147. background-color: #007AFF;
  148. }
  149. .hotelright {
  150. padding-left: 16upx;
  151. display: flex;
  152. flex-direction: column;
  153. width: 100%;
  154. }
  155. .searchType .input-view {
  156. width: 85%;
  157. display: flex;
  158. background-color: #e7e7e7;
  159. height: 30px;
  160. border-radius: 15px;
  161. padding: 0 4%;
  162. flex-wrap: nowrap;
  163. margin: 7px 0;
  164. line-height: 30px;
  165. margin: 24upx auto;
  166. }
  167. .searchType .input-view .uni-icon {
  168. line-height: 30px !important;
  169. }
  170. .searchType .input-view .input {
  171. height: 30px;
  172. line-height: 30px;
  173. width: 94%;
  174. padding: 0 3%;
  175. }
  176. </style>