income.vue 9.7 KB

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