index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view>
  3. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="我的盲豆"></u-navbar>
  4. <view class="bean">
  5. <view class="flex bean-balance">
  6. <image src="../../static/icon/bean.png" mode="aspectFill"></image>
  7. <view class="bean-balance-num">{{ initData.coinNum }}</view>
  8. </view>
  9. <view class="bean-list">
  10. <view class="flex bean-list-item" v-for="(item, index) in list" :key="index">
  11. <view class="flex left">
  12. <view class="title">{{ item.logText }}</view>
  13. <view class="date">{{ $parseTime(item.createdTime) }}</view>
  14. </view>
  15. <view class="flex right">
  16. <view class="amt">{{ item.logMoney > 0 ? '+' : '' }}{{ item.logMoney }}</view>
  17. <view class="balance">余额:{{ item.money }}</view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="flex empty" v-if="!list.length">
  22. <u-empty text="数据为空" mode="order" />
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import $http from '@/utils/request.js'
  29. export default {
  30. data() {
  31. return {
  32. initData: {},
  33. pageNum: 1,
  34. total: 0,
  35. list: [],
  36. };
  37. },
  38. onShow() {
  39. this.getBean()
  40. this.pageList()
  41. },
  42. methods: {
  43. getBean() {
  44. uni.showLoading({
  45. title: '加载中'
  46. });
  47. $http.post('/api/v1/mp/user/mine/init', {}).then(res => {
  48. uni.hideLoading();
  49. if (res.code == 0) {
  50. this.initData = res.data
  51. }
  52. }).catch(() => {
  53. uni.hideLoading();
  54. })
  55. },
  56. getList() {
  57. uni.showLoading({
  58. title: '加载中'
  59. });
  60. $http.post(`/api/v1/mp/user/mine/coin/log/list?pageNum=${this.pageNum}&pageSize=50`, {}).then(res => {
  61. uni.hideLoading();
  62. if (res.code == 0) {
  63. res.rows.forEach(item => {
  64. item.type = item.type ? JSON.parse(item.type) : ''
  65. })
  66. this.total = res.total
  67. this.list = this.list.concat(res.rows)
  68. }
  69. }).catch(() => {
  70. uni.hideLoading();
  71. })
  72. },
  73. pageList() {
  74. this.pageNum = 1
  75. this.total = 0
  76. this.list = []
  77. this.getList()
  78. }
  79. },
  80. onReachBottom() {
  81. // 判断是否有数据
  82. if (this.total > this.pageNum * 50) {
  83. setTimeout(() => {
  84. ++this.pageNum
  85. this.getList()
  86. }, 500)
  87. } else {
  88. uni.$u.toast('没有更多数据了')
  89. }
  90. },
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. .bean {
  95. margin: 20rpx 10rpx;
  96. &-balance {
  97. justify-content: flex-start;
  98. height: 230rpx;
  99. line-height: 230rpx;
  100. border-radius: 10rpx;
  101. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/md-bkgd.png) center center;
  102. font-size: 50rpx;
  103. padding-left: 180rpx;
  104. font-weight: bold;
  105. margin-bottom: 20rpx;
  106. image {
  107. width: 130rpx;
  108. height: 130rpx;
  109. margin-right: 16rpx;
  110. }
  111. }
  112. &-list {
  113. background-color: #FFFFFF;
  114. padding: 0 40rpx;
  115. &-item {
  116. justify-content: space-between;
  117. padding: 24rpx 0;
  118. border-bottom: 1px solid rgba(236, 236, 236, 100);
  119. .left {
  120. flex-direction: column;
  121. justify-content: space-between;
  122. align-items: flex-start;
  123. }
  124. .right {
  125. flex-direction: column;
  126. justify-content: space-between;
  127. align-items: flex-end;
  128. }
  129. .title {
  130. font-size: 32rpx;
  131. font-weight: bold;
  132. margin-bottom: 32rpx;
  133. }
  134. .amt {
  135. margin-bottom: 32rpx;
  136. }
  137. .balance {
  138. color: #606060;
  139. }
  140. }
  141. &-item:last-child {
  142. border-bottom: none;
  143. }
  144. }
  145. }
  146. .empty{
  147. height: 60vh;
  148. }
  149. </style>