wallet.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="status_bar"><!-- 这里是状态栏 --></view>
  5. <view class="body-title">
  6. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
  7. <view class="header">我的余额</view>
  8. </view>
  9. <view class="content-bg"><image src="../../static/img/yongjin-bg.png" mode=""></image></view>
  10. <view class="money-box">
  11. <view class="money">{{money | getMoneyStyle}}</view>
  12. <view>我的余额</view>
  13. </view>
  14. <view class="money-btn" @click="navto('/pages/money/recharge')">
  15. 余额充值
  16. <text>></text>
  17. </view>
  18. </view>
  19. <view class="info-box flex">
  20. <view class="info-item">
  21. <view class="info-font">累计收入</view>
  22. <view class="info-num">{{recharge}}</view>
  23. </view>
  24. <view class="shu"></view>
  25. <view class="info-item">
  26. <view class="info-font">累计支出</view>
  27. <view class="info-num">{{orderStatusSum}}</view>
  28. </view>
  29. </view>
  30. <view class="navbar">
  31. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  32. </view>
  33. <swiper :current="tabCurrentIndex" :style="{ height: height }" class="swiper-box" duration="300" @change="changeTab">
  34. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  35. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  36. <!-- 空白页 -->
  37. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  38. <!-- 订单列表 -->
  39. <view>
  40. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  41. <view class="title-box">
  42. <view class="title">
  43. <text>{{ item.title }}</text>
  44. </view>
  45. <view class="time">
  46. <text>{{ item.add_time }}</text>
  47. </view>
  48. </view>
  49. <view class="money">
  50. <view>{{ (item.pm == 0 ? '-' : '+') + item.number }}</view>
  51. <view v-if="item.status == 0" class="status">待发放</view>
  52. </view>
  53. </view>
  54. </view>
  55. <uni-load-more :status="tabItem.loadingType" v-if="!(tabItem.orderList.length == 0 && tabItem.loaded)"></uni-load-more>
  56. </scroll-view>
  57. </swiper-item>
  58. </swiper>
  59. </view>
  60. </template>
  61. <script>
  62. import { spreadCommission, userBalance } from '@/api/wallet.js';
  63. import { getMoneyStyle } from '@/utils/rocessor.js';
  64. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  65. import empty from '@/components/empty';
  66. export default {
  67. filters: {
  68. getMoneyStyle
  69. },
  70. components: {
  71. empty,
  72. uniLoadMore
  73. },
  74. onReady(res) {
  75. var _this = this;
  76. uni.getSystemInfo({
  77. success: resu => {
  78. const query = uni.createSelectorQuery();
  79. query.select('.swiper-box').boundingClientRect();
  80. query.exec(function(res) {
  81. _this.height = resu.windowHeight - res[0].top + 'px';
  82. console.log('打印页面的剩余高度', _this.height);
  83. });
  84. },
  85. fail: res => {}
  86. });
  87. },
  88. data() {
  89. return {
  90. height: '',
  91. // 头部图高度
  92. maxheight:'',
  93. tabCurrentIndex: 0,
  94. orderStatusSum: 0,
  95. recharge: 0,
  96. navList: [
  97. // {
  98. // state: 0,
  99. // text: '全部',
  100. // loadingType: 'more',
  101. // orderList: [],
  102. // page: 1, //当前页数
  103. // limit: 10 //每次信息条数
  104. // },
  105. {
  106. state: 1,
  107. text: '支出',
  108. loadingType: 'more',
  109. orderList: [],
  110. page: 1, //当前页数
  111. limit: 10 //每次信息条数
  112. },
  113. {
  114. state: 2,
  115. text: '收入',
  116. loadingType: 'more',
  117. orderList: [],
  118. page: 1, //当前页数
  119. limit: 10 //每次信息条数
  120. }
  121. ],
  122. money: ''
  123. };
  124. },
  125. onLoad(options) {},
  126. onShow() {
  127. this.loadData();
  128. // 获取用户余额
  129. userBalance({}).then(({ data }) => {
  130. this.money = data.now_money;
  131. this.orderStatusSum = data.orderStatusSum
  132. this.recharge = data.recharge
  133. });
  134. },
  135. methods: {
  136. // 页面跳转
  137. navto(e) {
  138. uni.navigateTo({
  139. url: e
  140. });
  141. },
  142. //获取收入支出信息
  143. async loadData(source) {
  144. //这里是将订单挂载到tab列表下
  145. let index = this.tabCurrentIndex;
  146. let navItem = this.navList[index];
  147. let state = navItem.state;
  148. if (source === 'tabChange' && navItem.loaded === true) {
  149. //tab切换只有第一次需要加载数据
  150. return;
  151. }
  152. if (navItem.loadingType === 'loading') {
  153. //防止重复加载
  154. return;
  155. }
  156. // 修改当前对象状态为加载中
  157. navItem.loadingType = 'loading';
  158. spreadCommission(
  159. {
  160. page: navItem.page,
  161. limit: navItem.limit
  162. },
  163. state
  164. )
  165. .then(({ data }) => {
  166. if (data.length > 0) {
  167. navItem.orderList = navItem.orderList.concat(data[0].list);
  168. console.log(navItem.orderList);
  169. navItem.page++;
  170. }
  171. if (navItem.limit == data.length) {
  172. //判断是否还有数据, 有改为 more, 没有改为noMore
  173. navItem.loadingType = 'more';
  174. return;
  175. } else {
  176. //判断是否还有数据, 有改为 more, 没有改为noMore
  177. navItem.loadingType = 'noMore';
  178. }
  179. uni.hideLoading();
  180. this.$set(navItem, 'loaded', true);
  181. })
  182. .catch(e => {
  183. console.log(e);
  184. });
  185. },
  186. //swiper 切换
  187. changeTab(e) {
  188. this.tabCurrentIndex = e.target.current;
  189. this.loadData('tabChange');
  190. },
  191. //顶部tab点击
  192. tabClick(index) {
  193. this.tabCurrentIndex = index;
  194. }
  195. }
  196. };
  197. </script>
  198. <style lang="scss">
  199. page {
  200. background: #f1f1f1;
  201. height: 100%;
  202. }
  203. .status_bar {
  204. height: var(--status-bar-height);
  205. width: 100%;
  206. }
  207. .content-money {
  208. position: relative;
  209. height: 480rpx;
  210. .content-bg {
  211. position: absolute;
  212. top: 0;
  213. left: 0;
  214. right: 0;
  215. width: 750rpx;
  216. height: 480rpx;
  217. image {
  218. width: 100%;
  219. height: 100%;
  220. }
  221. }
  222. .body-title {
  223. height: 80rpx;
  224. text-align: center;
  225. font-size: 35rpx;
  226. position: relative;
  227. .header {
  228. position: absolute;
  229. left: 0;
  230. top: 0;
  231. width: 100%;
  232. font-size: 36rpx;
  233. font-family: PingFang SC;
  234. font-weight: bold;
  235. color: #fffeff;
  236. height: 80rpx;
  237. font-size: 36rpx;
  238. font-weight: 700;
  239. z-index: 9;
  240. display: flex;
  241. justify-content: center;
  242. align-items: center;
  243. }
  244. .goback-box {
  245. position: absolute;
  246. left: 18rpx;
  247. top: 0;
  248. height: 80rpx;
  249. display: flex;
  250. align-items: center;
  251. }
  252. .goback {
  253. z-index: 100;
  254. width: 34rpx;
  255. height: 34rpx;
  256. }
  257. }
  258. }
  259. .info-box {
  260. width: 670rpx;
  261. height: 186rpx;
  262. background: #ffffff;
  263. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  264. border-radius: 20rpx;
  265. margin: -100rpx auto 0;
  266. position: relative;
  267. z-index: 2;
  268. .info-item {
  269. width: 50%;
  270. display: flex;
  271. flex-direction: column;
  272. align-items: center;
  273. line-height: 1;
  274. .info-font {
  275. font-size: 30rpx;
  276. font-family: PingFang SC;
  277. font-weight: bold;
  278. color: #999999;
  279. }
  280. .info-num {
  281. margin-top: 30rpx;
  282. font-size: 30rpx;
  283. font-family: PingFang SC;
  284. font-weight: bold;
  285. color: #181818;
  286. }
  287. }
  288. .shu {
  289. width: 2rpx;
  290. height: 74rpx;
  291. background: #dcdfe6;
  292. }
  293. }
  294. .money-box {
  295. position: relative;
  296. z-index: 2;
  297. padding-top: 90rpx;
  298. color: #ffffff;
  299. text-align: center;
  300. .money {
  301. font-size: 72rpx;
  302. font-family: PingFang SC;
  303. font-weight: bold;
  304. color: #ffffff;
  305. }
  306. .text {
  307. font-size: 30rpx;
  308. }
  309. }
  310. .money-btn {
  311. position: relative;
  312. z-index: 2;
  313. color: #ffffff;
  314. padding-right: 50rpx;
  315. text-align: right;
  316. font-size: 30rpx;
  317. font-family: PingFang SC;
  318. font-weight: bold;
  319. color: #FFFFFF;
  320. text {
  321. display: inline-block;
  322. padding-left: 10rpx;
  323. }
  324. }
  325. .navbar {
  326. margin-top: 20rpx;
  327. display: flex;
  328. height: 88rpx;
  329. padding: 0 5px;
  330. background: #fff;
  331. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  332. position: relative;
  333. z-index: 10;
  334. .nav-item {
  335. flex: 1;
  336. display: flex;
  337. justify-content: center;
  338. align-items: center;
  339. height: 100%;
  340. font-size: 15px;
  341. color: #999999;
  342. position: relative;
  343. &.current {
  344. color: #000;
  345. &:after {
  346. content: '';
  347. position: absolute;
  348. left: 50%;
  349. bottom: 0;
  350. transform: translateX(-50%);
  351. width: 44px;
  352. height: 0;
  353. border-bottom: 2px solid #fe5b38;
  354. }
  355. }
  356. }
  357. }
  358. //列表
  359. .swiper-box {
  360. .order-item:last-child {
  361. margin-bottom: 60rpx;
  362. }
  363. .order-item {
  364. padding: 20rpx 30rpx;
  365. line-height: 1.5;
  366. .title-box {
  367. .title {
  368. font-size: $font-lg;
  369. color: $font-color-base;
  370. }
  371. .time {
  372. font-size: $font-base;
  373. color: $font-color-light;
  374. }
  375. }
  376. .money {
  377. color: #fd5b23;
  378. font-size: $font-lg;
  379. text-align: right;
  380. .status {
  381. color: $font-color-light;
  382. }
  383. }
  384. }
  385. }
  386. .list-scroll-content {
  387. background: #ffffff;
  388. height: 100%;
  389. }
  390. .content {
  391. height: 100%;
  392. .empty-content {
  393. background-color: #ffffff;
  394. }
  395. }
  396. .btn-box {
  397. width: 674rpx;
  398. height: 88rpx;
  399. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  400. border-radius: 44rpx;
  401. font-size: 36rpx;
  402. font-family: PingFang SC;
  403. font-weight: 500;
  404. color: #ffffff;
  405. text-align: center;
  406. line-height: 88rpx;
  407. position: fixed;
  408. bottom: 48rpx;
  409. left: 0;
  410. right: 0;
  411. margin: 0 auto;
  412. }
  413. </style>