famousHall.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <view class="content" >
  3. <image class="home_top_bg" src="https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com/fs/20250115/1736955760372.png" mode="widthFix"></image>
  4. <view class="navBar">
  5. <view class="grace-page-header" :style="{'z-index':headerIndex }">
  6. <!-- 沉浸式状态栏 -->
  7. <view class="grace-page-status-bar" :style="{height:statusBarHeight+'px', background:statusBarBG}"></view>
  8. <!-- 头部核心 -->
  9. <view class="grace-page-header-nav" id="gracePageHeader" :style="{minHeight:headerHeight+'px', height:headerHeight+'px', overflow:'hidden'}">
  10. <view class="u-nav-back" @click="goBack">
  11. <image class="img" src="@/static/images/course/black_back.png" mode="heightFix"></image>
  12. </view>
  13. <view class="grace-header-main">{{navTitle}}</view>
  14. </view>
  15. </view>
  16. <view :style="{width:'100%', height:(headerHeight+statusBarHeight) + 'px'}"></view>
  17. </view>
  18. <!-- <mescroll-body :sticky="true" @init="mescrollInit" @down="downCallback" :down="downOption" :up="upOption"> -->
  19. <view class="cont-box">
  20. <view class="top-section">
  21. <view class="search-header-nav" id="gracePageHeader">
  22. <view class="search-header-main" style="height: auto;">
  23. <image src="@/static/images/course/icon_search.png" mode=""></image>
  24. <input class="input-text" @input="inputEvent" type="text" placeholder="搜索课程内容"/>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- sticky吸顶悬浮的菜单, 父元素必须是 mescroll -->
  29. <view>
  30. <me-tabs :value="tabIndex" :tabs="mtabs" nameKey="dictLabel" :height="88" @change="tabChange" :tab-width="134"></me-tabs>
  31. </view>
  32. <view class="scroll">
  33. <swiper :style="{'height': swHeight}" :current="tabIndex" @change="swiperChange" v-if="mtabs.length>0">
  34. <swiper-item v-for="(tab,i) in mtabs" :key="i">
  35. <famous-hall-item ref="mescrollItem" :i="i" :disable-scroll="disableScroll" :index="tabIndex" :tipsArr="tipsArr"></famous-hall-item>
  36. </swiper-item>
  37. </swiper>
  38. </view>
  39. <!-- <view class="scroll">
  40. <famous-hall-page ref="mescrollItem0" :mtabs="tabs" :tabTop="tabTop" :tipsArr="tipsArr"></famous-hall-page>
  41. </view> -->
  42. </view>
  43. <!-- </mescroll-body> -->
  44. </view>
  45. </template>
  46. <script>
  47. // import MescrollCompMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-comp.js";
  48. // import MescrollMoreMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more.js";
  49. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  50. import famousHallItem from "./famousHallPageItem.vue"
  51. import famousHallPage from "./famousHallPage.vue"
  52. import { getCourseCate,getCourseList } from '@/api/course'
  53. export default {
  54. mixins: [ MescrollMixin ], //mescroll-body写在子组件时
  55. components: {
  56. famousHallItem,
  57. famousHallPage
  58. },
  59. watch: {
  60. tabIndex(i) {
  61. // 当列表禁止滚动时,需把列表滚动条置顶 (解决问题: "全部"tab翻到第二页,切换到其他tab,滚动到顶部,再切回"全部"tab,此时的列表数据应该重头开始)
  62. if(this.disableScroll){
  63. this.disableScroll = false // 当disableScroll=true时,scroll-view的scrollTo会失效,需先开启,再置顶
  64. this.$nextTick(()=>{
  65. let mescroll = this.getMescroll(i)
  66. mescroll && mescroll.scrollTo(0,0)
  67. setTimeout(()=>{ // 经测试android真机需延时300ms才能恢复禁止滚动,否则scrollTo有可能无效
  68. this.disableScroll = true
  69. },300)
  70. });
  71. }
  72. }
  73. },
  74. data() {
  75. return {
  76. headerHeight:44,
  77. statusBarHeight: 0,
  78. tabTop:0,
  79. navigationBarHeight:44,
  80. headerBG:"#FF5C03",
  81. statusBarBG:"none",
  82. headerIndex:98,
  83. swHeight: "800px",
  84. downOption: { //下拉刷新
  85. use:false,
  86. },
  87. upOption: { //上拉加载
  88. use: false // 主体框架只启用下拉刷新
  89. },
  90. tipsArr:[],
  91. tabIndex: 0, // tab下标
  92. current: 0,
  93. mtabs:["精选","学科","入门","经典","名医"],
  94. fixedTop: false,
  95. topHeight:0,
  96. disableScroll: false, // swiper列表是否禁止滚动
  97. cateId:0,
  98. dataList:[],
  99. keyword:"",
  100. type:0,
  101. navTitle:""
  102. }
  103. },
  104. created() {
  105. // var system = uni.getSystemInfoSync();
  106. // system.model = system.model.replace(' ', '');
  107. // system.model = system.model.toLowerCase();
  108. // if (system.model.indexOf('iphonex') != -1 || system.model.indexOf('iphone1') != -1) {
  109. // this.iphoneXButtomHeight = uni.upx2px(50);
  110. // }
  111. },
  112. mounted() {
  113. try {
  114. const system = uni.getSystemInfoSync();
  115. let navigationBarHeight=44,tabHei=50,searchBarHei=88;
  116. let tempHei=navigationBarHeight+tabHei+system.statusBarHeight;
  117. tempHei=tempHei+uni.upx2px(searchBarHei);
  118. tempHei=system.windowHeight-tempHei;
  119. this.swHeight=tempHei+"px";
  120. this.statusBarHeight = system.statusBarHeight;
  121. } catch (e) {
  122. }
  123. },
  124. onLoad(options){
  125. this.type=options.type;
  126. this.navTitle=this.type==0?"名医讲堂":"课程讲堂"
  127. this.getCourseCate();
  128. },
  129. methods: {
  130. swiperChange(e){
  131. //this.tabIndex = e.detail.current;
  132. this.tabChange(e.detail.current);
  133. },
  134. /*下拉刷新的回调 */
  135. downCallback() {
  136. this.mescroll.resetUpScroll(true);
  137. this.requestData();
  138. },
  139. /*上拉加载的回调*/
  140. upCallback(page) {
  141. this.mescroll.endByPage(1, 1);
  142. //this.mescroll.endSuccess(8,false);
  143. // if (page.num == 1) {
  144. // this.mescroll.endSuccess(8, false);
  145. // } else {
  146. // this.mescroll.endErr()
  147. // }
  148. },
  149. refreshPage(index){
  150. let vForItem = this.$refs["mescrollItem"];
  151. let mescrollP=vForItem[index];
  152. mescrollP.tabs=this.mtabs;
  153. mescrollP.cateId=this.cateId;
  154. mescrollP.keyword= this.keyword;
  155. const item=this.mtabs[index];
  156. mescrollP.isBest=item.dictLabel=='精选'; //精选
  157. mescrollP.getProductCateByPid();
  158. mescrollP.mescroll.triggerDownScroll();
  159. },
  160. getCourseCate:function(){
  161. let that=this;
  162. getCourseCate().then(res => {
  163. if(res.code==200){
  164. this.mtabs=res.data;
  165. let findIdx=this.mtabs.findIndex(item=>item.dictLabel=='精选');
  166. console.log("qxj findIdx:"+findIdx);
  167. if(findIdx==-1){
  168. let dictItem={"dictValue":0,"dictLabel": "精选"};
  169. this.mtabs.unshift(dictItem);
  170. }
  171. if(this.mtabs.length>0){
  172. this.cateId=this.mtabs[0].dictValue;
  173. this.refreshPage(0);
  174. }
  175. }
  176. },
  177. rej => {}
  178. );
  179. },
  180. // 切换菜单
  181. tabChange (index) {
  182. // let preTab = this.tabs[this.preIndex]
  183. // preTab.y = this.mescroll.getScrollTop()
  184. // this.preIndex = index;
  185. this.tabIndex=index;
  186. const item=this.mtabs[index];
  187. if(item){
  188. this.cateId=item.dictValue;
  189. this.refreshPage(index);
  190. }
  191. // this.mescroll.optUp.use=this.tabIndex>0;
  192. // let curTab = this.tabs[index];
  193. // if(index==0){
  194. // this.mescroll.hideUpScroll();
  195. // this.mescroll.removeEmpty();
  196. // this.$nextTick(()=>{
  197. // this.mescroll.scrollTo(curTab.y, 0) // 恢复滚动条的位置
  198. // });
  199. // }
  200. },
  201. inputEvent(event){
  202. //console.log("qxj event:"+JSON.stringify(event));
  203. let vForItem = this.$refs["mescrollItem"];
  204. let mescrollP=vForItem[this.tabIndex];
  205. this.keyword=event.detail.value;
  206. mescrollP.keyword= this.keyword;
  207. mescrollP.mescroll.resetUpScroll();
  208. },
  209. // 获取指定下标的mescroll对象
  210. getMescroll(i){
  211. let mescrollItems = this.$refs.mescrollItem;
  212. if(mescrollItems){
  213. let item = mescrollItems[i]
  214. if(item) return item.mescroll
  215. }
  216. return null
  217. },
  218. // 页面的滚动事件
  219. onPageScroll(e){
  220. let mescroll = this.getMescroll(this.tabIndex);
  221. let that=this;
  222. if(Math.ceil(e.scrollTop)<69){
  223. mescroll.scrollTo(Math.ceil(e.scrollTop)-69,0);
  224. if(Math.ceil(e.scrollTop)>=44 && Math.ceil(e.scrollTop)<=69){
  225. }
  226. that.disableScroll = Math.ceil(e.scrollTop) < 69;
  227. setTimeout(function(){
  228. },200);
  229. if(mescroll.isScrollUp){ //向上滑动
  230. }
  231. }
  232. else{
  233. this.disableScroll = Math.ceil(e.scrollTop) < 69;
  234. mescroll.scrollTo(100,1);
  235. if(Math.ceil(e.scrollTop)>=44 && Math.ceil(e.scrollTop)<=69){
  236. }
  237. }
  238. console.log("qxj scrollTop:"+Math.ceil(e.scrollTop)+" isScrollUp:"+mescroll.isScrollUp+" disableScroll:"+this.disableScroll);
  239. },
  240. // 页面跳转
  241. navTo(url) {
  242. console.log("qxj url:"+url);
  243. uni.navigateTo({
  244. url: url
  245. })
  246. },
  247. goBack() {
  248. uni.navigateBack({
  249. delta:1,
  250. animationType: 'slide-out-right',
  251. animationDuration: 200
  252. });
  253. },
  254. }
  255. }
  256. </script>
  257. <style lang="scss" scoped>
  258. /*
  259. sticky生效条件:
  260. 1、父元素不能overflow:hidden或者overflow:auto属性。(mescroll-body设置:sticky="true"即可, mescroll-uni本身没有设置overflow)
  261. 2、必须指定top、bottom、left、right4个值之一,否则只会处于相对定位
  262. 3、父元素的高度不能低于sticky元素的高度
  263. 4、sticky元素仅在其父元素内生效,所以父元素必须是 mescroll
  264. */
  265. page{
  266. height: 100%;
  267. background-color: #fff;
  268. }
  269. .content{
  270. /* #ifdef APP-PLUS */
  271. flex: 1;
  272. /* #endif */
  273. /* #ifndef APP-PLUS */
  274. //display: flex;
  275. /* #endif */
  276. display: flex;
  277. flex-direction: column;
  278. width: 100%;
  279. min-height: 100%;
  280. flex: 1;
  281. position: relative;
  282. }
  283. .home_top_bg {
  284. width: 100%;
  285. height: auto;
  286. position: absolute;
  287. top: 0;
  288. left: 0;
  289. z-index: 0;
  290. }
  291. .sticky-tabs{
  292. z-index: 11;
  293. position: sticky;
  294. top: 44px;
  295. background-color: #fff;
  296. height: 80rpx;
  297. align-items: center;
  298. }
  299. .grace-page-header {
  300. width: 100%;
  301. position: fixed;
  302. left: 0;
  303. top: 0;
  304. z-index: 99;
  305. border-bottom: 0px solid #FFFFFF;
  306. .grace-page-status-bar {
  307. width: 100%;
  308. height: 0;
  309. }
  310. .grace-page-header-nav {
  311. width: 100%;
  312. display: flex;
  313. flex-direction: row;
  314. flex-wrap: nowrap;
  315. align-items: center;
  316. }
  317. .grace-header-main {
  318. width: 300rpx;
  319. flex: auto;
  320. overflow: hidden;
  321. margin:0 20rpx;
  322. height: 48rpx;
  323. text-align: center;
  324. font-weight: 500;
  325. font-size: 34rpx;
  326. color: #333;
  327. }
  328. }
  329. .u-nav-back{
  330. display: flex;
  331. align-items: center;
  332. position: absolute;
  333. left:20rpx;
  334. .img{
  335. height: 48upx;
  336. }
  337. }
  338. .cont-box{
  339. position: relative;
  340. .top-section{
  341. // background: #FF5C03;
  342. padding-bottom: 20rpx;
  343. .search-header-nav {
  344. width: 100%;
  345. display: flex;
  346. flex-direction: row;
  347. flex-wrap: nowrap;
  348. align-items: center;
  349. }
  350. .search-header-main {
  351. width: 300rpx;
  352. flex: auto;
  353. overflow: hidden;
  354. margin:0 20rpx;
  355. height: 48rpx;
  356. background: #fff;
  357. border-radius: 35rpx;
  358. padding: 10rpx 20upx;
  359. display: flex;
  360. justify-content: flex-start;
  361. align-items: center;
  362. image{
  363. width: 28upx;
  364. height: 28upx;
  365. margin-right: 16upx;
  366. }
  367. .input-text{
  368. color: #333;
  369. font-size: 24rpx;
  370. height: 48rpx;
  371. line-height:48rpx ;
  372. }
  373. .uni-input-placeholder{
  374. color:#999;
  375. }
  376. }
  377. }
  378. .inner.fixed{
  379. width: 100%;
  380. position: fixed;
  381. top: 0;
  382. left: 0;
  383. z-index: 999;
  384. }
  385. .seat{
  386. display: none;
  387. &.show{
  388. display: block;
  389. }
  390. }
  391. .status-bar.white-bg {
  392. background-color: #fff;
  393. }
  394. .top-title-box{
  395. height: 88rpx;
  396. line-height: 88rpx;
  397. text-align: center;
  398. background-color: #fff;
  399. font-size: 36rpx;
  400. font-weight: 420;
  401. color: #333333;
  402. color: red;
  403. display: none;
  404. &.show{
  405. display: block;
  406. }
  407. }
  408. }
  409. .myjt-box{
  410. margin:0 20rpx;
  411. border-radius: 20rpx;
  412. padding-right: 0rpx;
  413. background-color: #fff;
  414. .title-inner{
  415. margin-left: 20rpx;
  416. height: 70rpx;
  417. line-height: 70rpx;
  418. padding-top:20rpx;
  419. display: flex;
  420. justify-content: space-between;
  421. align-items: center;
  422. margin-right: 20rpx;
  423. font-size: 32rpx;
  424. font-weight: 500;
  425. .arrow-pro{
  426. height: 60rpx;
  427. display: flex;
  428. align-items: center;
  429. justify-content: space-between;
  430. .card{
  431. font-size: 26rpx;
  432. color: #999;
  433. }
  434. image{
  435. width: 20rpx;
  436. height: 20rpx;
  437. margin-right: 6rpx;
  438. }
  439. }
  440. }
  441. .collection-list{
  442. display: flex;
  443. flex-wrap: wrap;
  444. border-radius: 8rpx;
  445. margin: 0 16rpx;
  446. margin-top:20rpx;
  447. .item{
  448. display: flex;
  449. flex-direction: column;
  450. // align-items: center;
  451. justify-content: center;
  452. width: calc(100%);
  453. margin-bottom: 20rpx;
  454. .top{
  455. display: flex;
  456. flex: 1;
  457. flex-direction: row;
  458. .img-box{
  459. position: relative;
  460. width: 40%; /* 或者任何你想要的宽度 */
  461. padding-bottom: 25%; /* 高度等于宽度 */
  462. overflow: hidden; /* 防止图片溢出 */
  463. image{
  464. position: absolute;
  465. width: 100%;
  466. height: 100%;
  467. top: 50%;
  468. left: 50%;
  469. transform: translate(-50%, -50%);
  470. border-radius: 20rpx;
  471. }
  472. }
  473. .playIcon{
  474. position: absolute;
  475. width: 50rpx;
  476. height: 50rpx;
  477. background: rgba(0, 0, 0, 0.28);
  478. border-radius: 50%;
  479. top: 50%;
  480. left: 50%;
  481. transform: translate(-50%, -50%);
  482. image{
  483. width:20rpx ;
  484. height: 24rpx;
  485. border-radius: 0 !important;
  486. }
  487. }
  488. .vip{
  489. position: absolute;
  490. width: 49rpx;
  491. height: 28rpx;
  492. background: linear-gradient(94deg, #FFE9D0 0%, #E9BD97 100%);
  493. border-radius: 6rpx;
  494. top: 16rpx;
  495. right: 16rpx;
  496. color:#333;
  497. font-size:18rpx ;
  498. text-align: center;
  499. font-weight: 500;
  500. font-style: italic;
  501. }
  502. }
  503. .info-box{
  504. width: calc(60%);
  505. padding:0 20rpx;
  506. position: relative;
  507. .title{
  508. font-size: 26rpx;
  509. font-family: PingFang SC;
  510. font-weight: 470;
  511. color: #333;
  512. line-height: 40rpx;
  513. margin-top: 10rpx;
  514. }
  515. .tips,.time{
  516. font-size: 26rpx;
  517. color: #666;
  518. line-height: 40rpx;
  519. margin-top: 10rpx;
  520. }
  521. .time{
  522. position: absolute;
  523. left: 20rpx;
  524. bottom: 20rpx;
  525. }
  526. }
  527. .arrow{
  528. width: 30rpx;
  529. height: 100%;
  530. display: flex;
  531. align-items: center;
  532. justify-content: center;
  533. margin-right: 10rpx;
  534. image{
  535. width: 26rpx;
  536. height: 22rpx;
  537. }
  538. }
  539. }
  540. .progress-bar{
  541. border-radius: 20rpx;
  542. background: #ebebeb;
  543. height: 20rpx;
  544. margin:20rpx 0rpx;
  545. display: flex;
  546. flex-direction: row;
  547. align-items: center;
  548. .focus-bar{
  549. background:#FF5C03;
  550. border-radius: 20rpx;
  551. height: 100%;
  552. }
  553. .number{
  554. font-size: 22rpx;
  555. color: #fff;
  556. background:#FF5C03;
  557. border-radius: 10rpx;
  558. border-left: 2rpx solid #fff;
  559. padding: 0rpx 12rpx;
  560. margin-left: -2rpx;
  561. }
  562. }
  563. }
  564. }
  565. .scroll{
  566. width: 100%;
  567. flex: 1;
  568. display: flex;
  569. flex-direction: column;
  570. overflow: hidden;
  571. margin-top: 0rpx;
  572. }
  573. </style>