index.vue 4.9 KB

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