consume.vue 4.0 KB

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