cash.vue 8.6 KB

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