index.vue 4.1 KB

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