recharge.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. }).catch(err => {
  89. this.$hideLoading()
  90. console.error('-->error', err)
  91. })
  92. }
  93. },
  94. onLoad() {
  95. this.getRecharge()
  96. },
  97. onReachBottom(e) {
  98. if (!this.isMore) return
  99. this.page += 1
  100. this.getConsume()
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .recharge {
  106. padding: 20rpx 20rpx;
  107. .header{
  108. color: $info-color;
  109. text{
  110. margin-right: 20rpx;
  111. font-size: 32rpx;
  112. }
  113. .icon{
  114. transition: .3s;
  115. &.rotate{
  116. transform: rotate(-180deg);
  117. }
  118. }
  119. }
  120. .content{
  121. .recharge-item{
  122. border-bottom: 1rpx solid $info-color;
  123. color: $info-color;
  124. font-size: 26rpx;
  125. padding: 20rpx 0;
  126. &:last-child{
  127. border-bottom: none;
  128. }
  129. .gold-box{
  130. padding: 16rpx 0;
  131. .number{
  132. color: $primary-color;
  133. font-size: 38rpx;
  134. font-weight: 600;
  135. margin-right: 10rpx;
  136. }
  137. .gold .number{
  138. color: $default-color;
  139. }
  140. .left-box{
  141. .gift{
  142. color: $pink-color;
  143. margin-left: 40rpx;
  144. }
  145. }
  146. }
  147. text.time{
  148. font-size: 24rpx;
  149. }
  150. }
  151. }
  152. }
  153. </style>