wallet.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view class="content">
  3. <view class="bg">
  4. </view>
  5. <view class="content-money">
  6. <view class="conetnt-box">
  7. <view class="money-box">
  8. <view class="text">可用金额(元)</view>
  9. <view class="money">{{ money | getMoneyStyle }}</view>
  10. </view>
  11. <view class="flex buttom-box">
  12. <view class="buttom" @click="navto('./recharge')">
  13. <text>充值</text>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="listbox">
  19. <view class="navbar flex">
  20. <view class="title">
  21. 余额变动明细
  22. </view>
  23. <view class="alllist" @click="navto('./walletList')">
  24. 全部
  25. </view>
  26. </view>
  27. <view class="conetntList">
  28. <view class="listItem flex" v-for="(item, tabIndex) in navList[0].orderList">
  29. <view class="itemLeft">
  30. <view class="itemTitle">
  31. {{item.title}}
  32. </view>
  33. <view class="itemBottom">
  34. {{item.add_time}}
  35. </view>
  36. </view>
  37. <view class="itemRight">
  38. <view class="itemTitle">
  39. {{(item.pm == 0 ? '-' : '+')+item.number}}
  40. </view>
  41. <!-- <view class="itemBottom">
  42. 余额{{item.yue}}
  43. </view> -->
  44. </view>
  45. </view>
  46. <uni-load-more :status="navList[0].loadingType"></uni-load-more>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. spreadCommission,
  54. userBalance
  55. } from '@/api/wallet.js';
  56. import {
  57. getMoneyStyle
  58. } from '@/utils/rocessor.js';
  59. export default {
  60. filters: {
  61. getMoneyStyle
  62. },
  63. data() {
  64. return {
  65. // 头部图高度
  66. maxheight: '',
  67. tabCurrentIndex: 0, //当前选中的
  68. navList: [{
  69. state: 0,
  70. text: '全部',
  71. loadingType: 'more',
  72. orderList: [],
  73. page: 1, //当前页数
  74. limit: 10 //每次信息条数
  75. }, ],
  76. money: ''
  77. };
  78. },
  79. onLoad(options) {
  80. this.loadData();
  81. console.log('进入');
  82. },
  83. onShow() {
  84. // 获取用户余额
  85. userBalance({}).then(({
  86. data
  87. }) => {
  88. this.money = data.now_money;
  89. });
  90. },
  91. // 页面到底部后加载数据
  92. onReachBottom() {
  93. this.loadData();
  94. },
  95. methods: {
  96. // 页面跳转
  97. navto(e) {
  98. uni.navigateTo({
  99. url: e
  100. });
  101. },
  102. //获取收入支出信息
  103. async loadData(source) {
  104. //这里是将订单挂载到tab列表下
  105. let index = this.tabCurrentIndex;
  106. let navItem = this.navList[index];
  107. let state = navItem.state;
  108. if (source === 'tabChange' && navItem.loaded === true) {
  109. //tab切换只有第一次需要加载数据
  110. return;
  111. }
  112. if (navItem.loadingType === 'loading') {
  113. //防止重复加载
  114. return;
  115. }
  116. // 修改当前对象状态为加载中
  117. navItem.loadingType = 'loading';
  118. spreadCommission({
  119. page: navItem.page,
  120. limit: navItem.limit
  121. },
  122. state
  123. )
  124. .then(({
  125. data
  126. }) => {
  127. if (data.length > 0) {
  128. navItem.orderList = navItem.orderList.concat(data[0].list);
  129. console.log(navItem.orderList);
  130. navItem.page++;
  131. }
  132. if (navItem.limit == data.length) {
  133. //判断是否还有数据, 有改为 more, 没有改为noMore
  134. navItem.loadingType = 'more';
  135. return;
  136. } else {
  137. //判断是否还有数据, 有改为 more, 没有改为noMore
  138. navItem.loadingType = 'noMore';
  139. }
  140. uni.hideLoading();
  141. this.$set(navItem, 'loaded', true);
  142. })
  143. .catch(e => {
  144. console.log(e);
  145. this.$set(navItem, 'loaded', true);
  146. });
  147. }
  148. }
  149. };
  150. </script>
  151. <style lang="scss">
  152. page {
  153. height: 100%;
  154. }
  155. .content-money {
  156. position: relative;
  157. padding: 20rpx;
  158. z-index: 1;
  159. height: 440rpx;
  160. .conetnt-box {
  161. border-radius: 20rpx;
  162. background-color: #ffffff;
  163. height: 400rpx
  164. }
  165. .buttom-box {
  166. text-align: center;
  167. margin: 0 30rpx;
  168. margin-top: 80rpx;
  169. .buttom {
  170. flex-grow: 1;
  171. border-radius: 100rpx;
  172. font-size: $font-lg;
  173. width: 300rpx;
  174. height: 80rpx;
  175. line-height: 80rpx;
  176. background-color: $color-green;
  177. color: #FFFFFF;
  178. &.geMoney {
  179. border: 1px solid $font-color-disabled;
  180. color: $font-color-disabled;
  181. background-color: #FFFFFF;
  182. }
  183. }
  184. }
  185. }
  186. .money-box {
  187. text-align: center;
  188. color: $font-color-dark;
  189. font-weight: bold;
  190. .text {
  191. padding-top: 85rpx;
  192. font-size: 24rpx;
  193. margin-bottom: 20rpx;
  194. }
  195. .money {
  196. font-size: 60rpx;
  197. }
  198. }
  199. .listbox {
  200. margin: 0 20rpx;
  201. border-radius: 20rpx;
  202. }
  203. .navbar {
  204. background: #fff;
  205. padding: 30rpx;
  206. border-bottom: 1px solid $page-color-light;
  207. border-top-left-radius: 20rpx;
  208. border-top-right-radius: 20rpx;
  209. .title {
  210. font-size: 32rpx;
  211. font-weight: bold;
  212. }
  213. .alllist {
  214. font-size: 28rpx;
  215. }
  216. }
  217. .content {
  218. height: 100%;
  219. .bg {
  220. background-color: $color-green;
  221. width: 950rpx;
  222. position: absolute;
  223. left: -100rpx;
  224. border-bottom-left-radius: 1000rpx;
  225. border-bottom-right-radius: 1000rpx;
  226. top: 0rpx;
  227. height: 300rpx;
  228. }
  229. }
  230. .conetntList {
  231. padding: 30rpx;
  232. background-color: #FFFFFF;
  233. border-bottom-left-radius: 20rpx;
  234. border-bottom-right-radius: 20rpx;
  235. .listItem {
  236. font-size: 30rpx;
  237. color: $font-color-dark;
  238. align-items: flex-start;
  239. }
  240. .itemBottom {
  241. font-size: 24rpx;
  242. color: $font-color-disabled;
  243. }
  244. }
  245. </style>