index.vue 4.5 KB

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