cash.vue 8.7 KB

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