wenpiao.vue 9.4 KB

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