famousHall.vue 15 KB

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