index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. <template>
  2. <view class="entertainment-page">
  3. <image class="home_top_bg" src="@/static/images/enter/entertainment_top_bg.png" mode="widthFix"></image>
  4. <!-- 状态栏占位 -->
  5. <view class="status-bar" :style="{ height: statusBarHeight + 'px' }"></view>
  6. <!-- 顶部导航栏 -->
  7. <u-navbar :bgColor="bgColor" leftIconColor="#FFFFFF" title="娱乐模式" :autoBack="true"> </u-navbar>
  8. <!-- <view class="nav-bar" :style="{background:bgColor,paddingTop: statusBarHeight+'px'}">
  9. <view class="nav-title">娱乐模式</view>
  10. </view> -->
  11. <!-- 页面内容 -->
  12. <scroll-view class="page-content" scroll-y :style="'height:' + clientHeight + 'px;'"
  13. @scrolltolower="reachBottom">
  14. <!-- 主横幅 -->
  15. <view class="banner-section">
  16. <swiper class="banner-swiper" circular :indicator-dots="true" :autoplay="true" :interval="3000"
  17. :duration="1000" indicator-color="rgba(255,255,255,0.5)" indicator-active-color="#fff">
  18. <swiper-item v-for="(url,index) in advImgs" :key="index" class="swiper-item"
  19. @click="handleAdvClick(index)">
  20. <image style="width: 100%;height: 100%;" :src="url" mode="aspectFill"></image>
  21. </swiper-item>
  22. </swiper>
  23. </view>
  24. <image v-if="activityShow" @tap="$navTo('/pages_enter/activity/index')" class="img_enter_dance"
  25. src="/static/images/enter/activity/img_enter_dance.png" mode="">
  26. </image>
  27. <!-- 娱乐专区 -->
  28. <view class="entertainment-zone">
  29. <view class="section-title">
  30. <image class="w276 h52" src="@/static/images/enter/entertainment_zone_title.png"></image>
  31. </view>
  32. <!-- 前两张图一行并排 -->
  33. <view class="zone-grid">
  34. <view class="zone-item " v-for="(item, index) in zoneList.slice(0, 2)" :key="index"
  35. @click="handleZoneClick(item)">
  36. <view class="zone-card">
  37. <image :src="item.icon" mode="widthFix"></image>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- 后面三张图一行并排 -->
  42. <view class="zone-grid">
  43. <view class="zone-item" v-for="(item, index) in zoneList.slice(2)" :key="index + 2"
  44. :class="[index==0?'es-mr-10':'']" @click="handleZoneClick(item)">
  45. <view class="zone-card">
  46. <image :src="item.icon" mode="widthFix"></image>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 精彩推荐 -->
  52. <view class="recommend-section">
  53. <view class="section-title">
  54. <image class="w276 h52" src="@/static/images/enter/featured_recommendations_title.png"></image>
  55. </view>
  56. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  57. :down="downOption" :up="upOption">
  58. <view class="recommend-grid">
  59. <view class="recommend-item" v-for="(item, index) in recommendList" :key="index"
  60. @click="handleRecommendClick(item)">
  61. <view class="recommend-card">
  62. <image class="recommend-image" :src="item.image" mode="aspectFill"></image>
  63. <view class="recommend-info">
  64. <view class="recommend-stats">
  65. <text class="play-count">{{ item.playCount }}次播放</text>
  66. <text class="episode-count">共{{ item.episodeCount }}讲</text>
  67. </view>
  68. <view class="recommend-title">{{ item.title }}</view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- <u-loadmore :status="status" marginTop="30"></u-loadmore> -->
  74. </mescroll-body>
  75. </view>
  76. <!-- 底部安全区域 -->
  77. <view class="safe-area-bottom" style="height: 100rpx;"></view>
  78. </scroll-view>
  79. </view>
  80. </template>
  81. <script>
  82. import {
  83. getActivityInfo
  84. } from '@/api/activity.js';
  85. import {
  86. getAdvList
  87. } from '@/api/adv.js'
  88. import {
  89. getCourseList
  90. } from '@/api/course'
  91. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  92. export default {
  93. mixins: [MescrollMixin],
  94. data() {
  95. return {
  96. top: 0,
  97. clientHeight: 0,
  98. statusBarHeight: 0,
  99. safeAreaBottom: 0,
  100. currentNavIndex: 2, // 娱乐页面为当前激活
  101. advImgs: [],
  102. zoneList: [{
  103. id: 1,
  104. name: '小游戏',
  105. url: '/pages_enter/games',
  106. icon: '/static/images/enter/mini_game_img.png',
  107. }, {
  108. id: 3,
  109. name: '戏曲评书',
  110. url: '/pages_enter/program?cateId=4',
  111. icon: '/static/images/enter/opera_img.png',
  112. }, {
  113. id: 5,
  114. name: '节目',
  115. // url: '/pages_enter/program',
  116. url: '/pages_enter/program?cateId=1',
  117. icon: '/static/images/enter/program_img2.png',
  118. },
  119. {
  120. id: 2,
  121. name: '热播剧',
  122. url: '/pages_enter/program?cateId=3',
  123. icon: '/static/images/enter/hit_drama_img.png',
  124. },
  125. {
  126. id: 4,
  127. name: '运动',
  128. // url: '/pages_enter/sports',
  129. url: '/pages_enter/program?cateId=2',
  130. icon: '/static/images/enter/sports_img.png',
  131. },
  132. // {
  133. // id: 2,
  134. // name: '短剧',
  135. // url:'/pages_enter/program?cateId=4',
  136. // // url:'/pages_enter/drama',
  137. // icon: '/static/images/enter/short_play_img.png',
  138. // },
  139. // {
  140. // id: 3,
  141. // name: '小说',
  142. // // url:'/pages_enter/novel',
  143. // url:'/pages_enter/program?cateId=3',
  144. // icon: '/static/images/enter/novel_img.png',
  145. // },
  146. ],
  147. recommendList: [],
  148. statusBarHeight: '',
  149. pageNum: 1,
  150. pageSize: 10,
  151. totalPage: 1,
  152. status: 'loadmore',
  153. downOption: { //下拉刷新
  154. use: true,
  155. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  156. },
  157. upOption: {
  158. onScroll: false,
  159. use: true, // 是否启用上拉加载; 默认true
  160. page: {
  161. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  162. size: 10 // 每页数据的数量,默认10
  163. },
  164. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  165. textNoMore: "已经到底了",
  166. empty: {
  167. icon: 'https://zkzh-2025.oss-cn-beijing.aliyuncs.com/appimgs/cf4a86b913a04341bb44e34bb4d37aa2.png',
  168. tip: '暂无数据'
  169. }
  170. },
  171. bgColor: 'transparent',
  172. activityShow: false,
  173. }
  174. },
  175. onPageScroll(e) {
  176. this.top = e.scrollTop;
  177. if (e.scrollTop > 30) {
  178. this.bgColor = '#F4FFF2'
  179. } else {
  180. this.bgColor = 'transparent'
  181. }
  182. },
  183. onLoad() {
  184. const systemInfo = uni.getSystemInfoSync();
  185. this.statusBarHeight = systemInfo.statusBarHeight;
  186. this.getAdvList();
  187. this.getSystemInfo();
  188. this.getActivityInfoFun();
  189. },
  190. onShow() {
  191. uni.showTabBar();
  192. },
  193. // computed: {
  194. // // 计算属性的 getter
  195. // bgColor: function() {
  196. // var top = this.top / 30;
  197. // return 'rgba(239, 254, 248,' + top + ')';
  198. // },
  199. // },
  200. onReady() {
  201. uni.getSystemInfo({
  202. success: (res) => {
  203. this.clientHeight = res.windowHeight - uni.upx2px(120) - res.statusBarHeight;
  204. }
  205. })
  206. },
  207. methods: {
  208. async getActivityInfoFun() {
  209. const res = await getActivityInfo({
  210. activityId: getApp().globalData.activityId
  211. })
  212. if (res.code == 200 && res.data) {
  213. this.activityShow = res.data.status == 1 ? true : false
  214. getApp().globalData.miniprogamId = res.data.id
  215. this.activityShow = true
  216. }
  217. },
  218. getAdvList() {
  219. let that = this;
  220. let data = {
  221. advType: 12,
  222. status: 1
  223. }
  224. getAdvList(data).then(res => {
  225. if (res.code == 200) {
  226. that.advImgs = [];
  227. that.advs = [];
  228. res.data.forEach(function(element) {
  229. if (element.imageUrl != null && element.imageUrl != "") {
  230. that.advs.push(element);
  231. that.advImgs.push(element.imageUrl);
  232. }
  233. });
  234. } else {
  235. uni.showToast({
  236. icon: 'none',
  237. title: "请求失败"
  238. });
  239. }
  240. });
  241. },
  242. getSystemInfo() {
  243. const systemInfo = uni.getSystemInfoSync();
  244. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  245. // 计算底部安全区域高度
  246. if (systemInfo.safeArea) {
  247. this.safeAreaBottom = systemInfo.screenHeight - systemInfo.safeArea.bottom;
  248. }
  249. },
  250. handlePrizeCollection() {
  251. uni.showToast({
  252. title: '有奖征集',
  253. icon: 'none'
  254. });
  255. },
  256. handleZoneClick(item) {
  257. if (item.url) {
  258. uni.navigateTo({
  259. url: item.url
  260. });
  261. } else {
  262. uni.showToast({
  263. title: '正在开发中...',
  264. icon: 'none'
  265. });
  266. }
  267. },
  268. mescrollInit(mescroll) {
  269. this.mescroll = mescroll;
  270. },
  271. /*下拉刷新的回调 */
  272. downCallback(mescroll) {
  273. mescroll.resetUpScroll()
  274. },
  275. upCallback(page) {
  276. let params = {
  277. isTui: 1,
  278. // isBest: 1,
  279. pageNum: page.num,
  280. pageSize: page.size,
  281. limit: page.size
  282. };
  283. let that = this;
  284. getCourseList(params).then(res => {
  285. if (res.code === 200) {
  286. let list = res.data.list.map(item => ({
  287. id: item.courseId,
  288. title: item.courseName,
  289. playCount: item.views,
  290. episodeCount: item.sectionCount || 0,
  291. image: item.imgUrl
  292. }));
  293. if (page.num == 1) {
  294. that.recommendList = list
  295. } else {
  296. that.recommendList = that.recommendList.concat(list);
  297. }
  298. that.mescroll.endBySize(res.data.list.length, res.data.total);
  299. }
  300. })
  301. },
  302. handleRecommendClick(item) {
  303. uni.navigateTo({
  304. url: `/pages/course/info?courseId=${item.id}`
  305. });
  306. },
  307. handleNavClick(item, index) {
  308. if (this.currentNavIndex === index) {
  309. return;
  310. }
  311. this.currentNavIndex = index;
  312. if (item.path && item.path !== '/pages_enter/index') {
  313. uni.switchTab({
  314. url: item.path
  315. });
  316. }
  317. }
  318. }
  319. }
  320. </script>
  321. <style lang="scss" scoped>
  322. .entertainment-page {
  323. width: 100%;
  324. min-height: 100vh;
  325. background-color: #fff !important;
  326. display: flex;
  327. flex-direction: column;
  328. position: relative;
  329. z-index: 2;
  330. }
  331. .home_top_bg {
  332. width: 100%;
  333. height: auto;
  334. position: absolute;
  335. top: 0;
  336. left: 0;
  337. z-index: 0;
  338. }
  339. .status-bar {
  340. width: 100%;
  341. }
  342. .nav-bar {
  343. width: 100%;
  344. height: 88rpx;
  345. //background-color: #ffffff;
  346. display: flex;
  347. align-items: center;
  348. justify-content: center;
  349. position: fixed;
  350. top: 0;
  351. left: 0;
  352. z-index: 1000;
  353. .nav-title {
  354. font-family: PingFang SC, PingFang SC;
  355. font-weight: 600;
  356. font-size: 40rpx;
  357. color: #222222;
  358. }
  359. }
  360. .page-content {
  361. flex: 1;
  362. width: 100%;
  363. }
  364. // 主横幅
  365. .banner-section {
  366. width: 100%;
  367. height: 280rpx;
  368. margin-top: 108rpx;
  369. padding: 0 30rpx;
  370. .banner-swiper {
  371. width: 100%;
  372. height: 100%;
  373. border-radius: 24rpx;
  374. overflow: hidden;
  375. }
  376. .banner-item {
  377. width: 100%;
  378. height: 100%;
  379. background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 50%, #7d3c98 100%);
  380. position: relative;
  381. display: flex;
  382. align-items: center;
  383. justify-content: center;
  384. overflow: hidden;
  385. &::before {
  386. content: '';
  387. position: absolute;
  388. top: -50%;
  389. left: -50%;
  390. width: 200%;
  391. height: 200%;
  392. background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  393. background-size: 30rpx 30rpx;
  394. animation: sparkle 3s linear infinite;
  395. }
  396. }
  397. @keyframes sparkle {
  398. 0% {
  399. transform: rotate(0deg);
  400. }
  401. 100% {
  402. transform: rotate(360deg);
  403. }
  404. }
  405. .banner-content {
  406. display: flex;
  407. flex-direction: column;
  408. align-items: center;
  409. justify-content: center;
  410. position: relative;
  411. z-index: 2;
  412. }
  413. .banner-title {
  414. font-size: 56rpx;
  415. font-weight: bold;
  416. color: #ffffff;
  417. margin-bottom: 40rpx;
  418. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.2);
  419. }
  420. .banner-btn {
  421. background-color: #ff6b9d;
  422. color: #ffffff;
  423. padding: 20rpx 60rpx;
  424. border-radius: 50rpx;
  425. font-size: 28rpx;
  426. font-weight: 500;
  427. }
  428. }
  429. // 娱乐专区
  430. .entertainment-zone {
  431. width: 100%;
  432. padding: 40rpx 30rpx;
  433. .section-title {
  434. display: flex;
  435. align-items: center;
  436. justify-content: center;
  437. margin-bottom: 40rpx;
  438. .sparkle-icon {
  439. font-size: 32rpx;
  440. margin: 0 10rpx;
  441. }
  442. .title-text {
  443. font-size: 36rpx;
  444. font-weight: 600;
  445. color: #333333;
  446. }
  447. }
  448. .zone-grid {
  449. display: flex;
  450. margin-bottom: 20rpx;
  451. margin-top: 80rpx;
  452. &:last-child {
  453. margin-bottom: 0;
  454. margin-top: 0;
  455. }
  456. }
  457. .zone-item {
  458. flex: 1
  459. }
  460. .zone-card {
  461. width: 100%;
  462. display: flex;
  463. align-items: center;
  464. image {
  465. width: 100%;
  466. }
  467. }
  468. .zone-icon-wrapper {
  469. width: 100rpx;
  470. height: 100rpx;
  471. display: flex;
  472. align-items: center;
  473. justify-content: center;
  474. margin-right: 20rpx;
  475. .zone-icon {
  476. font-size: 60rpx;
  477. }
  478. }
  479. .zone-info {
  480. flex: 1;
  481. display: flex;
  482. flex-direction: column;
  483. justify-content: center;
  484. }
  485. .zone-name {
  486. font-size: 32rpx;
  487. font-weight: 600;
  488. color: #ffffff;
  489. margin-bottom: 10rpx;
  490. display: flex;
  491. align-items: center;
  492. .badge {
  493. width: 32rpx;
  494. height: 32rpx;
  495. background-color: #ff4757;
  496. border-radius: 50%;
  497. display: flex;
  498. align-items: center;
  499. justify-content: center;
  500. font-size: 20rpx;
  501. color: #ffffff;
  502. margin-left: 10rpx;
  503. }
  504. }
  505. .zone-desc {
  506. font-size: 24rpx;
  507. color: rgba(255, 255, 255, 0.9);
  508. }
  509. }
  510. // 精彩推荐
  511. .recommend-section {
  512. width: 100%;
  513. padding: 0rpx 30rpx;
  514. margin-bottom: 40rpx;
  515. .section-title {
  516. display: flex;
  517. align-items: center;
  518. justify-content: center;
  519. margin-bottom: 40rpx;
  520. .sparkle-icon {
  521. font-size: 32rpx;
  522. margin: 0 10rpx;
  523. }
  524. .title-text {
  525. font-size: 36rpx;
  526. font-weight: 600;
  527. color: #333333;
  528. }
  529. }
  530. .recommend-grid {
  531. display: flex;
  532. flex-wrap: wrap;
  533. justify-content: space-between;
  534. }
  535. .recommend-item {
  536. width: 332rpx;
  537. margin-bottom: 24rpx;
  538. }
  539. .recommend-card {
  540. width: 100%;
  541. background-color: #ffffff;
  542. // border-radius: 16rpx;
  543. overflow: hidden;
  544. }
  545. .recommend-image {
  546. width: 100%;
  547. height: 208rpx;
  548. border-radius: 16rpx 16rpx 16rpx 16rpx;
  549. background-color: #f0f0f0;
  550. }
  551. .recommend-info {
  552. padding: 20rpx;
  553. }
  554. .recommend-title {
  555. font-size: 28rpx;
  556. font-weight: 500;
  557. color: #333333;
  558. margin-bottom: 12rpx;
  559. overflow: hidden;
  560. text-overflow: ellipsis;
  561. white-space: nowrap;
  562. }
  563. .recommend-stats {
  564. display: flex;
  565. align-items: center;
  566. justify-content: space-between;
  567. font-size: 22rpx;
  568. color: #999999;
  569. .play-count {
  570. margin-right: 10rpx;
  571. }
  572. }
  573. }
  574. .safe-area-bottom {
  575. width: 100%;
  576. }
  577. // 底部导航栏
  578. .bottom-nav {
  579. width: 100%;
  580. height: 100rpx;
  581. background-color: #ffffff;
  582. display: flex;
  583. align-items: center;
  584. justify-content: space-around;
  585. border-top: 1rpx solid #f0f0f0;
  586. padding-bottom: env(safe-area-inset-bottom);
  587. .nav-item {
  588. flex: 1;
  589. display: flex;
  590. flex-direction: column;
  591. align-items: center;
  592. justify-content: center;
  593. padding: 10rpx 0;
  594. }
  595. .nav-icon-wrapper {
  596. width: 48rpx;
  597. height: 48rpx;
  598. display: flex;
  599. align-items: center;
  600. justify-content: center;
  601. margin-bottom: 6rpx;
  602. .nav-icon {
  603. font-size: 40rpx;
  604. line-height: 1;
  605. }
  606. }
  607. .nav-label {
  608. font-size: 22rpx;
  609. color: #999999;
  610. &.active {
  611. color: #2583EB;
  612. font-weight: 500;
  613. }
  614. }
  615. }
  616. .img_enter_dance {
  617. margin: 24rpx 24rpx 0;
  618. height: 156rpx;
  619. width: calc(100vw - 48rpx);
  620. }
  621. </style>