science.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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.add_time | time}}
  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. filters: {
  44. time(val) {
  45. let arr = val.split(' ')
  46. return arr[0]
  47. }
  48. },
  49. methods:{
  50. //搜索
  51. // messagesearch(event) {
  52. // console.log(event.target.value)
  53. // let arrlist = [];
  54. // for (let i = 0; i < this.science.length; i++) {
  55. // if (this.science[i].title.indexOf(event.target.value) != -1) {
  56. // arrlist.push(this.science[i]);
  57. // }
  58. // }
  59. // this.science = arrlist;
  60. // if (event.target.value == '') {
  61. // this.loadData();
  62. // }
  63. // },
  64. messagesearch() {
  65. let keyword = this.keyword;
  66. console.log(keyword);
  67. let arrlist = [];
  68. for (let i = 0; i < this.science.length; i++) {
  69. if (this.science[i].title.indexOf(keyword) != -1) {
  70. arrlist.push(this.science[i]);
  71. }
  72. }
  73. this.science = arrlist;
  74. if (keyword == '') {
  75. this.loadData();
  76. }
  77. },
  78. loadData(){
  79. let obj = this;
  80. bannerlist().then(({ data }) => {
  81. console.log(data);
  82. obj.science = data.list;
  83. console.log(obj.science,'999999999999999999')
  84. });
  85. },
  86. Jump(id) {
  87. uni.navigateTo({
  88. url:"/pages/applic/info?id="+id
  89. })
  90. },
  91. }
  92. }
  93. </script>
  94. <style lang="scss">
  95. //搜索框
  96. .Search-box {
  97. padding-left: 20rpx;
  98. padding-right: 20rpx;
  99. height: 100rpx;
  100. background: #ffffff;
  101. display: flex;
  102. justify-content: space-between;
  103. align-items: center;
  104. .Search-box-sort {
  105. font-size: 30rpx;
  106. font-weight: 500;
  107. color: rgba(102, 102, 102, 1);
  108. .sort-text {
  109. width: 57rpx;
  110. height: 29rpx;
  111. font-size: 30rpx;
  112. font-weight: 500;
  113. color: rgba(51, 51, 51, 1);
  114. line-height: 58rpx;
  115. margin-right: 19rpx;
  116. }
  117. .sort-img {
  118. width: 21rpx;
  119. height: 11rpx;
  120. margin-bottom: 4rpx;
  121. }
  122. }
  123. .Search-box-size {
  124. width: 630rpx;
  125. height: 65rpx;
  126. border-radius: 32rpx;
  127. background-color: #f1f1f1;
  128. padding-left: 36rpx;
  129. display: flex;
  130. align-items: center;
  131. .box-img {
  132. height: 32rpx;
  133. width: 32rpx;
  134. margin-right: 16rpx;
  135. }
  136. .box-word {
  137. width: 100%;
  138. font-size: 22rpx;
  139. font-weight: 500;
  140. color: rgba(205, 203, 203, 1);
  141. line-height: 55rpx;
  142. }
  143. }
  144. }
  145. .content{
  146. line-height: 1;
  147. .list-box{
  148. width: 725rpx;
  149. height: 200rpx;
  150. margin: 20rpx auto 0;
  151. background: #FFFFFF;
  152. box-shadow: 0px 5rpx 5rpx 0px rgba(35, 24, 21, 0.06);
  153. border-radius: 7rpx;
  154. padding:0 20rpx;
  155. display: flex;
  156. align-items: center;
  157. .box-left{
  158. width: 230rpx;
  159. height: 145rpx;
  160. margin-right: 20rpx;
  161. .left-img{
  162. width: 230rpx;
  163. height: 145rpx;
  164. }
  165. }
  166. .box-right{
  167. width: 430rpx;
  168. height: 145rpx;
  169. position: relative;
  170. .right-top{
  171. font-size: 25rpx;
  172. font-weight: bold;
  173. color: #333333;
  174. margin-bottom: 24rpx;
  175. }
  176. .right-center{
  177. width: 362rpx;
  178. // height: 53rpx;
  179. font-size: 21rpx;
  180. font-weight: bold;
  181. color: #999999;
  182. line-height: 33rpx;
  183. overflow: hidden;
  184. text-overflow: ellipsis;
  185. display: -webkit-box;
  186. -webkit-line-clamp: 2;//在第几行显示...
  187. -webkit-box-orient: vertical;
  188. }
  189. .right-foot{
  190. font-size: 21rpx;
  191. font-weight: bold;
  192. color: #999999;
  193. line-height: 31rpx;
  194. text-align: right;
  195. // margin-top: 13rpx;
  196. position: absolute;
  197. right: 0;
  198. bottom: 0;
  199. }
  200. }
  201. }
  202. }
  203. </style>