science.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. <scroll-view scroll-y="true" :style="{'height': height}" class="good-content">
  14. <view class="list-box" v-for="(item,index) in science" :key='index' @click="Jump(item.id)">
  15. <view class="box-left">
  16. <image :src="(item.image.indexOf('http') != -1 )? item.image: ($store.state.baseURL + item.image)"
  17. mode="" class="left-img"></image>
  18. </view>
  19. <view class="box-right">
  20. <view class="right-top word1_ellipsis">
  21. {{item.title}}
  22. </view>
  23. <view class="right-center">
  24. {{item.synopsis}}
  25. </view>
  26. <view class="right-foot">
  27. <!-- 已阅读人数:{{item.visit || 0}} -->
  28. </view>
  29. </view>
  30. </view>
  31. <uni-load-more :status="loadingType"></uni-load-more>
  32. </scroll-view>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. getArticList
  38. } from '@/api/index.js';
  39. export default {
  40. data() {
  41. return {
  42. loadingType: 'more',
  43. keyword: '',
  44. science: [],
  45. page: 1,
  46. limit: 10,
  47. height: '',
  48. }
  49. },
  50. onLoad() {
  51. this.loadData();
  52. },
  53. onReady(res) {
  54. var obj = this;
  55. uni.getSystemInfo({
  56. success: resu => {
  57. const query = uni.createSelectorQuery();
  58. query.select('.good-content').boundingClientRect();
  59. query.exec(function(res) {
  60. obj.height = resu.windowHeight - res[0].top + 'px';
  61. });
  62. },
  63. fail: res => {}
  64. });
  65. },
  66. onReachBottom() {
  67. this.loadData()
  68. },
  69. filters: {
  70. time(val) {
  71. let arr = val.split(' ')
  72. return arr[0]
  73. }
  74. },
  75. methods: {
  76. messagesearch() {
  77. let keyword = this.keyword;
  78. console.log(keyword);
  79. let arrlist = [];
  80. for (let i = 0; i < this.science.length; i++) {
  81. if (this.science[i].title.indexOf(keyword) != -1) {
  82. arrlist.push(this.science[i]);
  83. }
  84. }
  85. this.science = arrlist;
  86. if (keyword == '') {
  87. this.loadData();
  88. }
  89. },
  90. loadData() {
  91. let obj = this;
  92. if(obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  93. return
  94. }
  95. obj.loadingType = 'loading'
  96. getArticList({
  97. ifyid: 55
  98. }).then(({
  99. data
  100. }) => {
  101. obj.science = obj.science.concat(data.list);
  102. obj.page++
  103. if (obj.limit == data.list) {
  104. obj.loadingType = 'more'
  105. } else {
  106. obj.loadingType = 'noMore'
  107. }
  108. });
  109. },
  110. Jump(id) {
  111. uni.navigateTo({
  112. url: "/pages/applic/info?id=" + id
  113. })
  114. },
  115. }
  116. }
  117. </script>
  118. <style lang="scss">
  119. //搜索框
  120. .Search-box {
  121. padding-left: 20rpx;
  122. padding-right: 20rpx;
  123. height: 100rpx;
  124. background: #ffffff;
  125. display: flex;
  126. justify-content: space-between;
  127. align-items: center;
  128. .Search-box-sort {
  129. font-size: 30rpx;
  130. font-weight: 500;
  131. color: rgba(102, 102, 102, 1);
  132. .sort-text {
  133. width: 57rpx;
  134. height: 29rpx;
  135. font-size: 30rpx;
  136. font-weight: 500;
  137. color: rgba(51, 51, 51, 1);
  138. line-height: 58rpx;
  139. margin-right: 19rpx;
  140. }
  141. .sort-img {
  142. width: 21rpx;
  143. height: 11rpx;
  144. margin-bottom: 4rpx;
  145. }
  146. }
  147. .Search-box-size {
  148. width: 630rpx;
  149. height: 65rpx;
  150. border-radius: 32rpx;
  151. background-color: #f1f1f1;
  152. padding-left: 36rpx;
  153. display: flex;
  154. align-items: center;
  155. .box-img {
  156. height: 32rpx;
  157. width: 32rpx;
  158. margin-right: 16rpx;
  159. }
  160. .box-word {
  161. width: 100%;
  162. font-size: 22rpx;
  163. font-weight: 500;
  164. color: rgba(205, 203, 203, 1);
  165. line-height: 55rpx;
  166. }
  167. }
  168. }
  169. .content {
  170. line-height: 1;
  171. .list-box {
  172. width: 725rpx;
  173. height: 200rpx;
  174. margin: 0 auto 20rpx;
  175. background: #FFFFFF;
  176. box-shadow: 0px 5rpx 5rpx 0px rgba(35, 24, 21, 0.06);
  177. border-radius: 7rpx;
  178. padding: 0 20rpx;
  179. display: flex;
  180. align-items: center;
  181. .box-left {
  182. width: 230rpx;
  183. height: 145rpx;
  184. margin-right: 20rpx;
  185. .left-img {
  186. width: 230rpx;
  187. height: 145rpx;
  188. }
  189. }
  190. .box-right {
  191. width: 430rpx;
  192. height: 145rpx;
  193. position: relative;
  194. .right-top {
  195. font-size: 25rpx;
  196. font-weight: bold;
  197. color: #333333;
  198. margin-bottom: 24rpx;
  199. }
  200. .right-center {
  201. width: 362rpx;
  202. // height: 53rpx;
  203. font-size: 21rpx;
  204. font-weight: bold;
  205. color: #999999;
  206. line-height: 33rpx;
  207. overflow: hidden;
  208. text-overflow: ellipsis;
  209. display: -webkit-box;
  210. -webkit-line-clamp: 2; //在第几行显示...
  211. -webkit-box-orient: vertical;
  212. }
  213. .right-foot {
  214. font-size: 21rpx;
  215. font-weight: bold;
  216. color: #999999;
  217. line-height: 31rpx;
  218. text-align: right;
  219. // margin-top: 13rpx;
  220. position: absolute;
  221. right: 0;
  222. bottom: 0;
  223. }
  224. }
  225. }
  226. }
  227. .good-content {
  228. padding-top: 20rpx;
  229. }
  230. </style>