lesson.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="zhibo">
  33. <image mode="aspectFill" src="@/static/image/icon_video.png"></image>
  34. </view>
  35. </view>
  36. <view class="article-title-box">
  37. <view class="article-title one-t">王医生学术直播</view>
  38. <view class="name-title ">
  39. <image mode="aspectFill" src="@/static/image/icon_doctor.png"></image>
  40. <view class="one-t">
  41. 王小明-副主任医师/副主任副主任
  42. </view>
  43. </view>
  44. <view class="position-title">
  45. <image mode="aspectFill" src="@/static/image/icon_hospital.png"></image>
  46. <view class="one-t">
  47. 北京人民医院
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  53. <view class="image-box">
  54. <image class="bg" mode="aspectFill" :src="item.imageUrl"></image>
  55. <view class="zhibo">
  56. <image mode="aspectFill" src="@/static/image/icon_video.png"></image>
  57. </view>
  58. </view>
  59. <view class="article-title-box">
  60. <view class="article-title one-t">王医生学术直播</view>
  61. <view class="name-title">
  62. <image mode="aspectFill" src="@/static/image/icon_doctor.png"></image>
  63. <view class="position-title">
  64. <image mode="aspectFill" src="@/static/image/icon_hospital.png"></image>
  65. <view class="one-t">
  66. 北京人民医院
  67. </view>
  68. </view>
  69. </view>
  70. <view class="position-title one-t">
  71. <image mode="aspectFill" src="@/static/image/icon_hospital.png"></image>北京人民医院
  72. </view>
  73. </view>
  74. </view>
  75. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  76. <view class="image-box">
  77. <image class="bg" mode="aspectFill" :src="item.imageUrl"></image>
  78. <view class="zhibo">
  79. <image mode="aspectFill" src="@/static/image/icon_video.png"></image>
  80. </view>
  81. </view>
  82. <view class="article-title-box">
  83. <view class="article-title one-t">王医生学术直播</view>
  84. <view class="name-title">
  85. <image mode="aspectFill" src="@/static/image/icon_doctor.png"></image>
  86. <view class="one-t">
  87. 王小明-副主任医师/副主任副主任
  88. </view>
  89. </view>
  90. <view class="position-title">
  91. <image mode="aspectFill" src="@/static/image/icon_hospital.png"></image>
  92. <view class="one-t">
  93. 北京人民医院
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </mescroll-body>
  100. </view>
  101. </template>
  102. <script>
  103. import {
  104. getArticleCate,
  105. getArticleList
  106. } from '@/api/article'
  107. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  108. export default {
  109. mixins: [MescrollMixin],
  110. data() {
  111. return {
  112. top: '0px',
  113. cates: [
  114. {name: '全部',cateId:0},
  115. {name:'内分泌',cateId:1},
  116. {name:'肾病',cateId:2},
  117. {name:'心血管',cateId:3},
  118. {name:'风湿免疫',cateId:4},
  119. {name:'风湿免疫',cateId:5},
  120. ],
  121. choseCateId: 0,
  122. // 状态栏的高度
  123. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  124. searchValue: '',
  125. mescroll: null,
  126. // 上拉加载的配置
  127. downOption: {
  128. },
  129. upOption: {
  130. onScroll: true,
  131. use: true, // 是否启用上拉加载; 默认true
  132. page: {
  133. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  134. size: 10 // 每页数据的数量,默认10
  135. },
  136. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  137. empty: {
  138. icon: '/static/images/no_data.png',
  139. tip: '暂无数据'
  140. },
  141. textNoMore: '没有更多了~'
  142. },
  143. // 列表数据
  144. dataList: [],
  145. };
  146. },
  147. onShow() {
  148. //this.getArticleCate();
  149. var that = this;
  150. setTimeout(function() {
  151. let query = uni.createSelectorQuery().select(".top-content");
  152. query.boundingClientRect(function(data) { //data - 各种参数
  153. console.log(data.height) // 获取元素宽度
  154. that.top = data.height + "px";
  155. }).exec()
  156. }, 500);
  157. },
  158. methods: {
  159. doSearch() {
  160. this.mescroll.resetUpScroll()
  161. },
  162. getArticleCate() {
  163. var that = this;
  164. let data = {};
  165. getArticleCate(data).then(
  166. res => {
  167. if (res.code == 200) {
  168. this.cates = res.data.map(person => ({
  169. name: person.cateName
  170. }));
  171. } else {
  172. uni.showToast({
  173. icon: 'none',
  174. title: "请求失败",
  175. });
  176. }
  177. },
  178. rej => {}
  179. );
  180. },
  181. mescrollInit(mescroll) {
  182. this.mescroll = mescroll;
  183. },
  184. /*下拉刷新的回调 */
  185. downCallback(mescroll) {
  186. mescroll.resetUpScroll()
  187. },
  188. upCallback(page) {
  189. //联网加载数据
  190. var that = this;
  191. var data = {
  192. keyword: this.searchValue,
  193. cateId: this.choseCateId,
  194. page: page.num,
  195. pageSize: page.size
  196. };
  197. getArticleList(data).then(res => {
  198. if (res.code == 200) {
  199. //设置列表数据
  200. if (page.num == 1) {
  201. that.dataList = res.data.list;
  202. } else {
  203. that.dataList = that.dataList.concat(res.data.list);
  204. }
  205. that.mescroll.endBySize(res.data.list.length, res.data.total);
  206. } else {
  207. uni.showToast({
  208. icon: 'none',
  209. title: "请求失败",
  210. });
  211. that.dataList = null;
  212. that.mescroll.endErr();
  213. }
  214. });
  215. },
  216. // 关键词选择
  217. choseCate(item) {
  218. this.choseCateId = item.cateId;
  219. this.mescroll.resetUpScroll()
  220. },
  221. // 查看详情
  222. showDetail(item) {
  223. uni.navigateTo({
  224. url: './detail?articleId=' + item.articleId
  225. })
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="scss">
  231. page {
  232. background: #EFF3F7;
  233. }
  234. .status_bar {
  235. width: 100%;
  236. }
  237. .top-content {
  238. width: 100%;
  239. position: fixed;
  240. top: 0;
  241. left: 0;
  242. z-index: 10;
  243. }
  244. .top-title {
  245. height: 88upx;
  246. line-height: 88upx;
  247. font-size: 42upx;
  248. font-family: Source Han Sans CN;
  249. font-weight: bold;
  250. color: #222222;
  251. padding-left: 41upx;
  252. }
  253. .search-cont {
  254. padding: 16upx 30upx;
  255. background: #fff;
  256. .inner {
  257. box-sizing: border-box;
  258. width: 100%;
  259. height: 72upx;
  260. background: #F7F8FA;
  261. border-radius: 36upx;
  262. display: flex;
  263. align-items: center;
  264. padding: 0 30upx;
  265. .icon-search {
  266. width: 28upx;
  267. height: 28upx;
  268. margin-right: 20upx;
  269. }
  270. input {
  271. height: 60upx;
  272. line-height: 60upx;
  273. flex: 1;
  274. }
  275. }
  276. }
  277. .keyword-list {
  278. box-sizing: border-box;
  279. padding:0 24rpx;
  280. height: 88rpx;
  281. background: #FFFFFF;
  282. flex-shrink: 0;
  283. .inner {
  284. display: flex;
  285. align-items: center;
  286. justify-content: space-between;
  287. }
  288. .item {
  289. flex:1;
  290. display: flex;
  291. align-items: center;
  292. justify-content: center;
  293. flex-shrink: 0;
  294. height: 88upx;
  295. line-height: 88upx;
  296. font-size: 28upx;
  297. font-family: PingFang SC;
  298. font-weight: 400;
  299. color: #999999;
  300. position: relative;
  301. &.active {
  302. font-weight: 500;
  303. font-size: 32rpx;
  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>