index.vue 4.7 KB

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