123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <template>
- <view class="episode-box">
- <view class="header-box main-between cross-center">
- <text class="title">{{ title }}</text>
- <view class="refresh main-left cross-center" @click="handleRefresh">
- <text>换一批</text>
- <view class="icon">
- <u-icon name="reload" size="32rpx" bold />
- </view>
- </view>
- </view>
- <view
- class="container dir-left-wrap"
- :class="{
- loading: loading,
- 'main-center':loading,
- 'cross-center': loading
- }"
- >
- <u-loading-icon :show="loading" vertical />
- <template v-if="episodes.length && !loading">
- <episode
- v-for="(episode,index) in episodes"
- :key="index"
- :episode="episode"
- :guess="episode.guess"
- :recent="episode.recent"
- :rank="episode.rank"
- :custom-style="{
- marginRight: ((index+1) % 3 !== 0 ? '20rpx' :''),
- }"
- />
- </template>
- </view>
- </view>
- </template>
- <script>
- import Episode from '../../../components/Episode/index'
- export default {
- name: 'EpisodeBox',
- components: { Episode },
- props: {
- title: {
- type: String,
- required: true
- },
- type: {
- type: String,
- required: true
- }
- },
- data() {
- return {
- loading: false,
- episodes: []
- }
- },
- computed: {},
- created() {
- this.handleRefresh()
- },
- methods: {
- getRecommend() {
- this.loading = true
- this.$api.episode.recommend().then(res => {
- this.loading = false
- this.episodes = res.data
- })
- },
- getTodayRecommend() {
- this.loading = true
- this.$api.episode.todayRecommend().then(res => {
- this.loading = false
- this.episodes = res.data
- })
- },
- getNews() {
- this.loading = true
- this.$api.episode.news().then(res => {
- this.loading = false
- this.episodes = res.data
- })
- },
- getRank() {
- this.loading = true
- this.$api.episode.rank().then(res => {
- this.loading = false
- this.episodes = res.data
- })
- },
- handleRefresh() {
- this.type === 'recommend' && this.getRecommend()
- this.type === 'todayRecommend' && this.getTodayRecommend()
- this.type === 'news' && this.getNews()
- this.type === 'rank' && this.getRank()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .episode-box {
- margin-top: 30rpx;
- .header-box{
- .title{
- font-size: 32rpx;
- color: #ffffff;
- }
- .refresh{
- text{
- color: $info-color;
- font-size: 24rpx;
- line-height: 22rpx;
- margin-right: 4rpx;
- }
- }
- }
- .container{
- margin-top: 30rpx;
- min-height: 458rpx;
- &.loading{
- }
- }
- }
- </style>
|