wenpiao.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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. console.log(data,'data')
  199. obj.zc = data.zc
  200. obj.sr = data.sr
  201. navItem.orderList = navItem.orderList.concat(data.list)
  202. navItem.page++
  203. if (navItem.limit == data.list.length) {
  204. navItem.loadingType = 'more'
  205. } else {
  206. navItem.loadingType = 'noMore'
  207. }
  208. obj.$set(navItem, 'loaded', true);
  209. })
  210. .catch(e => {
  211. console.log(e);
  212. });
  213. },
  214. //swiper 切换
  215. changeTab(e) {
  216. this.tabCurrentIndex = e.target.current;
  217. this.loadData('tabChange');
  218. },
  219. //顶部tab点击
  220. tabClick(index) {
  221. this.tabCurrentIndex = index;
  222. }
  223. }
  224. };
  225. </script>
  226. <style lang="scss">
  227. page {
  228. background: #f1f1f1;
  229. height: 100%;
  230. }
  231. .status_bar {
  232. height: var(--status-bar-height);
  233. width: 100%;
  234. }
  235. .content-money {
  236. position: relative;
  237. height: 480rpx;
  238. .content-bg {
  239. position: absolute;
  240. top: 0;
  241. left: 0;
  242. right: 0;
  243. width: 750rpx;
  244. height: 480rpx;
  245. image {
  246. width: 100%;
  247. height: 100%;
  248. }
  249. }
  250. .body-title {
  251. height: 80rpx;
  252. text-align: center;
  253. font-size: 35rpx;
  254. position: relative;
  255. .header {
  256. position: absolute;
  257. left: 0;
  258. top: 0;
  259. width: 100%;
  260. font-size: 36rpx;
  261. font-family: PingFang SC;
  262. font-weight: bold;
  263. color: #fffeff;
  264. height: 80rpx;
  265. font-size: 36rpx;
  266. font-weight: 700;
  267. z-index: 9;
  268. display: flex;
  269. justify-content: center;
  270. align-items: center;
  271. }
  272. .goback-box {
  273. position: absolute;
  274. left: 18rpx;
  275. top: 0;
  276. height: 80rpx;
  277. display: flex;
  278. align-items: center;
  279. }
  280. .goback {
  281. z-index: 100;
  282. width: 34rpx;
  283. height: 34rpx;
  284. }
  285. }
  286. }
  287. .info-box {
  288. width: 670rpx;
  289. height: 186rpx;
  290. background: #ffffff;
  291. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  292. border-radius: 20rpx;
  293. margin: -100rpx auto 0;
  294. position: relative;
  295. z-index: 2;
  296. .info-item {
  297. width: 50%;
  298. display: flex;
  299. flex-direction: column;
  300. align-items: center;
  301. line-height: 1;
  302. .info-font {
  303. font-size: 30rpx;
  304. font-family: PingFang SC;
  305. font-weight: bold;
  306. color: #999999;
  307. }
  308. .info-num {
  309. margin-top: 30rpx;
  310. font-size: 30rpx;
  311. font-family: PingFang SC;
  312. font-weight: bold;
  313. color: #181818;
  314. }
  315. }
  316. .shu {
  317. width: 2rpx;
  318. height: 74rpx;
  319. background: #dcdfe6;
  320. }
  321. }
  322. .money-box {
  323. position: relative;
  324. z-index: 2;
  325. padding-top: 70rpx;
  326. color: #ffffff;
  327. text-align: center;
  328. /* #ifdef APP-PLUS */
  329. padding-top: 30rpx;
  330. /* #endif */
  331. .money {
  332. font-size: 72rpx;
  333. font-family: PingFang SC;
  334. font-weight: bold;
  335. color: #ffffff;
  336. }
  337. .text {
  338. font-size: 30rpx;
  339. }
  340. }
  341. .moneybtn-box {
  342. display: flex;
  343. justify-content: space-between;
  344. position: relative;
  345. z-index: 2;
  346. color: #ffffff;
  347. padding: 20rpx 50rpx;
  348. font-size: 30rpx;
  349. font-family: PingFang SC;
  350. font-weight: bold;
  351. color: #FFFFFF;
  352. }
  353. .navbar {
  354. margin-top: 20rpx;
  355. display: flex;
  356. height: 88rpx;
  357. padding: 0 5px;
  358. background: #fff;
  359. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  360. position: relative;
  361. z-index: 10;
  362. .nav-item {
  363. flex: 1;
  364. display: flex;
  365. justify-content: center;
  366. align-items: center;
  367. height: 100%;
  368. font-size: 15px;
  369. color: #999999;
  370. position: relative;
  371. &.current {
  372. color: #000;
  373. &:after {
  374. content: '';
  375. position: absolute;
  376. left: 50%;
  377. bottom: 0;
  378. transform: translateX(-50%);
  379. width: 44px;
  380. height: 0;
  381. border-bottom: 2px solid #fe5b38;
  382. }
  383. }
  384. }
  385. }
  386. //列表
  387. .swiper-box {
  388. .order-item:last-child {
  389. margin-bottom: 60rpx;
  390. }
  391. .order-item {
  392. padding: 20rpx 30rpx;
  393. line-height: 1.5;
  394. .title-box {
  395. width: 580rpx;
  396. // text-overflow: ellipsis;
  397. // overflow: hidden;
  398. // white-space: nowrap;
  399. .title {
  400. width: 580rpx;
  401. display: flex;
  402. flex-wrap: wrap;
  403. // text-overflow: ellipsis;
  404. // overflow: hidden;
  405. // white-space: nowrap;
  406. font-size: $font-lg;
  407. color: $font-color-base;
  408. }
  409. .time {
  410. font-size: $font-base;
  411. color: $font-color-light;
  412. }
  413. }
  414. .money {
  415. color: #fd5b23;
  416. font-size: $font-lg;
  417. text-align: right;
  418. .status {
  419. color: $font-color-light;
  420. }
  421. }
  422. }
  423. }
  424. .list-scroll-content {
  425. background: #ffffff;
  426. height: 100%;
  427. }
  428. .content {
  429. height: 100%;
  430. .empty-content {
  431. background-color: #ffffff;
  432. }
  433. }
  434. .btn-box {
  435. width: 674rpx;
  436. height: 88rpx;
  437. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  438. border-radius: 44rpx;
  439. font-size: 36rpx;
  440. font-family: PingFang SC;
  441. font-weight: 500;
  442. color: #ffffff;
  443. text-align: center;
  444. line-height: 88rpx;
  445. position: fixed;
  446. bottom: 48rpx;
  447. left: 0;
  448. right: 0;
  449. margin: 0 auto;
  450. }
  451. </style>