consume.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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.consume = []
  77. this.page = 1
  78. this.isMore = true
  79. this.getConsume()
  80. },
  81. getConsume() {
  82. this.$loading()
  83. this.$api.user.consume.record({ date: this.datePicker.date, limit: this.limit, page: this.page }).then(res => {
  84. this.$hideLoading()
  85. if (res.data.length) {
  86. this.consume = this.consume.concat(res.data)
  87. } else {
  88. this.isMore = false
  89. }
  90. })
  91. }
  92. },
  93. onLoad() {
  94. this.getConsume()
  95. },
  96. onReachBottom(e) {
  97. if (!this.isMore) return
  98. this.page += 1
  99. this.getConsume()
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .consume {
  105. padding: 20rpx 20rpx;
  106. font-size: 30rpx;
  107. .header{
  108. color: $info-color;
  109. text{
  110. margin-right: 20rpx;
  111. font-size: 32rpx;
  112. }
  113. .icon{
  114. transition: .3s;
  115. &.rotate{
  116. transform: rotate(-180deg);
  117. }
  118. }
  119. }
  120. .content{
  121. .consume-item{
  122. color: $info-color;
  123. margin-top: 20rpx;
  124. .cover-image{
  125. image{
  126. width: 200rpx;
  127. height: 260rpx;
  128. border-radius: 16rpx;
  129. }
  130. }
  131. .episode-box{
  132. flex: 1;
  133. margin-left: 20rpx;
  134. font-size: 26rpx;
  135. .name{
  136. color: $default-color;
  137. font-size: 38rpx;
  138. font-weight: 600;
  139. margin-bottom: 10rpx;
  140. }
  141. .status-box{
  142. margin-bottom: 50rpx;
  143. .status{
  144. color: $primary-color;
  145. margin-right: 14rpx;
  146. }
  147. }
  148. .detail{
  149. font-size: 32rpx;
  150. color: $default-color;
  151. margin-bottom: 10rpx;
  152. }
  153. }
  154. .gold{
  155. .number{
  156. color: $pink-color;
  157. font-size: 42rpx;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. </style>