index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. <view class="bean-balance-img">
  7. <image src="../../static/icon/bean.png" mode="aspectFill"></image>
  8. </view>
  9. <view class="bean-balance-num">{{ initData.coinNum }}</view>
  10. <view class="bean-balance-btn" @click="toCore">立即兑换</view>
  11. </view>
  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="title">{{ item.logText }}</view>
  16. <view class="date">{{ $parseTime(item.createdTime) }}</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: 20rpx 10rpx;
  104. &-balance {
  105. justify-content: flex-start;
  106. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/md-bkgd.png) center center;
  107. padding-left: 34rpx;
  108. font-weight: bold;
  109. margin-bottom: 20rpx;
  110. color: #FFFFFF;
  111. image {
  112. width: 130rpx;
  113. height: 130rpx;
  114. margin-right: 16rpx;
  115. }
  116. &-img{
  117. background-color: rgba(255,255,255,0.7);
  118. border-radius: 100rpx;
  119. width: 65px;
  120. height: 65px;
  121. image {
  122. width: 57px;
  123. height: 57px;
  124. margin:7rpx 7rpx ;
  125. }
  126. }
  127. &-num {
  128. height: 230rpx;
  129. line-height: 230rpx;
  130. border-radius: 10rpx;
  131. font-size: 72rpx;
  132. margin-left: 25rpx;
  133. }
  134. &-btn{
  135. font-size: 28rpx;
  136. height: 54rpx;
  137. width: 160rpx;
  138. line-height: 51rpx;
  139. background-color: rgba(255,255,255,0.4);
  140. color: #FFFFFF;
  141. border: 2rpx solid #FFFFFF;
  142. margin-left: 170rpx;
  143. margin-top: 10rpx;
  144. border-radius: 27rpx;
  145. text-align: center;
  146. }
  147. &-btn:hover{
  148. opacity: 0.8;
  149. }
  150. }
  151. &-list {
  152. background-color: #FFFFFF;
  153. padding: 0 40rpx;
  154. &-item {
  155. justify-content: space-between;
  156. padding: 24rpx 0;
  157. border-bottom: 1px solid rgba(236, 236, 236, 100);
  158. .left {
  159. flex-direction: column;
  160. justify-content: space-between;
  161. align-items: flex-start;
  162. }
  163. .right {
  164. flex-direction: column;
  165. justify-content: space-between;
  166. align-items: flex-end;
  167. }
  168. .title {
  169. font-size: 32rpx;
  170. font-weight: bold;
  171. margin-bottom: 32rpx;
  172. }
  173. .amt {
  174. margin-bottom: 32rpx;
  175. }
  176. .balance {
  177. color: #606060;
  178. }
  179. }
  180. &-item:last-child {
  181. border-bottom: none;
  182. }
  183. }
  184. }
  185. .empty {
  186. height: 60vh;
  187. }
  188. </style>