list.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="movieList">
  3. <view class="title">{{title}}</view>
  4. <view class="list" v-for="(item,index) in list" :key="index" @click="goToDetail(item)">
  5. <view class="list-left">
  6. <image :src="item.pic.normal" mode=""></image>
  7. </view>
  8. <view class="list-right">
  9. <view class="list-desc">
  10. <view class="list-title">
  11. <view class="tips">
  12. {{item.title}}
  13. </view>
  14. <van-rate color="#ffd21e" void-color='#c7c7c7' class="rate" :value="item.rating.star_count" />
  15. <text>{{item.rating.value}}</text>
  16. </view>
  17. <view class="list-icon">
  18. <image :src="imgUrl" mode=""></image>
  19. </view>
  20. </view>
  21. <view class="list-main">
  22. <Desc :val="item.recommend_comment"></Desc>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. Domestic,
  31. Variety,
  32. American
  33. } from '../../api/home.js';
  34. import Desc from '../../components/desc.vue';
  35. export default {
  36. onLoad(options) {
  37. this.ids = options.params;
  38. },
  39. onShow() {
  40. this.main()
  41. },
  42. data() {
  43. return {
  44. list: [],
  45. imgUrl: '/static/xiangkan.png',
  46. title: "",
  47. ids: "",
  48. interfaceName: '',
  49. startNum: 0,
  50. countNum: 8,
  51. totalNum: 0
  52. }
  53. },
  54. components: {
  55. Desc
  56. },
  57. methods: {
  58. main() {
  59. if (this.ids == 'tv_domestic') {
  60. this.interfaceName = Domestic;
  61. } else if (this.ids == "tv_american") {
  62. this.interfaceName = Variety;
  63. } else if (this.ids == 'tv_variety_show') {
  64. this.interfaceName = American;
  65. }
  66. this.init();
  67. },
  68. async init() {
  69. let res = await this.interfaceName({
  70. start: this.startNum,
  71. count: this.countNum
  72. });
  73. if (this.list.length) {
  74. this.list = this.list.concat(res.subject_collection_items)
  75. } else {
  76. this.list = res.subject_collection_items;
  77. }
  78. this.title = res.subject_collection.name;
  79. this.totalNum = res.total;
  80. },
  81. goToDetail(val) {
  82. console.log(val.id, 'val')
  83. uni.navigateTo({
  84. url:`/pages/detail/detail?ids=${val.id}`
  85. })
  86. }
  87. },
  88. onPullDownRefresh() {
  89. this.main();
  90. },
  91. onReachBottom() {
  92. console.log("走进来")
  93. if (this.startNum < this.totalNum) {
  94. this.startNum += 8;
  95. this.main();
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. .title {
  102. font-size: 24rpx;
  103. margin: 20rpx 0 30rpx 0;
  104. }
  105. .list {
  106. width: 96%;
  107. height: auto;
  108. margin: 0 auto;
  109. display: flex;
  110. padding: 30rpx 0 50rpx;
  111. border-bottom: 1px solid #eee;
  112. .list-left {
  113. flex: 2;
  114. image {
  115. width: 160rpx;
  116. height: 230rpx;
  117. border-radius: 8rpx;
  118. }
  119. }
  120. .list-right {
  121. flex: 8;
  122. display: flex;
  123. flex-direction: column;
  124. margin-left: 30rpx;
  125. .list-desc {
  126. flex: 1;
  127. display: flex;
  128. .list-title {
  129. flex: 4;
  130. border-right: 1px dashed #ccc;
  131. padding: 10rpx;
  132. .tips {
  133. font-size: 44rpx;
  134. }
  135. ::v-deep .van-rate__icon {
  136. font-size: 20rpx;
  137. }
  138. text {
  139. margin-left: 10rpx;
  140. color: #7d7d7d;
  141. }
  142. }
  143. .list-icon {
  144. flex: 1;
  145. display: flex;
  146. align-items: center;
  147. justify-content: center;
  148. image {
  149. width: 50rpx;
  150. height: 50rpx;
  151. }
  152. }
  153. }
  154. .list-main {
  155. flex: 2;
  156. font-size: 25rrpx;
  157. color: #7d7d7d;
  158. background: #f7f7f7;
  159. border-radius: 10rpx;
  160. padding: 10rpx;
  161. margin-top: 20rpx;
  162. }
  163. }
  164. }
  165. </style>