consume.vue 3.8 KB

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