consume.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="consume">
  3. <view class="header main-left cross-center" @click="datePicker.show = true">
  4. <picker
  5. mode="date"
  6. fields="month"
  7. :value="date"
  8. @change="handleDateConfirm"
  9. >
  10. <text>{{ date }}</text>
  11. </picker>
  12. <view class="icon" :class="{rotate: datePicker.show}">
  13. <u-icon name="arrow-down" />
  14. </view>
  15. </view>
  16. <view class="content">
  17. <view
  18. v-for="(item,index) in consume"
  19. :key="index"
  20. class="consume-item dir-left-nowrap cross-center"
  21. >
  22. <view class="cover-image">
  23. <image :src="item.detail.episode.cover_img" />
  24. </view>
  25. <view class="episode-box dir-top-wrap ">
  26. <view class="name">{{ item.detail.episode.name }}</view>
  27. <view class="status-box main-left cross-center">
  28. <text class="status">{{ item.detail.episode.status_text }}</text>
  29. <text>共{{ item.detail.episode.total }}集</text>
  30. </view>
  31. <view class="detail">{{ item.detail.sort }}集</view>
  32. <text class="time">{{ item.created_at }}</text>
  33. </view>
  34. <view class="gold">
  35. <text class="number">-{{ item.price }}</text>
  36. <text>金币</text>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. limit: 10,
  47. page: 1,
  48. isMore: true,
  49. consume: [],
  50. datePicker: {
  51. date: uni.$u.timeFormat(Number(new Date()), 'yyyy-mm'),
  52. show: false
  53. }
  54. }
  55. },
  56. computed: {
  57. date() {
  58. const date = this.datePicker.date
  59. const arr = date.split('-')
  60. return `${arr[0]}年${arr[1]}月`
  61. }
  62. },
  63. methods: {
  64. handlePlay(detail) {
  65. this.$u.route({
  66. url: '/pages/episode/play',
  67. params: {
  68. id: detail.episode.id,
  69. list_id: detail.id
  70. }
  71. })
  72. },
  73. handleDateConfirm({ detail }) {
  74. this.datePicker.date = detail.value
  75. this.datePicker.show = false
  76. this.getConsume()
  77. },
  78. getConsume() {
  79. this.$loading()
  80. this.$api.user.consume.record({ date: this.datePicker.date, limit: this.limit, page: this.page }).then(res => {
  81. this.$hideLoading()
  82. if (res.data.length) {
  83. this.consume = this.consume.concat(res.data)
  84. } else {
  85. this.isMore = false
  86. }
  87. })
  88. }
  89. },
  90. onLoad() {
  91. this.getConsume()
  92. },
  93. onReachBottom(e) {
  94. if (!this.isMore) return
  95. this.page += 1
  96. this.getConsume()
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .consume {
  102. padding: 20rpx 20rpx;
  103. font-size: 30rpx;
  104. .header{
  105. color: $info-color;
  106. text{
  107. margin-right: 20rpx;
  108. font-size: 32rpx;
  109. }
  110. .icon{
  111. transition: .3s;
  112. &.rotate{
  113. transform: rotate(-180deg);
  114. }
  115. }
  116. }
  117. .content{
  118. .consume-item{
  119. color: $info-color;
  120. margin-top: 20rpx;
  121. .cover-image{
  122. image{
  123. width: 200rpx;
  124. height: 260rpx;
  125. border-radius: 16rpx;
  126. }
  127. }
  128. .episode-box{
  129. flex: 1;
  130. margin-left: 20rpx;
  131. font-size: 26rpx;
  132. .name{
  133. color: $default-color;
  134. font-size: 38rpx;
  135. font-weight: 600;
  136. margin-bottom: 10rpx;
  137. }
  138. .status-box{
  139. margin-bottom: 50rpx;
  140. .status{
  141. color: $primary-color;
  142. margin-right: 14rpx;
  143. }
  144. }
  145. .detail{
  146. font-size: 32rpx;
  147. color: $default-color;
  148. margin-bottom: 10rpx;
  149. }
  150. }
  151. .gold{
  152. .number{
  153. color: $pink-color;
  154. font-size: 42rpx;
  155. }
  156. }
  157. }
  158. }
  159. }
  160. </style>