index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 flex" @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 16rpx;
  122. }
  123. &-title {
  124. font-size: 26rpx;
  125. line-height: 26rpx;
  126. margin-bottom: 24rpx;
  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. font-size: 30rpx;
  136. text-align: center;
  137. background: #fff;
  138. border-radius: 16rpx;
  139. image {
  140. width: 56rpx;
  141. height: 56rpx;
  142. margin-right: 10rpx;
  143. }
  144. }
  145. }
  146. // 盲豆流水
  147. &-list {
  148. background-color: #FFFFFF;
  149. padding: 0 34rpx;
  150. border-radius: 22rpx;
  151. &-item {
  152. justify-content: space-between;
  153. padding: 40rpx 0;
  154. border-bottom: 1px solid #eee;
  155. .left {
  156. flex-direction: column;
  157. justify-content: space-between;
  158. align-items: flex-start;
  159. .date {
  160. color: #AAAAAA;
  161. line-height: 24rpx;
  162. margin-bottom: 28rpx;
  163. }
  164. .title {
  165. font-size: 30rpx;
  166. line-height: 30rpx;
  167. }
  168. }
  169. .right {
  170. flex-direction: column;
  171. justify-content: space-between;
  172. align-items: flex-end;
  173. .amt {
  174. color: #FF4208;
  175. font-size: 30rpx;
  176. line-height: 30rpx;
  177. margin-bottom: 28rpx;
  178. }
  179. .balance {
  180. color: #AAAAAA;
  181. }
  182. }
  183. }
  184. &-item:last-child {
  185. border-bottom: none;
  186. }
  187. }
  188. }
  189. .empty {
  190. height: 60vh;
  191. .center {
  192. text-align: center;
  193. &-img {
  194. width: 228rpx;
  195. height: 320rpx;
  196. }
  197. &-font {
  198. font-size: 30rpx;
  199. font-weight: 400;
  200. color: #999999;
  201. margin-bottom: 250rpx;
  202. }
  203. }
  204. }
  205. </style>