ariclle.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. isHttp:true,
  55. }
  56. },
  57. onLoad() {
  58. //this.getype(); // 获取文章分类
  59. ///this.getlist(); // 获取文章列表
  60. },
  61. methods: {
  62. goIndex(items) {
  63. let article_id = items.article_id;
  64. let ac_id = items.ac_id;
  65. let name = '';
  66. this.typelist.forEach((item, index) => {
  67. if(item.ac_id == ac_id) {
  68. name = item.ac_name;
  69. }
  70. })
  71. uni.navigateTo({
  72. url: `/pages/myone/onedetail?id=${article_id}&name=${name}`
  73. });
  74. },
  75. getlist() {
  76. this.isHttp=false;
  77. this.request({
  78. url: '/v1/entry/news',
  79. method:'POST',
  80. data: {
  81. page: this.page,
  82. page_size: this.page_size,
  83. keyword: this.keyword
  84. },
  85. success: (res) => {
  86. let { data } = res.data;
  87. if(data.total_page == data.current_page) {
  88. this.ispull = false;
  89. }
  90. this.acrelist = this.acrelist.concat(data.new_list);
  91. this.isHttp=true;
  92. },
  93. })
  94. },
  95. confirm(e) {
  96. this.acrelist = [];
  97. this.keyword = e.detail.value;
  98. this.getlist();
  99. },
  100. search() {
  101. if(this.keyword == '') {
  102. this.$msg("关键字不能为空");
  103. return;
  104. }
  105. this.acrelist = [];
  106. if(this.isHttp){
  107. this.getlist();
  108. }
  109. },
  110. // 滚动到顶部
  111. upper(e) {
  112. console.log(e)
  113. console.log("顶部")
  114. },
  115. // 滚到底部
  116. lower(e) {
  117. this.page = this.page + 1;
  118. if(this.ispull) {
  119. this.getlist();
  120. }
  121. },
  122. // 滚动时触发
  123. scroll(e) {
  124. if(e.detail.scrollTop > 400) {
  125. this.isTop = true;
  126. }else{ //当距离小于500时显示回到顶部按钮
  127. this.isTop = false;
  128. }
  129. this.old.scrollTop = e.detail.scrollTop
  130. },
  131. }
  132. }
  133. </script>
  134. <style>
  135. .searchType .input-view {
  136. width: 80%;
  137. display: flex;
  138. background-color: #e7e7e7;
  139. height: 30px;
  140. border-radius: 15px;
  141. padding: 0 4%;
  142. flex-wrap: nowrap;
  143. margin: 7px 0;
  144. line-height: 30px;
  145. margin: 24upx 0 24upx 32upx;
  146. }
  147. .searchType .input-view .uni-icon {
  148. line-height: 30px !important;
  149. }
  150. .searchType .input-view .input {
  151. height: 30px;
  152. line-height: 30px;
  153. width: 94%;
  154. padding: 0 3%;
  155. }
  156. .van-cell__title {
  157. flex: 6!important;
  158. }
  159. .searchclass {
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. }
  164. .van-cell {
  165. padding: 15upx 32upx 0 32upx!important;
  166. }
  167. .hotelList {
  168. display: flex;
  169. flex-direction: row;
  170. padding: 24upx 32upx;
  171. }
  172. .hotleLeft {
  173. width: 214upx;
  174. height: 152upx;
  175. }
  176. .hotelright {
  177. padding-left: 16upx;
  178. display: flex;
  179. flex-direction: column;
  180. width: 100%;
  181. }
  182. .undertip {
  183. display: flex;
  184. flex-direction: row;
  185. align-items: center;
  186. }
  187. .tipsTop {
  188. border: 2upx solid #BBBBBB;
  189. margin-right: 14upx;
  190. color: #BBBBBB;
  191. padding: 4upx;
  192. }
  193. /* .van-cell__title {
  194. flex: 6!important;
  195. } */
  196. </style>