index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="main">
  3. <view class="card">
  4. <view class="money">{{ item.money }}</view>
  5. <view class="desc">账户余额(元)</view>
  6. <view class="flex">
  7. <view class="f">
  8. <button class="btn" style="background-color: #607d8b">
  9. <text class="icon">&#xe612;</text>
  10. <text>提现</text>
  11. </button>
  12. </view>
  13. <view class="f">
  14. <button class="btn" @click="go('/pages/user/money/add')">
  15. <text class="icon">&#xe7c4;</text>
  16. <text>充值</text>
  17. </button>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="tab">
  22. <u-tabs :list="type" @click="click($event, 'type')"></u-tabs>
  23. </view>
  24. <view class="list">
  25. <view class="item" v-for="(item, index) in list" :key="index">
  26. <view class="title">{{ item.title }}</view>
  27. <view class="desc">
  28. <text v-if="item.state == 0 && item.type == 0" style="color: #f44336">未支付</text>
  29. <text v-if="item.state == 1 && item.type == 0" style="color: #4caf50">充值成功</text>
  30. <text v-if="item.state == 1 && item.type == 1" style="color: #4caf50">兼职支出</text>
  31. <text v-if="item.state == 1 && item.type == 4" style="color: #4caf50">退款成功</text>
  32. <text>{{ item.createTime }}</text>
  33. </view>
  34. <view class="price">
  35. <text v-if="item.type == 0" style="color: orangered">+{{ item.money }}</text>
  36. <text v-if="item.type == 1 || item.type == 4" style="color: darkgray">-{{ item.money }}</text>
  37. </view>
  38. </view>
  39. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  40. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. data() {
  47. return {
  48. item: {},
  49. current: 0,
  50. type: [
  51. { name: '全部', value: '' },
  52. { name: '充值', value: 0 },
  53. { name: '支出', value: 1 },
  54. { name: '提现', value: 2 },
  55. { name: '收入', value: 3 },
  56. { name: '退款', value: 4 }
  57. ],
  58. list: [],
  59. param: { pageNum: 1, pageSize: 10 },
  60. loadMore: true
  61. };
  62. },
  63. onLoad(e) {
  64. this.getInfo();
  65. this.getData();
  66. uni.$on('payMoney', (res) => {
  67. this.getInfo();
  68. this.getData();
  69. });
  70. },
  71. methods: {
  72. getInfo() {
  73. this.http.request({
  74. url: '/app/user/info',
  75. success: (res) => {
  76. this.item = res.data.data;
  77. uni.setStorageSync('money', res.data.data.money || 0);
  78. }
  79. });
  80. },
  81. getData() {
  82. this.http.request({
  83. url: '/app/pay/list',
  84. data: this.param,
  85. loading: 'false',
  86. success: (res) => {
  87. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  88. this.list.push(...res.data.rows);
  89. }
  90. });
  91. },
  92. click(e) {
  93. this.param.type = e.value;
  94. this.refresh();
  95. },
  96. go(url) {
  97. uni.navigateTo({ url: url });
  98. },
  99. //刷新数据
  100. refresh() {
  101. this.loadMore = true;
  102. this.param.pageNum = 1;
  103. this.list = [];
  104. this.getData();
  105. }
  106. },
  107. //下拉刷新
  108. onPullDownRefresh() {
  109. setTimeout(() => {
  110. this.refresh();
  111. uni.stopPullDownRefresh();
  112. }, 1000);
  113. },
  114. //上拉加载
  115. onReachBottom() {
  116. if (this.loadMore) {
  117. this.param.pageNum++;
  118. this.getData();
  119. }
  120. }
  121. };
  122. </script>
  123. <style lang="scss">
  124. .card {
  125. background-color: white;
  126. padding: 15px;
  127. border-radius: 8px;
  128. .money {
  129. font-size: 22px;
  130. font-weight: bold;
  131. }
  132. .desc {
  133. padding-top: 10px;
  134. font-size: 14px;
  135. color: $font-c;
  136. }
  137. .f {
  138. padding: 10px;
  139. .btn {
  140. padding: 0px;
  141. .icon {
  142. padding-right: 3px;
  143. }
  144. }
  145. }
  146. }
  147. .list {
  148. background-color: white;
  149. border-radius: 8px;
  150. padding: 15px 15px 15px 15px;
  151. .item {
  152. padding: 15px 0px 15px 0px;
  153. border-bottom: 1px solid $line;
  154. padding-bottom: 10px;
  155. &:first-child {
  156. padding-top: 0px;
  157. }
  158. &:last-child {
  159. border: 0px;
  160. padding-bottom: 5px;
  161. }
  162. .title {
  163. width: 70%;
  164. }
  165. .desc {
  166. font-size: 14px;
  167. padding-top: 5px;
  168. color: $font-c;
  169. text {
  170. padding-right: 15px;
  171. }
  172. }
  173. .price {
  174. float: right;
  175. margin-top: -35px;
  176. }
  177. }
  178. }
  179. </style>