index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="container">
  3. <check-login />
  4. <template v-if="isLogin">
  5. <!--search-->
  6. <view class="search-box main-center cross-center">
  7. <u-input
  8. v-model="keywords"
  9. placeholder="请输入剧名"
  10. color="#fff"
  11. border="none"
  12. prefix-icon="search"
  13. :prefix-icon-style="{
  14. color: $colors.primaryColor,
  15. fontSize: '50rpx',
  16. fontWeight: 500,
  17. lineHeight: '50rpx'
  18. }"
  19. :custom-style="{
  20. backgroundColor: '#1B203C',
  21. padding: '14rpx 30rpx',
  22. width: '700rpx',
  23. borderRadius: '36rpx',
  24. color: '#fff'
  25. }"
  26. @confirm="handleSearch"
  27. />
  28. </view>
  29. <!--swpier-->
  30. <swiper-box />
  31. <!--栏目分类-->
  32. <nav-bar />
  33. <!--分类-->
  34. <episode-box
  35. v-for="(item,index) in homeColumn"
  36. :key="index"
  37. :title="item.name"
  38. :type="item.type"
  39. />
  40. <!--tab bar-->
  41. <tab-bar />
  42. <!--最近播放-->
  43. <recent />
  44. </template>
  45. </view>
  46. </template>
  47. <script>
  48. import SwiperBox from '../../components/SwiperBox/index'
  49. import EpisodeBox from './components/EpisodeBox'
  50. import TabBar from '../../components/TabBar/index'
  51. import NavBar from '../../components/NavBar/index'
  52. import Recent from './components/Recent'
  53. import CheckLogin from '../../components/CheckLogin/index'
  54. export default {
  55. components: { CheckLogin, Recent, NavBar, TabBar, EpisodeBox, SwiperBox },
  56. data() {
  57. return {
  58. keywords: '',
  59. homeColumnType: {
  60. 1: 'recommend',
  61. 2: 'todayRecommend',
  62. 3: 'news',
  63. 4: 'rank'
  64. },
  65. homeColumn: []
  66. }
  67. },
  68. computed: {
  69. isLogin() {
  70. return this.$api.user.isLogin()
  71. }
  72. },
  73. onLoad(options) {
  74. this.isLogin && this.getHomeColumn()
  75. },
  76. methods: {
  77. handleSearch() {
  78. if (!this.keywords) {
  79. this.$u.toast('请输入剧集名称')
  80. return
  81. }
  82. this.$u.route({
  83. url: '/pages/index/search',
  84. params: {
  85. keywords: this.keywords
  86. }
  87. })
  88. },
  89. getHomeColumn() {
  90. this.$api.setting.homeColumn().then(res => {
  91. this.homeColumn = res.data
  92. this.homeColumn.forEach(obj => {
  93. obj.type = this.homeColumnType[obj.type]
  94. })
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .container{
  102. padding: 0 20rpx 160px;
  103. .search-box{
  104. margin-top: 30rpx;
  105. }
  106. .category-box{
  107. .category-item{
  108. flex: 1;
  109. font-size: 32rpx;
  110. .icon{
  111. image{
  112. width: 100rpx;
  113. height: 100rpx;
  114. }
  115. }
  116. text{
  117. color: #fff;
  118. }
  119. }
  120. }
  121. }
  122. </style>