search.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <view>
  3. <view class="top-content">
  4. <view class="search-cont">
  5. <view class="inner">
  6. <image class="icon-search" src="../../static/images/search.png" mode=""></image>
  7. <input type="text" v-model="searchValue" placeholder="请输入关键字或作者" confirm-type="search"
  8. @confirm="doSearch"
  9. placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  10. </view>
  11. </view>
  12. <view class="keyword-list">
  13. <!-- 关键字列表 -->
  14. <!-- <scroll-view scroll-x="true" > -->
  15. <view class="inner">
  16. <view v-for="(item,index) in cates" :key="index" :class="choseCateId == item.cateId?'item active':'item'" @click="choseCate(item)">
  17. {{ item.cateName }}
  18. </view>
  19. </view>
  20. <!-- </scroll-view> -->
  21. <!-- <u-tabs :list="cates" :activeStyle="{fontWeight: '500',color: '#333333',fontSize: '32rpx',lineHeight:'88rpx'}"
  22. :inactiveStyle="{color: '#999999',fontSize: '28rpx',lineHeight:'88rpx'}" @click="choseCate(item)"
  23. scrollable="false" lineColor="#388BFF"></u-tabs> -->
  24. </view>
  25. </view>
  26. <mescroll-body :top="top" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  27. :down="downOption" :up="upOption">
  28. <view class="know-list">
  29. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  30. <view class="image-box">
  31. <image class="bg" mode="aspectFill" :src="item.imageUrl"></image>
  32. <view v-if="choseCateId==0" class="views" >
  33. <image mode="aspectFill" src="@/static/image/icon_goon.png"></image>
  34. <view class="status">进行中</view>
  35. </view>
  36. <view v-else class="zhibo">
  37. <image mode="aspectFill" src="@/static/image/icon_video.png"></image>
  38. </view>
  39. </view>
  40. <view class="article-title-box">
  41. <view class="article-title one-t">王医生学术直播</view>
  42. <view class="name-title ">
  43. <image mode="aspectFill" src="@/static/image/icon_doctor.png"></image>
  44. <view class="one-t">
  45. 王小明-副主任医师/副主任副主任
  46. </view>
  47. </view>
  48. <view class="position-title">
  49. <image mode="aspectFill" src="@/static/image/icon_hospital.png"></image>
  50. <view class="one-t">
  51. 北京人民医院
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  57. <view class="image-box">
  58. <image class="bg" mode="aspectFill" :src="item.imageUrl"></image>
  59. <view v-if="choseCateId==0" class="views" >
  60. <image mode="aspectFill" src="@/static/image/icon_goon.png"></image>
  61. <view class="status">进行中</view>
  62. </view>
  63. <view v-else class="zhibo">
  64. <image mode="aspectFill" src="@/static/image/icon_video.png"></image>
  65. </view>
  66. </view>
  67. <view class="article-title-box">
  68. <view class="article-title one-t">王医生学术直播</view>
  69. <view class="name-title">
  70. <image mode="aspectFill" src="@/static/image/icon_doctor.png"></image>
  71. <view class="position-title">
  72. <image mode="aspectFill" src="@/static/image/icon_hospital.png"></image>
  73. <view class="one-t">
  74. 北京人民医院
  75. </view>
  76. </view>
  77. </view>
  78. <view class="position-title one-t">
  79. <image mode="aspectFill" src="@/static/image/icon_hospital.png"></image>北京人民医院
  80. </view>
  81. </view>
  82. </view>
  83. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  84. <view class="image-box">
  85. <image class="bg" mode="aspectFill" :src="item.imageUrl"></image>
  86. <view v-if="choseCateId==0" class="views" >
  87. <image mode="aspectFill" src="@/static/image/icon_goon.png"></image>
  88. <view class="status">进行中</view>
  89. </view>
  90. <view v-else class="zhibo">
  91. <image mode="aspectFill" src="@/static/image/icon_video.png"></image>
  92. </view>
  93. </view>
  94. <view class="article-title-box">
  95. <view class="article-title one-t">王医生学术直播</view>
  96. <view class="name-title">
  97. <image mode="aspectFill" src="@/static/image/icon_doctor.png"></image>
  98. <view class="one-t">
  99. 王小明-副主任医师/副主任副主任
  100. </view>
  101. </view>
  102. <view class="position-title">
  103. <image mode="aspectFill" src="@/static/image/icon_hospital.png"></image>
  104. <view class="one-t">
  105. 北京人民医院
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </mescroll-body>
  112. </view>
  113. </template>
  114. <script>
  115. import {
  116. getArticleCate,
  117. getArticleList
  118. } from '@/api/article'
  119. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  120. export default {
  121. mixins: [MescrollMixin],
  122. data() {
  123. return {
  124. top: '0px',
  125. cates: [
  126. {cateName: '在线讲座',cateId:0},
  127. {cateName:'空中课堂',cateId:1},
  128. ],
  129. choseCateId: 0,
  130. // 状态栏的高度
  131. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  132. searchValue: '',
  133. mescroll: null,
  134. // 上拉加载的配置
  135. downOption: {
  136. },
  137. upOption: {
  138. onScroll: true,
  139. use: true, // 是否启用上拉加载; 默认true
  140. page: {
  141. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  142. size: 10 // 每页数据的数量,默认10
  143. },
  144. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  145. empty: {
  146. icon: '/static/images/no_data.png',
  147. tip: '暂无数据'
  148. },
  149. textNoMore: '已经到底了'
  150. },
  151. // 列表数据
  152. dataList: [],
  153. };
  154. },
  155. onShow() {
  156. //this.getArticleCate();
  157. var that = this;
  158. setTimeout(function() {
  159. let query = uni.createSelectorQuery().select(".top-content");
  160. query.boundingClientRect(function(data) { //data - 各种参数
  161. console.log(data.height) // 获取元素宽度
  162. that.top = data.height + "px";
  163. }).exec()
  164. }, 500);
  165. },
  166. methods: {
  167. doSearch() {
  168. this.mescroll.resetUpScroll()
  169. },
  170. getArticleCate() {
  171. var that = this;
  172. let data = {};
  173. getArticleCate(data).then(
  174. res => {
  175. if (res.code == 200) {
  176. this.cates = res.data.map(person => ({
  177. name: person.cateName
  178. }));
  179. } else {
  180. uni.showToast({
  181. icon: 'none',
  182. title: "请求失败",
  183. });
  184. }
  185. },
  186. rej => {}
  187. );
  188. },
  189. mescrollInit(mescroll) {
  190. this.mescroll = mescroll;
  191. },
  192. /*下拉刷新的回调 */
  193. downCallback(mescroll) {
  194. mescroll.resetUpScroll()
  195. },
  196. upCallback(page) {
  197. //联网加载数据
  198. var that = this;
  199. var data = {
  200. keyword: this.searchValue,
  201. cateId: this.choseCateId,
  202. page: page.num,
  203. pageSize: page.size
  204. };
  205. getArticleList(data).then(res => {
  206. if (res.code == 200) {
  207. //设置列表数据
  208. if (page.num == 1) {
  209. that.dataList = res.data.list;
  210. } else {
  211. that.dataList = that.dataList.concat(res.data.list);
  212. }
  213. that.mescroll.endBySize(res.data.list.length, res.data.total);
  214. } else {
  215. uni.showToast({
  216. icon: 'none',
  217. title: "请求失败",
  218. });
  219. that.dataList = null;
  220. that.mescroll.endErr();
  221. }
  222. });
  223. },
  224. // 关键词选择
  225. choseCate(item) {
  226. this.choseCateId = item.cateId;
  227. this.mescroll.resetUpScroll()
  228. },
  229. // 查看详情
  230. showDetail(item) {
  231. uni.navigateTo({
  232. url: './detail?articleId=' + item.articleId
  233. })
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="scss">
  239. page {
  240. background: #EFF3F7;
  241. }
  242. .status_bar {
  243. width: 100%;
  244. }
  245. .top-content {
  246. width: 100%;
  247. position: fixed;
  248. top: 0;
  249. left: 0;
  250. z-index: 10;
  251. }
  252. .top-title {
  253. height: 88upx;
  254. line-height: 88upx;
  255. font-size: 42upx;
  256. font-family: Source Han Sans CN;
  257. font-weight: bold;
  258. color: #222222;
  259. padding-left: 41upx;
  260. }
  261. .search-cont {
  262. padding: 16upx 30upx;
  263. background: #fff;
  264. .inner {
  265. box-sizing: border-box;
  266. width: 100%;
  267. height: 72upx;
  268. background: #F7F8FA;
  269. border-radius: 36upx;
  270. display: flex;
  271. align-items: center;
  272. padding: 0 30upx;
  273. .icon-search {
  274. width: 28upx;
  275. height: 28upx;
  276. margin-right: 20upx;
  277. }
  278. input {
  279. height: 60upx;
  280. line-height: 60upx;
  281. flex: 1;
  282. }
  283. }
  284. }
  285. .keyword-list {
  286. box-sizing: border-box;
  287. // padding: 10upx 27upx;
  288. height: 88rpx;
  289. background: #FFFFFF;
  290. flex-shrink: 0;
  291. .inner {
  292. display: flex;
  293. align-items: center;
  294. justify-content: space-between;
  295. }
  296. .item {
  297. flex:1;
  298. display: flex;
  299. align-items: center;
  300. justify-content: center;
  301. flex-shrink: 0;
  302. height: 88upx;
  303. line-height: 88upx;
  304. font-size: 28upx;
  305. font-family: PingFang SC;
  306. font-weight: 400;
  307. color: #999999;
  308. position: relative;
  309. &.active {
  310. font-weight: 500;
  311. color: #333333;
  312. &::after {
  313. content: "";
  314. width: 56upx;
  315. height: 6upx;
  316. background: #388BFF;
  317. position: absolute;
  318. bottom: 0;
  319. border-radius: 3rpx 3rpx 3rpx 3rpx;
  320. }
  321. }
  322. }
  323. }
  324. .know-list {
  325. margin-top: 24upx;
  326. padding: 0 24upx;
  327. display: flex;
  328. align-items: center;
  329. flex-direction: row;
  330. flex-shrink: 0;
  331. flex-wrap: wrap;
  332. width: 100%;
  333. box-sizing: border-box;
  334. .item {
  335. box-sizing: border-box;
  336. width: calc(50% - 10rpx);
  337. height: 340rpx;
  338. background: #FFFFFF;
  339. border-radius: 16upx;
  340. display: flex;
  341. align-items: center;
  342. justify-content: flex-start;
  343. flex-direction: column;
  344. margin-bottom: 18rpx;
  345. margin-right: 18rpx;
  346. &:nth-child(2){
  347. margin-right:0;
  348. }
  349. .image-box {
  350. width: 100%;
  351. height: 192rpx;
  352. position: relative;
  353. border-radius: 16rpx 16rpx 0rpx 0rpx;
  354. .bg {
  355. border-radius: 16rpx 16rpx 0rpx 0rpx;
  356. width: 100%;
  357. height: 100%;
  358. }
  359. .views {
  360. position: absolute;
  361. top: 0rpx;
  362. left: 0rpx;
  363. width: 112rpx;
  364. height: 32rpx;
  365. display: flex;
  366. align-items: center;
  367. background: rgba(0, 0, 0, 0.4);
  368. border-radius: 16rpx 0rpx 16rpx 0rpx;
  369. font-weight: 500;
  370. font-size: 20rpx;
  371. color: #FFFFFF;
  372. font-family: PingFang SC-Bold, PingFang SC;
  373. image {
  374. width: 36rpx;
  375. height: 32rpx;
  376. margin-right: 8rpx;
  377. }
  378. }
  379. .zhibo {
  380. position: absolute;
  381. top: 50%;
  382. left: 50%;
  383. transform: translate(-50%, -50%);
  384. image {
  385. width: 56rpx;
  386. height: 56rpx;
  387. }
  388. }
  389. }
  390. .article-title-box {
  391. width: 100%;
  392. padding: 16rpx;
  393. display: flex;
  394. align-items: flex-start;
  395. flex-direction: column;
  396. justify-content: space-between;
  397. height: 148rpx;
  398. box-sizing: border-box;
  399. .article-title {
  400. font-family: PingFang SC, PingFang SC;
  401. font-weight: 500;
  402. font-size: 28rpx;
  403. color: #333333;
  404. .one-t{
  405. width: 100%;
  406. }
  407. }
  408. .name-title {
  409. display: flex;
  410. align-items: center;
  411. font-family: PingFang SC, PingFang SC;
  412. font-weight: 400;
  413. font-size: 22rpx;
  414. color: #999999;
  415. .one-t{
  416. width: 80%;
  417. }
  418. image {
  419. width: 28rpx;
  420. height: 28rpx;
  421. margin-right: 14rpx;
  422. }
  423. }
  424. .position-title {
  425. display: flex;
  426. align-items: center;
  427. font-family: PingFang SC, PingFang SC;
  428. font-weight: 400;
  429. font-size: 22rpx;
  430. color: #999999;
  431. .one-t{
  432. width: 80%;
  433. }
  434. image {
  435. width: 28rpx;
  436. height: 28rpx;
  437. margin-right: 14rpx;
  438. }
  439. }
  440. }
  441. }
  442. }
  443. </style>