balance.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="balance">
  3. <view class="balance-top">
  4. <view class="balance-top-bg center">
  5. <text>{{ balancePrice }}</text>
  6. <text>余额</text>
  7. </view>
  8. <view class="xian flex" style="justify-content: center;"></view>
  9. </view>
  10. <view class="main">
  11. <view class="main-top flexs">
  12. <view class="main-item center" v-for="(item, index) in 2" :key="index" :class="{ active: index == i }" @click="changeMoney(index)">
  13. {{ index == 0 ? '收入' : '支出' }}
  14. </view>
  15. </view>
  16. <view class="main-list">
  17. <view class="main-list-item flex" v-for="(item, index) in balanceList" :key="index">
  18. <view class="main-list-main">
  19. <view class="main-list-main-name">{{ item.type }}</view>
  20. <view class="main-list-main-time">时间:{{ item.create_time }}</view>
  21. </view>
  22. <view class="main-list-main-price" :class="{ blue: i == 1 }">{{ item.money }}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. i: 0, //
  33. page: 1, //页码
  34. pages: null, //总页数
  35. balanceList: [], //
  36. balancePrice: '' //余额详情
  37. };
  38. },
  39. methods: {
  40. //切换
  41. changeMoney(index) {
  42. this.i = index;
  43. this.page = 1;
  44. this.balanceList = [];
  45. this.loadData();
  46. },
  47. //
  48. loadData() {
  49. this.$api.myBalance({ page: this.page, type: this.i == 0 ? 'in' : 'out', msg: '数据加载中' }).then(res => {
  50. uni.stopPullDownRefresh();
  51. if (res.code === 1) {
  52. this.balancePrice = res.data.balance;
  53. this.pages = res.data.record.last_page;
  54. this.balanceList = this.page == 1 ? res.data.record.data : [...this.balanceList, ...res.data.record.data];
  55. }
  56. });
  57. },
  58. //卡密充值记录列表
  59. carpassList() {
  60. uni.navigateTo({
  61. url: '/pages/me/carpassList/carpassList'
  62. });
  63. }
  64. },
  65. onLoad() {
  66. this.loadData();
  67. },
  68. onPullDownRefresh() {
  69. this.page = 1;
  70. this.balanceList = [];
  71. this.getBalanceList();
  72. },
  73. onReachBottom() {
  74. if (this.page < this.pages) {
  75. this.page++;
  76. this.getBalanceList();
  77. }
  78. }
  79. };
  80. </script>
  81. <style lang="scss">
  82. .balance {
  83. padding: 0 30rpx;
  84. .balance-top {
  85. .balance-top-bg {
  86. height: 220rpx;
  87. margin-bottom: 30rpx;
  88. background: url(https://www.chaomangdao.com/image/yuebeijing@2x.png) no-repeat;
  89. background-size: cover;
  90. flex-direction: column;
  91. text {
  92. color: #ffffff;
  93. &:first-child {
  94. font-size: 60rpx;
  95. font-weight: bold;
  96. }
  97. &:last-child {
  98. font-size: 28rpx;
  99. margin-top: 30rpx;
  100. }
  101. }
  102. }
  103. .balance-top_li {
  104. width: 330rpx;
  105. height: 78rpx;
  106. margin-bottom: 20rpx;
  107. color: #ffffff;
  108. font-size: 30rpx;
  109. border-radius: 39rpx;
  110. &:first-child {
  111. background: -webkit-linear-gradient(60deg, #ffb0d0 0%, #ff67a4 100%);
  112. margin-right: 10rpx;
  113. }
  114. &:last-child {
  115. background: -webkit-linear-gradient(0deg, #89f7fe 0%, #66a6ff 100%);
  116. margin-left: 10rpx;
  117. }
  118. }
  119. }
  120. }
  121. .main-top {
  122. background: #ffffff;
  123. border-radius: 10rpx 10rpx 0rpx 0rpx;
  124. border-bottom: 2rpx solid #fafafa;
  125. .main-item {
  126. width: 50%;
  127. height: 80rpx;
  128. font-size: 30rpx;
  129. }
  130. .active {
  131. color: #fff;
  132. position: relative;
  133. font-weight: bold;
  134. background: -webkit-linear-gradient(0deg, #89f7fe 0%, #66a6ff 100%);
  135. &::after {
  136. position: absolute;
  137. content: '';
  138. bottom: 0;
  139. left: 50%;
  140. transform: translateX(-50%);
  141. width: 40rpx;
  142. height: 4rpx;
  143. background: #89f7fe;
  144. border-radius: 2rpx;
  145. }
  146. }
  147. }
  148. .main-list {
  149. background: #ffffff;
  150. border-radius: 0rpx 0rpx 10rpx 10rpx;
  151. .main-list-item {
  152. padding: 20rpx 30rpx;
  153. border-bottom: 2rpx solid #fafafa;
  154. .main-list-main-name {
  155. color: #666666;
  156. font-size: 26rpx;
  157. margin-bottom: 20rpx;
  158. }
  159. .main-list-main-time {
  160. color: #999999;
  161. }
  162. .main-list-main-price {
  163. color: #ff4891;
  164. font-size: 30rpx;
  165. }
  166. .blue {
  167. color: #327cf6;
  168. }
  169. }
  170. }
  171. </style>