lecture.vue 11 KB

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