ariclle.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="searchType" style="background: #fff;height: 100vh;">
  3. <van-cell value-class="searchclass">
  4. <template slot="title">
  5. <view class="input-view">
  6. <uni-icon type="search" size="22" color="#666666" />
  7. <input confirm-type="search" class="input" type="text" placeholder="输入搜索关键词"
  8. @input="confirm" />
  9. </view>
  10. </template>
  11. <template>
  12. <view @click="search">搜索</view>
  13. </template>
  14. </van-cell>
  15. <view v-for="(item,indedx) in acrelist" :key="indedx" @click="goIndex(item)">
  16. <view class="hotelList">
  17. <view class="hotleLeft">
  18. <image style="width: 214upx;height: 152upx;" :src=" pictureUrl + '/' + item.article_thumb"/>
  19. </view>
  20. <view class="hotelright">
  21. <view style="font-size: 28upx;color: #303133;">{{item.article_title}}</view>
  22. <view>
  23. {{item.article_time}}
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import uniIcon from '@/component/uni-icon/uni-icon.vue'
  32. import Gobacktop from '@/component/Gobacktop.vue'
  33. export default {
  34. components: {
  35. uniIcon,
  36. Gobacktop
  37. },
  38. data() {
  39. return {
  40. pictureUrl: this.pictureUrl,
  41. page: 1,
  42. page_size: 10,
  43. ac_id:'',
  44. keyword:'',
  45. active: 0,
  46. scrollTop: 0,
  47. old: {
  48. scrollTop: 0
  49. },
  50. isTop: false,
  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. getlist() {
  75. this.request({
  76. url: '/v1/entry/news',
  77. method:'POST',
  78. data: {
  79. page: this.page,
  80. page_size: this.page_size,
  81. keyword: this.keyword
  82. },
  83. success: (res) => {
  84. let { data } = res.data;
  85. if(data.total_page == data.current_page) {
  86. this.ispull = false;
  87. }
  88. this.acrelist = this.acrelist.concat(data.new_list);
  89. }
  90. })
  91. },
  92. confirm(e) {
  93. this.acrelist = [];
  94. this.keyword = e.detail.value;
  95. this.getlist();
  96. },
  97. search() {
  98. if(this.keyword == '') {
  99. this.$msg("关键字不能为空");
  100. return;
  101. }
  102. this.acrelist = [];
  103. this.getlist();
  104. },
  105. // 滚动到顶部
  106. upper(e) {
  107. console.log(e)
  108. console.log("顶部")
  109. },
  110. // 滚到底部
  111. lower(e) {
  112. this.page = this.page + 1;
  113. if(this.ispull) {
  114. this.getlist();
  115. }
  116. },
  117. // 滚动时触发
  118. scroll(e) {
  119. if(e.detail.scrollTop > 400) {
  120. this.isTop = true;
  121. }else{ //当距离小于500时显示回到顶部按钮
  122. this.isTop = false;
  123. }
  124. this.old.scrollTop = e.detail.scrollTop
  125. },
  126. }
  127. }
  128. </script>
  129. <style>
  130. .searchType .input-view {
  131. width: 80%;
  132. display: flex;
  133. background-color: #e7e7e7;
  134. height: 30px;
  135. border-radius: 15px;
  136. padding: 0 4%;
  137. flex-wrap: nowrap;
  138. margin: 7px 0;
  139. line-height: 30px;
  140. margin: 24upx 0 24upx 32upx;
  141. }
  142. .searchType .input-view .uni-icon {
  143. line-height: 30px !important;
  144. }
  145. .searchType .input-view .input {
  146. height: 30px;
  147. line-height: 30px;
  148. width: 94%;
  149. padding: 0 3%;
  150. }
  151. .van-cell__title {
  152. flex: 6!important;
  153. }
  154. .searchclass {
  155. display: flex;
  156. align-items: center;
  157. justify-content: center;
  158. }
  159. .van-cell {
  160. padding: 15upx 32upx 0 32upx!important;
  161. }
  162. .hotelList {
  163. display: flex;
  164. flex-direction: row;
  165. padding: 24upx 32upx;
  166. }
  167. .hotleLeft {
  168. width: 214upx;
  169. height: 152upx;
  170. }
  171. .hotelright {
  172. padding-left: 16upx;
  173. display: flex;
  174. flex-direction: column;
  175. width: 100%;
  176. }
  177. .undertip {
  178. display: flex;
  179. flex-direction: row;
  180. align-items: center;
  181. }
  182. .tipsTop {
  183. border: 2upx solid #BBBBBB;
  184. margin-right: 14upx;
  185. color: #BBBBBB;
  186. padding: 4upx;
  187. }
  188. /* .van-cell__title {
  189. flex: 6!important;
  190. } */
  191. </style>