recharge.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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="handleDateConfirm"
  46. />
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. recharge: [],
  54. datePicker: {
  55. date: uni.$u.timeFormat(Number(new Date()), 'yyyy-mm'),
  56. show: false
  57. }
  58. }
  59. },
  60. computed: {
  61. date() {
  62. const date = this.datePicker.date
  63. const arr = date.split('-')
  64. return `${arr[0]}年${arr[1]}月`
  65. }
  66. },
  67. methods: {
  68. handleDateConfirm({ detail }) {
  69. this.datePicker.date = detail.value
  70. this.datePicker.show = false
  71. this.getRecharge()
  72. },
  73. getRecharge() {
  74. this.$loading()
  75. this.$api.user.recharge.record({ date: this.datePicker.date }).then(res => {
  76. this.$hideLoading()
  77. this.recharge = res.data
  78. })
  79. }
  80. },
  81. onLoad() {
  82. this.getRecharge()
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .recharge {
  88. padding: 20rpx 20rpx;
  89. .header{
  90. color: $info-color;
  91. text{
  92. margin-right: 20rpx;
  93. font-size: 32rpx;
  94. }
  95. .icon{
  96. transition: .3s;
  97. &.rotate{
  98. transform: rotate(-180deg);
  99. }
  100. }
  101. }
  102. .content{
  103. .recharge-item{
  104. border-bottom: 1rpx solid $info-color;
  105. color: $info-color;
  106. font-size: 26rpx;
  107. padding: 20rpx 0;
  108. &:last-child{
  109. border-bottom: none;
  110. }
  111. .gold-box{
  112. padding: 16rpx 0;
  113. .number{
  114. color: $primary-color;
  115. font-size: 38rpx;
  116. font-weight: 600;
  117. margin-right: 10rpx;
  118. }
  119. .gold .number{
  120. color: $default-color;
  121. }
  122. .left-box{
  123. .gift{
  124. color: $pink-color;
  125. margin-left: 40rpx;
  126. }
  127. }
  128. }
  129. text.time{
  130. font-size: 24rpx;
  131. }
  132. }
  133. }
  134. }
  135. </style>