science.vue 4.5 KB

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