cash.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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/cash-bg.png" mode=""></image></view>
  10. <view class="money-box">
  11. <view class="money">{{ userInfo.cash }}</view>
  12. <view>我的现金</view>
  13. </view>
  14. <view class="moneybtn-box">
  15. <view class="money-btn" @click="navto('/pages/money/withdmoenys?type=cash')">
  16. 现金转账
  17. </view>
  18. <view class="money-btn" @click="navto('/pages/user/withdrawal')">
  19. 现金提现
  20. </view>
  21. </view>
  22. </view>
  23. <view class="info-box flex">
  24. <view class="info-item">
  25. <view class="info-font">累计收入</view>
  26. <view class="info-num">{{recharge}}</view>
  27. </view>
  28. <view class="shu"></view>
  29. <view class="info-item">
  30. <view class="info-font">累计支出</view>
  31. <view class="info-num">{{orderStatusSum}}</view>
  32. </view>
  33. </view>
  34. <view class="navbar">
  35. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  36. </view>
  37. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  38. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  39. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  40. <!-- 空白页 -->
  41. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  42. <!-- 订单列表 -->
  43. <view>
  44. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  45. <view class="title-box">
  46. <view class="title">
  47. <text>{{ item.mark }}</text>
  48. </view>
  49. <view class="time">
  50. <text>{{ item.add_time }}</text>
  51. </view>
  52. </view>
  53. <view class="money">
  54. <view>{{ (item.pm == 0 ? '-' : '+') + item.number }}</view>
  55. <view v-if="item.status == 0" class="status">待发放</view>
  56. </view>
  57. </view>
  58. </view>
  59. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  60. </scroll-view>
  61. </swiper-item>
  62. </swiper>
  63. </view>
  64. </template>
  65. <script>
  66. import { cashList, userBalance } from '@/api/wallet.js';
  67. import { getMoneyStyle } from '@/utils/rocessor.js';
  68. import { mapState, mapMutations } from 'vuex';
  69. import uniLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue';
  70. import empty from '@/uview-ui/components/u-empty/u-empty.vue';
  71. export default {
  72. filters: {
  73. getMoneyStyle
  74. },
  75. computed: {
  76. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  77. },
  78. components: {
  79. empty,
  80. uniLoadMore
  81. },
  82. onReady(res) {
  83. var _this = this;
  84. uni.getSystemInfo({
  85. success: resu => {
  86. const query = uni.createSelectorQuery();
  87. query.select('.swiper-box').boundingClientRect();
  88. query.exec(function(res) {
  89. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  90. console.log('打印页面的剩余高度', _this.height);
  91. });
  92. },
  93. fail: res => {}
  94. });
  95. },
  96. data() {
  97. return {
  98. // 头部图高度
  99. maxheight: '',
  100. tabCurrentIndex: 0,
  101. orderStatusSum: 0,
  102. recharge: 0,
  103. navList: [
  104. {
  105. state: 1,
  106. text: '收入',
  107. loadingType: 'more',
  108. orderList: [],
  109. page: 1, //当前页数
  110. limit: 10 //每次信息条数
  111. },
  112. {
  113. state: 0,
  114. text: '支出',
  115. loadingType: 'more',
  116. orderList: [],
  117. page: 1, //当前页数
  118. limit: 10 //每次信息条数
  119. }
  120. ],
  121. money: ''
  122. };
  123. },
  124. onLoad(options) {},
  125. onShow() {
  126. this.loadData();
  127. },
  128. methods: {
  129. // 页面跳转
  130. navto(e) {
  131. uni.navigateTo({
  132. url: e
  133. });
  134. },
  135. // 点击返回 我的页面
  136. toBack() {
  137. uni.navigateBack({});
  138. },
  139. //获取收入支出信息
  140. async loadData(source) {
  141. let obj = this
  142. //这里是将订单挂载到tab列表下
  143. let index = this.tabCurrentIndex;
  144. let navItem = this.navList[index];
  145. let state = navItem.state;
  146. if (source === 'tabChange' && navItem.loaded === true) {
  147. //tab切换只有第一次需要加载数据
  148. return;
  149. }
  150. if (navItem.loadingType === 'loading') {
  151. //防止重复加载
  152. return;
  153. }
  154. // 修改当前对象状态为加载中
  155. navItem.loadingType = 'loading';
  156. cashList(
  157. {
  158. page: navItem.page,
  159. limit: navItem.limit,
  160. pm: state
  161. }
  162. )
  163. .then(({ data }) => {
  164. obj.recharge = data.income;
  165. obj.orderStatusSum = data.expend;
  166. if (data.list.length > 0) {
  167. navItem.orderList = navItem.orderList.concat(data.list);
  168. console.log(navItem.orderList);
  169. navItem.page++;
  170. }
  171. if (navItem.limit == data.list.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. .moneybtn-box {
  295. display: flex;
  296. justify-content: space-between;
  297. position: relative;
  298. z-index: 2;
  299. color: #ffffff;
  300. padding:20rpx 50rpx ;
  301. font-size: 30rpx;
  302. font-family: PingFang SC;
  303. font-weight: bold;
  304. color: #FFFFFF;
  305. }
  306. .money-box {
  307. position: relative;
  308. z-index: 2;
  309. padding-top: 90rpx;
  310. color: #ffffff;
  311. text-align: center;
  312. .money {
  313. font-size: 72rpx;
  314. font-family: PingFang SC;
  315. font-weight: bold;
  316. color: #ffffff;
  317. }
  318. .text {
  319. font-size: 30rpx;
  320. }
  321. }
  322. .navbar {
  323. margin-top: 20rpx;
  324. display: flex;
  325. height: 88rpx;
  326. padding: 0 5px;
  327. background: #fff;
  328. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  329. position: relative;
  330. z-index: 10;
  331. .nav-item {
  332. flex: 1;
  333. display: flex;
  334. justify-content: center;
  335. align-items: center;
  336. height: 100%;
  337. font-size: 15px;
  338. color: #999999;
  339. position: relative;
  340. &.current {
  341. color: #000;
  342. &:after {
  343. content: '';
  344. position: absolute;
  345. left: 50%;
  346. bottom: 0;
  347. transform: translateX(-50%);
  348. width: 44px;
  349. height: 0;
  350. border-bottom: 2px solid #fe5b38;
  351. }
  352. }
  353. }
  354. }
  355. //列表
  356. .swiper-box {
  357. .order-item:last-child {
  358. margin-bottom: 60rpx;
  359. }
  360. .order-item {
  361. padding: 20rpx 30rpx;
  362. line-height: 1.5;
  363. .title-box {
  364. .title {
  365. font-size: $font-lg;
  366. color: $font-color-base;
  367. }
  368. .time {
  369. font-size: $font-base;
  370. color: $font-color-light;
  371. }
  372. }
  373. .money {
  374. color: #fd5b23;
  375. font-size: $font-lg;
  376. text-align: right;
  377. .status {
  378. color: $font-color-light;
  379. }
  380. }
  381. }
  382. }
  383. .list-scroll-content {
  384. background: #ffffff;
  385. height: 100%;
  386. }
  387. .content {
  388. height: 100%;
  389. .empty-content {
  390. background-color: #ffffff;
  391. }
  392. }
  393. .btn-box {
  394. width: 674rpx;
  395. height: 88rpx;
  396. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  397. border-radius: 44rpx;
  398. font-size: 36rpx;
  399. font-family: PingFang SC;
  400. font-weight: 500;
  401. color: #ffffff;
  402. text-align: center;
  403. line-height: 88rpx;
  404. position: fixed;
  405. bottom: 48rpx;
  406. left: 0;
  407. right: 0;
  408. margin: 0 auto;
  409. }
  410. </style>