search.vue 9.6 KB

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