wallet.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <view class="text">可提现金额(元)</view>
  6. <view class="money">{{ money | getMoneyStyle }}</view>
  7. </view>
  8. <view class="moneyTx" @click="navto('/pages/wallet/recharge')">充值</view>
  9. <view class="flex buttom-box">
  10. <view class="buttom" @click="navto('/pages/wallet/recharge')">
  11. <view class="icon"><image class="icon-img" src="/static/icon/i5.png" mode="aspectFit"></image></view>
  12. <text>充值</text>
  13. </view>
  14. <view class="interval"></view>
  15. <view class="buttom" @click="navto('/pages/wallet/withdrawal')">
  16. <view class="icon"><image class="icon-img" src="/static/icon/i1.png" mode="aspectFit"></image></view>
  17. <text>提现</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="navbar">
  22. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  23. </view>
  24. <swiper :current="tabCurrentIndex" :style="{'height':maxheight+'px'}" class="swiper-box" duration="300" @change="changeTab">
  25. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  26. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  27. <!-- 空白页 -->
  28. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  29. <!-- 订单列表 -->
  30. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  31. <view class="title-box">
  32. <view class="title">
  33. <text>{{ item.title }}</text>
  34. </view>
  35. <view class="time">
  36. <text>{{ item.add_time }}</text>
  37. </view>
  38. </view>
  39. <view class="money">
  40. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  41. </view>
  42. </view>
  43. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  44. </scroll-view>
  45. </swiper-item>
  46. </swiper>
  47. </view>
  48. </template>
  49. <script>
  50. import { spreadCommission, userBalance } from '@/api/wallet.js';
  51. import { getMoneyStyle } from '@/utils/rocessor.js';
  52. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  53. import empty from '@/components/empty';
  54. export default {
  55. filters: {
  56. getMoneyStyle
  57. },
  58. components: {
  59. empty,
  60. uniLoadMore
  61. },
  62. onReady() {
  63. // 初始化获取页面宽度
  64. uni.createSelectorQuery()
  65. .select('.content')
  66. .fields(
  67. {
  68. size: true
  69. },
  70. data => {
  71. // 保存头部高度
  72. this.maxheight =data.height - Math.floor((data.width / 750) * 570);
  73. }
  74. )
  75. .exec();
  76. },
  77. data() {
  78. return {
  79. // 头部图高度
  80. maxheight:'',
  81. tabCurrentIndex: 0,
  82. navList: [
  83. {
  84. state: 0,
  85. text: '全部',
  86. loadingType: 'more',
  87. orderList: [],
  88. page: 1, //当前页数
  89. limit: 10 //每次信息条数
  90. },
  91. {
  92. state: 1,
  93. text: '支出',
  94. loadingType: 'more',
  95. orderList: [],
  96. page: 1, //当前页数
  97. limit: 10 //每次信息条数
  98. },
  99. {
  100. state: 2,
  101. text: '收入',
  102. loadingType: 'more',
  103. orderList: [],
  104. page: 1, //当前页数
  105. limit: 10 //每次信息条数
  106. }
  107. ],
  108. money: ''
  109. };
  110. },
  111. onLoad(options) {},
  112. onShow() {
  113. this.loadData();
  114. // 获取用户余额
  115. userBalance({}).then(({ data }) => {
  116. this.money = data.now_money;
  117. });
  118. },
  119. methods: {
  120. // 页面跳转
  121. navto(e) {
  122. uni.navigateTo({
  123. url: e
  124. });
  125. },
  126. //获取收入支出信息
  127. async loadData(source) {
  128. //这里是将订单挂载到tab列表下
  129. let index = this.tabCurrentIndex;
  130. let navItem = this.navList[index];
  131. let state = navItem.state;
  132. if (source === 'tabChange' && navItem.loaded === true) {
  133. //tab切换只有第一次需要加载数据
  134. return;
  135. }
  136. if (navItem.loadingType === 'loading') {
  137. //防止重复加载
  138. return;
  139. }
  140. // 修改当前对象状态为加载中
  141. navItem.loadingType = 'loading';
  142. spreadCommission(
  143. {
  144. page: navItem.page,
  145. limit: navItem.limit
  146. },
  147. state
  148. )
  149. .then(({ data }) => {
  150. if (data.length > 0) {
  151. navItem.orderList = navItem.orderList.concat(data[0].list);
  152. navItem.page++;
  153. }
  154. if (navItem.limit == data.length) {
  155. //判断是否还有数据, 有改为 more, 没有改为noMore
  156. navItem.loadingType = 'more';
  157. return;
  158. } else {
  159. //判断是否还有数据, 有改为 more, 没有改为noMore
  160. navItem.loadingType = 'noMore';
  161. }
  162. this.$set(navItem, 'loaded', true);
  163. })
  164. .catch(e => {
  165. console.log(e);
  166. });
  167. },
  168. //swiper 切换
  169. changeTab(e) {
  170. this.tabCurrentIndex = e.target.current;
  171. this.loadData('tabChange');
  172. },
  173. //顶部tab点击
  174. tabClick(index) {
  175. this.tabCurrentIndex = index;
  176. }
  177. }
  178. };
  179. </script>
  180. <style lang="scss">
  181. page {
  182. background: #ffffff;
  183. height: 100%;
  184. }
  185. .content-money {
  186. padding-bottom: 30rpx;
  187. background: $page-color-base;
  188. .moneyTx {
  189. position: absolute;
  190. top: 150rpx;
  191. right: 0rpx;
  192. width: 150rpx;
  193. padding: 10rpx 30rpx;
  194. border: 2px solid #ffffff;
  195. border-top-left-radius: 99rpx;
  196. border-bottom-left-radius: 99rpx;
  197. color: #ffffff;
  198. line-height: 1;
  199. font-size: $font-base;
  200. }
  201. .buttom-box {
  202. background-color: #ffffff;
  203. text-align: center;
  204. margin: 0 30rpx;
  205. padding: 20rpx 0;
  206. border-radius: $border-radius-sm;
  207. margin-top: -60rpx;
  208. .buttom {
  209. font-size: $font-lg;
  210. flex-grow: 1;
  211. }
  212. .interval {
  213. width: 2px;
  214. height: 60rpx;
  215. background-color: #eeeeee;
  216. }
  217. .icon {
  218. height: 50rpx;
  219. width: 48rpx;
  220. margin: 0 auto;
  221. .icon-img {
  222. width: 100%;
  223. height: 100%;
  224. }
  225. }
  226. }
  227. }
  228. .money-box {
  229. background-color: $base-color;
  230. padding-top: var(--status-bar-height);
  231. height: 368rpx;
  232. color: #ffffff;
  233. text-align: center;
  234. .text {
  235. padding-top: 147rpx;
  236. font-size: $font-sm;
  237. }
  238. .money {
  239. font-size: 56rpx;
  240. }
  241. }
  242. .navbar {
  243. display: flex;
  244. height: 40px;
  245. padding: 0 5px;
  246. background: #fff;
  247. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  248. position: relative;
  249. z-index: 10;
  250. .nav-item {
  251. flex: 1;
  252. display: flex;
  253. justify-content: center;
  254. align-items: center;
  255. height: 100%;
  256. font-size: 15px;
  257. color: $font-color-dark;
  258. position: relative;
  259. &.current {
  260. color: $base-color;
  261. &:after {
  262. content: '';
  263. position: absolute;
  264. left: 50%;
  265. bottom: 0;
  266. transform: translateX(-50%);
  267. width: 44px;
  268. height: 0;
  269. border-bottom: 2px solid $base-color;
  270. }
  271. }
  272. }
  273. }
  274. // 列表
  275. .swiper-box {
  276. padding-top: 10rpx;
  277. .order-item {
  278. padding: 20rpx 30rpx;
  279. line-height: 1.5;
  280. .title-box {
  281. .title {
  282. font-size: $font-lg;
  283. color: $font-color-base;
  284. }
  285. .time {
  286. font-size: $font-base;
  287. color: $font-color-light;
  288. }
  289. }
  290. .money {
  291. color: #fd5b23;
  292. font-size: $font-lg;
  293. }
  294. }
  295. }
  296. .list-scroll-content {
  297. height: 100%;
  298. }
  299. .content {
  300. height: 100%;
  301. .empty-content {
  302. background-color: #ffffff;
  303. }
  304. }
  305. </style>