recharge.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="recharge">
  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 recharge"
  19. :key="index"
  20. class="recharge-item"
  21. >
  22. <view class="gold-box main-between cross-center">
  23. <view class="left-box main-left cross-center">
  24. <view class="gold">
  25. <text class="number">+{{ item.gold + item.gift }}</text>
  26. <text>金币</text>
  27. </view>
  28. <view class="gift">充{{ item.gold }}赠{{ item.gift }}</view>
  29. </view>
  30. <view class="right-box">
  31. <text class="number">{{ item.price }}</text>
  32. <text>元</text>
  33. </view>
  34. </view>
  35. <text class="time">{{ item.created_at }}</text>
  36. </view>
  37. </view>
  38. <!--时间选择-->
  39. <!-- <u-datetime-picker-->
  40. <!-- ref="datePicker"-->
  41. <!-- v-model="datePicker.value"-->
  42. <!-- :show="datePicker.show"-->
  43. <!-- mode="year-month"-->
  44. <!-- @confirm="handleDateConfirm"-->
  45. <!-- @cancel="datePicker.show = false"-->
  46. <!-- />-->
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. limit: 10,
  54. page: 1,
  55. isMore: true,
  56. recharge: [],
  57. datePicker: {
  58. date: uni.$u.timeFormat(Number(new Date()), 'yyyy-mm'),
  59. show: false
  60. }
  61. }
  62. },
  63. computed: {
  64. date() {
  65. const date = this.datePicker.date
  66. const arr = date.split('-')
  67. return `${arr[0]}年${arr[1]}月`
  68. }
  69. },
  70. methods: {
  71. handleDateConfirm({ detail }) {
  72. this.datePicker.date = detail.value
  73. this.datePicker.show = false
  74. this.isMore = true
  75. this.page = 1
  76. this.recharge = []
  77. this.getRecharge()
  78. },
  79. getRecharge() {
  80. this.$loading()
  81. this.$api.user.recharge.record({ date: this.datePicker.date, limit: this.limit, page: this.page }).then(res => {
  82. this.$hideLoading()
  83. if (res.data.length) {
  84. this.recharge = this.recharge.concat(res.data)
  85. } else {
  86. this.isMore = false
  87. }
  88. })
  89. }
  90. },
  91. onLoad() {
  92. this.getRecharge()
  93. },
  94. onReachBottom(e) {
  95. if (!this.isMore) return
  96. this.page += 1
  97. this.getConsume()
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .recharge {
  103. padding: 20rpx 20rpx;
  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. .recharge-item{
  119. border-bottom: 1rpx solid $info-color;
  120. color: $info-color;
  121. font-size: 26rpx;
  122. padding: 20rpx 0;
  123. &:last-child{
  124. border-bottom: none;
  125. }
  126. .gold-box{
  127. padding: 16rpx 0;
  128. .number{
  129. color: $primary-color;
  130. font-size: 38rpx;
  131. font-weight: 600;
  132. margin-right: 10rpx;
  133. }
  134. .gold .number{
  135. color: $default-color;
  136. }
  137. .left-box{
  138. .gift{
  139. color: $pink-color;
  140. margin-left: 40rpx;
  141. }
  142. }
  143. }
  144. text.time{
  145. font-size: 24rpx;
  146. }
  147. }
  148. }
  149. }
  150. </style>