famousHall.vue 15 KB

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