famousHall.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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:"#2583EB",
  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. .content{
  263. /* #ifdef APP-PLUS */
  264. flex: 1;
  265. /* #endif */
  266. /* #ifndef APP-PLUS */
  267. //display: flex;
  268. /* #endif */
  269. display: flex;
  270. flex-direction: column;
  271. width: 100%;
  272. min-height: 100%;
  273. flex: 1;
  274. position: relative;
  275. }
  276. .home_top_bg {
  277. width: 100%;
  278. height: auto;
  279. position: absolute;
  280. top: 0;
  281. left: 0;
  282. z-index: 0;
  283. }
  284. .sticky-tabs{
  285. z-index: 11;
  286. position: sticky;
  287. top: 44px;
  288. background-color: #fff;
  289. height: 80rpx;
  290. align-items: center;
  291. }
  292. .grace-page-header {
  293. width: 100%;
  294. position: fixed;
  295. left: 0;
  296. top: 0;
  297. z-index: 99;
  298. border-bottom: 0px solid #FFFFFF;
  299. .grace-page-status-bar {
  300. width: 100%;
  301. height: 0;
  302. }
  303. .grace-page-header-nav {
  304. width: 100%;
  305. display: flex;
  306. flex-direction: row;
  307. flex-wrap: nowrap;
  308. align-items: center;
  309. }
  310. .grace-header-main {
  311. width: 300rpx;
  312. flex: auto;
  313. overflow: hidden;
  314. margin:0 20rpx;
  315. height: 48rpx;
  316. text-align: center;
  317. font-weight: 500;
  318. font-size: 34rpx;
  319. color: #333;
  320. }
  321. }
  322. .u-nav-back{
  323. display: flex;
  324. align-items: center;
  325. position: absolute;
  326. left:20rpx;
  327. .img{
  328. height: 48upx;
  329. }
  330. }
  331. .cont-box{
  332. position: relative;
  333. .top-section{
  334. // background: #2583EB;
  335. padding-bottom: 20rpx;
  336. .search-header-nav {
  337. width: 100%;
  338. display: flex;
  339. flex-direction: row;
  340. flex-wrap: nowrap;
  341. align-items: center;
  342. }
  343. .search-header-main {
  344. width: 300rpx;
  345. flex: auto;
  346. overflow: hidden;
  347. margin:0 20rpx;
  348. height: 48rpx;
  349. background: #fff;
  350. border-radius: 35rpx;
  351. padding: 10rpx 20upx;
  352. display: flex;
  353. justify-content: flex-start;
  354. align-items: center;
  355. image{
  356. flex-shrink: 0;
  357. width: 28upx;
  358. height: 28upx;
  359. margin-right: 16upx;
  360. }
  361. .input-text{
  362. flex: 1;
  363. color: #333;
  364. font-size: 24rpx;
  365. height: 48rpx;
  366. line-height:48rpx ;
  367. }
  368. .uni-input-placeholder{
  369. color:#999;
  370. }
  371. }
  372. }
  373. .inner.fixed{
  374. width: 100%;
  375. position: fixed;
  376. top: 0;
  377. left: 0;
  378. z-index: 999;
  379. }
  380. .seat{
  381. display: none;
  382. &.show{
  383. display: block;
  384. }
  385. }
  386. .status-bar.white-bg {
  387. background-color: #fff;
  388. }
  389. .top-title-box{
  390. height: 88rpx;
  391. line-height: 88rpx;
  392. text-align: center;
  393. background-color: #fff;
  394. font-size: 36rpx;
  395. font-weight: 420;
  396. color: #333333;
  397. color: red;
  398. display: none;
  399. &.show{
  400. display: block;
  401. }
  402. }
  403. }
  404. .myjt-box{
  405. margin:0 20rpx;
  406. border-radius: 20rpx;
  407. padding-right: 0rpx;
  408. background-color: #fff;
  409. .title-inner{
  410. margin-left: 20rpx;
  411. height: 70rpx;
  412. line-height: 70rpx;
  413. padding-top:20rpx;
  414. display: flex;
  415. justify-content: space-between;
  416. align-items: center;
  417. margin-right: 20rpx;
  418. font-size: 32rpx;
  419. font-weight: 500;
  420. .arrow-pro{
  421. height: 60rpx;
  422. display: flex;
  423. align-items: center;
  424. justify-content: space-between;
  425. .card{
  426. font-size: 26rpx;
  427. color: #999;
  428. }
  429. image{
  430. width: 20rpx;
  431. height: 20rpx;
  432. margin-right: 6rpx;
  433. }
  434. }
  435. }
  436. .collection-list{
  437. display: flex;
  438. flex-wrap: wrap;
  439. border-radius: 8rpx;
  440. margin: 0 16rpx;
  441. margin-top:20rpx;
  442. .item{
  443. display: flex;
  444. flex-direction: column;
  445. // align-items: center;
  446. justify-content: center;
  447. width: calc(100%);
  448. margin-bottom: 20rpx;
  449. .top{
  450. display: flex;
  451. flex: 1;
  452. flex-direction: row;
  453. .img-box{
  454. position: relative;
  455. width: 40%; /* 或者任何你想要的宽度 */
  456. padding-bottom: 25%; /* 高度等于宽度 */
  457. overflow: hidden; /* 防止图片溢出 */
  458. image{
  459. position: absolute;
  460. width: 100%;
  461. height: 100%;
  462. top: 50%;
  463. left: 50%;
  464. transform: translate(-50%, -50%);
  465. border-radius: 20rpx;
  466. }
  467. }
  468. .playIcon{
  469. position: absolute;
  470. width: 50rpx;
  471. height: 50rpx;
  472. background: rgba(0, 0, 0, 0.28);
  473. border-radius: 50%;
  474. top: 50%;
  475. left: 50%;
  476. transform: translate(-50%, -50%);
  477. image{
  478. width:20rpx ;
  479. height: 24rpx;
  480. border-radius: 0 !important;
  481. }
  482. }
  483. .vip{
  484. position: absolute;
  485. width: 49rpx;
  486. height: 28rpx;
  487. background: linear-gradient(94deg, #FFE9D0 0%, #E9BD97 100%);
  488. border-radius: 6rpx;
  489. top: 16rpx;
  490. right: 16rpx;
  491. color:#333;
  492. font-size:18rpx ;
  493. text-align: center;
  494. font-weight: 500;
  495. font-style: italic;
  496. }
  497. }
  498. .info-box{
  499. width: calc(60%);
  500. padding:0 20rpx;
  501. position: relative;
  502. .title{
  503. font-size: 26rpx;
  504. font-family: PingFang SC;
  505. font-weight: 470;
  506. color: #333;
  507. line-height: 40rpx;
  508. margin-top: 10rpx;
  509. }
  510. .tips,.time{
  511. font-size: 26rpx;
  512. color: #666;
  513. line-height: 40rpx;
  514. margin-top: 10rpx;
  515. }
  516. .time{
  517. position: absolute;
  518. left: 20rpx;
  519. bottom: 20rpx;
  520. }
  521. }
  522. .arrow{
  523. width: 30rpx;
  524. height: 100%;
  525. display: flex;
  526. align-items: center;
  527. justify-content: center;
  528. margin-right: 10rpx;
  529. image{
  530. width: 26rpx;
  531. height: 22rpx;
  532. }
  533. }
  534. }
  535. .progress-bar{
  536. border-radius: 20rpx;
  537. background: #ebebeb;
  538. height: 20rpx;
  539. margin:20rpx 0rpx;
  540. display: flex;
  541. flex-direction: row;
  542. align-items: center;
  543. .focus-bar{
  544. background:#2583EB;
  545. border-radius: 20rpx;
  546. height: 100%;
  547. }
  548. .number{
  549. font-size: 22rpx;
  550. color: #fff;
  551. background:#2583EB;
  552. border-radius: 10rpx;
  553. border-left: 2rpx solid #fff;
  554. padding: 0rpx 12rpx;
  555. margin-left: -2rpx;
  556. }
  557. }
  558. }
  559. }
  560. .scroll{
  561. width: 100%;
  562. flex: 1;
  563. display: flex;
  564. flex-direction: column;
  565. overflow: hidden;
  566. margin-top: 0rpx;
  567. }
  568. </style>