recharge.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="recharge">
  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 recharge"
  12. :key="index"
  13. class="recharge-item"
  14. >
  15. <view class="gold-box main-between cross-center">
  16. <view class="left-box main-left cross-center">
  17. <view class="gold">
  18. <text class="number">+{{ item.gold + item.gift }}</text>
  19. <text>金币</text>
  20. </view>
  21. <view class="gift">充{{ item.gold }}赠{{ item.gift }}</view>
  22. </view>
  23. <view class="right-box">
  24. <text class="number">{{ item.price }}</text>
  25. <text>元</text>
  26. </view>
  27. </view>
  28. <text class="time">{{ item.created_at }}</text>
  29. </view>
  30. </view>
  31. <!--时间选择-->
  32. <u-datetime-picker
  33. ref="datePicker"
  34. v-model="datePicker.value"
  35. :show="datePicker.show"
  36. mode="year-month"
  37. @confirm="handleDateConfirm"
  38. @cancel="handleDateConfirm"
  39. />
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. recharge: [],
  47. datePicker: {
  48. value: (new Date()).getTime(),
  49. date: uni.$u.timeFormat((new Date()).getTime(), 'yyyy-mm'),
  50. show: false
  51. }
  52. }
  53. },
  54. computed: {
  55. date() {
  56. const date = this.datePicker.date
  57. const arr = date.split('-')
  58. return `${arr[0]}年${arr[1]}月`
  59. }
  60. },
  61. watch: {
  62. datePicker: {
  63. handler(date) {
  64. date.date = uni.$u.timeFormat(date.value, 'yyyy-mm')
  65. },
  66. deep: true,
  67. immediate: true
  68. }
  69. },
  70. methods: {
  71. handleDateConfirm() {
  72. this.datePicker.show = false
  73. this.getRecharge()
  74. },
  75. getRecharge() {
  76. this.$loading()
  77. this.$api.user.recharge.record({ date: this.datePicker.date }).then(res => {
  78. this.$hideLoading()
  79. this.recharge = res.data
  80. })
  81. }
  82. },
  83. onLoad() {
  84. this.getRecharge()
  85. }
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. .recharge {
  90. padding: 20rpx 20rpx;
  91. .header{
  92. color: $info-color;
  93. text{
  94. margin-right: 20rpx;
  95. font-size: 32rpx;
  96. }
  97. .icon{
  98. transition: .3s;
  99. &.rotate{
  100. transform: rotate(-180deg);
  101. }
  102. }
  103. }
  104. .content{
  105. .recharge-item{
  106. border-bottom: 1rpx solid $info-color;
  107. color: $info-color;
  108. font-size: 26rpx;
  109. padding: 20rpx 0;
  110. &:last-child{
  111. border-bottom: none;
  112. }
  113. .gold-box{
  114. padding: 16rpx 0;
  115. .number{
  116. color: $primary-color;
  117. font-size: 38rpx;
  118. font-weight: 600;
  119. margin-right: 10rpx;
  120. }
  121. .gold .number{
  122. color: $default-color;
  123. }
  124. .left-box{
  125. .gift{
  126. color: $pink-color;
  127. margin-left: 40rpx;
  128. }
  129. }
  130. }
  131. text.time{
  132. font-size: 24rpx;
  133. }
  134. }
  135. }
  136. }
  137. </style>