consumption.vue 9.6 KB

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