science.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <!-- 搜索框 -->
  5. <view class="Search-box">
  6. <view class="Search-box-size">
  7. <image class="box-img" src="../../static/images/img01.png"></image>
  8. <input type="text" class="box-word" placeholder="请输入关键字" v-model="keyword" />
  9. </view>
  10. <view class="Search-box-sort" @click="messagesearch">搜索</view>
  11. </view>
  12. </view>
  13. <view class="list-box" v-for="(item,index) in science" :key='index' @click="Jump(item.id)">
  14. <view class="box-left">
  15. <image :src="item.image_input[0]" mode="" class="left-img"></image>
  16. </view>
  17. <view class="box-right">
  18. <view class="right-top word1_ellipsis">
  19. {{item.title}}
  20. </view>
  21. <view class="right-center">
  22. {{item.synopsis}}
  23. </view>
  24. <view class="right-foot">
  25. {{item.visit}}阅读
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import { bannerlist} from '@/api/index.js';
  33. export default{
  34. data(){
  35. return{
  36. keyword:'',
  37. science:[]
  38. }
  39. },
  40. onLoad() {
  41. this.loadData();
  42. },
  43. methods:{
  44. //搜索
  45. // messagesearch(event) {
  46. // console.log(event.target.value)
  47. // let arrlist = [];
  48. // for (let i = 0; i < this.science.length; i++) {
  49. // if (this.science[i].title.indexOf(event.target.value) != -1) {
  50. // arrlist.push(this.science[i]);
  51. // }
  52. // }
  53. // this.science = arrlist;
  54. // if (event.target.value == '') {
  55. // this.loadData();
  56. // }
  57. // },
  58. messagesearch() {
  59. let keyword = this.keyword;
  60. console.log(keyword);
  61. let arrlist = [];
  62. for (let i = 0; i < this.science.length; i++) {
  63. if (this.science[i].title.indexOf(keyword) != -1) {
  64. arrlist.push(this.science[i]);
  65. }
  66. }
  67. this.science = arrlist;
  68. if (keyword == '') {
  69. this.loadData();
  70. }
  71. },
  72. loadData(){
  73. let obj = this;
  74. bannerlist().then(({ data }) => {
  75. console.log(data);
  76. obj.science = data;
  77. });
  78. },
  79. Jump(id) {
  80. uni.navigateTo({
  81. url:"/pages/applic/info?id="+id
  82. })
  83. },
  84. }
  85. }
  86. </script>
  87. <style lang="scss">
  88. //搜索框
  89. .Search-box {
  90. padding-left: 20rpx;
  91. padding-right: 20rpx;
  92. height: 100rpx;
  93. background: #ffffff;
  94. display: flex;
  95. justify-content: space-between;
  96. align-items: center;
  97. .Search-box-sort {
  98. font-size: 30rpx;
  99. font-weight: 500;
  100. color: rgba(102, 102, 102, 1);
  101. .sort-text {
  102. width: 57rpx;
  103. height: 29rpx;
  104. font-size: 30rpx;
  105. font-weight: 500;
  106. color: rgba(51, 51, 51, 1);
  107. line-height: 58rpx;
  108. margin-right: 19rpx;
  109. }
  110. .sort-img {
  111. width: 21rpx;
  112. height: 11rpx;
  113. margin-bottom: 4rpx;
  114. }
  115. }
  116. .Search-box-size {
  117. width: 630rpx;
  118. height: 65rpx;
  119. border-radius: 32rpx;
  120. background-color: #f1f1f1;
  121. padding-left: 36rpx;
  122. display: flex;
  123. align-items: center;
  124. .box-img {
  125. height: 32rpx;
  126. width: 32rpx;
  127. margin-right: 16rpx;
  128. }
  129. .box-word {
  130. width: 100%;
  131. font-size: 22rpx;
  132. font-weight: 500;
  133. color: rgba(205, 203, 203, 1);
  134. line-height: 55rpx;
  135. }
  136. }
  137. }
  138. .content{
  139. line-height: 1;
  140. .list-box{
  141. width: 725rpx;
  142. height: 200rpx;
  143. margin: 20rpx auto 0;
  144. background: #FFFFFF;
  145. box-shadow: 0px 5rpx 5rpx 0px rgba(35, 24, 21, 0.06);
  146. border-radius: 7rpx;
  147. padding:0 20rpx;
  148. display: flex;
  149. align-items: center;
  150. .box-left{
  151. width: 230rpx;
  152. height: 145rpx;
  153. margin-right: 20rpx;
  154. .left-img{
  155. width: 230rpx;
  156. height: 145rpx;
  157. }
  158. }
  159. .box-right{
  160. width: 430rpx;
  161. height: 145rpx;
  162. .right-top{
  163. font-size: 25rpx;
  164. font-weight: bold;
  165. color: #333333;
  166. margin-bottom: 24rpx;
  167. }
  168. .right-center{
  169. width: 362rpx;
  170. // height: 53rpx;
  171. font-size: 21rpx;
  172. font-weight: bold;
  173. color: #999999;
  174. line-height: 33rpx;
  175. overflow: hidden;
  176. text-overflow: ellipsis;
  177. display: -webkit-box;
  178. -webkit-line-clamp: 2;//在第几行显示...
  179. -webkit-box-orient: vertical;
  180. }
  181. .right-foot{
  182. font-size: 21rpx;
  183. font-weight: bold;
  184. color: #999999;
  185. line-height: 31rpx;
  186. text-align: right;
  187. margin-top: 13rpx;
  188. }
  189. }
  190. }
  191. }
  192. </style>