wallet.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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('/pages/user/user')">
  9. <image class="goback" src="../../static/img/fanhui.png" mode=""></image>
  10. </view>
  11. <view class="header">我的钱包</view>
  12. </view>
  13. <view class="content-bg">
  14. <image src="../../static/user/walletbg.png" mode=""></image>
  15. </view>
  16. <view class="money-box">
  17. <view class="money">{{userInfo.integral | getMoneyStyle}}</view>
  18. <view>我的余额</view>
  19. </view>
  20. <view class="money-btn" @click="navto('/pages/money/withdmoenys')">
  21. 余额充值
  22. <text>></text>
  23. </view>
  24. </view>
  25. <view class="info-box flex">
  26. <view class="info-item">
  27. <view class="info-font">累计收入</view>
  28. <view class="info-num">{{recharge}}</view>
  29. </view>
  30. <view class="shu"></view>
  31. <view class="info-item">
  32. <view class="info-font">累计支出</view>
  33. <view class="info-num">{{orderStatusSum}}</view>
  34. </view>
  35. </view>
  36. <view class="navbar">
  37. <view v-for="(item, index) in navList" :key="index" class="nav-item"
  38. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  39. </view>
  40. <swiper :current="tabCurrentIndex" :style="{ height: height }" class="swiper-box" duration="300"
  41. @change="changeTab">
  42. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  43. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  44. <!-- 空白页 -->
  45. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  46. <!-- 订单列表 -->
  47. <view>
  48. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  49. <view class="title-box">
  50. <view class="title">
  51. <text>{{ item.mark }}</text>
  52. </view>
  53. <view class="time">
  54. <text>{{ item.add_time }}</text>
  55. </view>
  56. </view>
  57. <view class="money">
  58. <view>{{ (item.pm == 0 ? '-' : '+') + item.number }}</view>
  59. <view v-if="item.status == 0" class="status">待发放</view>
  60. </view>
  61. </view>
  62. </view>
  63. <uni-load-more :status="tabItem.loadingType"
  64. v-if="!(tabItem.orderList.length == 0 && tabItem.loaded)"></uni-load-more>
  65. </scroll-view>
  66. </swiper-item>
  67. </swiper>
  68. </view>
  69. </template>
  70. <script>
  71. import { spreadCommission, userBalance } from '@/api/wallet.js';
  72. import {
  73. integrallist
  74. } from '@/api/functionalUnit.js';
  75. import {
  76. getMoneyStyle
  77. } from '@/utils/rocessor.js';
  78. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  79. import empty from '@/components/empty';
  80. import {
  81. mapState,
  82. mapMutations
  83. } from 'vuex';
  84. export default {
  85. filters: {
  86. getMoneyStyle
  87. },
  88. components: {
  89. empty,
  90. uniLoadMore
  91. },
  92. computed: {
  93. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  94. },
  95. onReady(res) {
  96. var _this = this;
  97. uni.getSystemInfo({
  98. success: resu => {
  99. const query = uni.createSelectorQuery();
  100. query.select('.swiper-box').boundingClientRect();
  101. query.exec(function(res) {
  102. _this.height = resu.windowHeight - res[0].top + 'px';
  103. console.log('打印页面的剩余高度', _this.height);
  104. });
  105. },
  106. fail: res => {}
  107. });
  108. },
  109. data() {
  110. return {
  111. height: '',
  112. // 头部图高度
  113. maxheight: '',
  114. tabCurrentIndex: 0,
  115. orderStatusSum: 0,
  116. recharge: 0,
  117. navList: [
  118. // {
  119. // state: 0,
  120. // text: '全部',
  121. // loadingType: 'more',
  122. // orderList: [],
  123. // page: 1, //当前页数
  124. // limit: 10 //每次信息条数
  125. // },
  126. {
  127. state: 0,
  128. text: '支出',
  129. loadingType: 'more',
  130. orderList: [],
  131. page: 1, //当前页数
  132. limit: 10 //每次信息条数
  133. },
  134. {
  135. state: 1,
  136. text: '收入',
  137. loadingType: 'more',
  138. orderList: [],
  139. page: 1, //当前页数
  140. limit: 10 //每次信息条数
  141. }
  142. ],
  143. };
  144. },
  145. onLoad(options) {},
  146. onShow() {
  147. this.loadData();
  148. // 获取用户余额
  149. userBalance({}).then(({ data }) => {
  150. console.log(data,'22');
  151. this.money = data.now_money;
  152. console.log(this.money,'222');
  153. });
  154. },
  155. methods: {
  156. // 页面跳转
  157. navto(e) {
  158. uni.navigateTo({
  159. url: e
  160. });
  161. },
  162. //获取收入支出信息
  163. async loadData(source) {
  164. let obj = this
  165. //这里是将订单挂载到tab列表下
  166. let index = this.tabCurrentIndex;
  167. let navItem = this.navList[index];
  168. let state = navItem.state;
  169. if (source === 'tabChange' && navItem.loaded === true) {
  170. //tab切换只有第一次需要加载数据
  171. return;
  172. }
  173. if (navItem.loadingType === 'loading') {
  174. //防止重复加载
  175. return;
  176. }
  177. // 修改当前对象状态为加载中
  178. navItem.loadingType = 'loading';
  179. spreadCommission({
  180. page: navItem.page,
  181. limit: navItem.limit,
  182. },state )
  183. .then(({
  184. data
  185. }) => {
  186. obj.recharge = data.income;
  187. obj.orderStatusSum = data.expend;
  188. if (data.list.length > 0) {
  189. console.log(data,'数据111');
  190. navItem.orderList = navItem.orderList.concat(data.list);
  191. console.log(navItem.orderList);
  192. navItem.page++;
  193. }
  194. if (navItem.limit == data.list.length) {
  195. //判断是否还有数据, 有改为 more, 没有改为noMore
  196. navItem.loadingType = 'more';
  197. return;
  198. } else {
  199. //判断是否还有数据, 有改为 more, 没有改为noMore
  200. navItem.loadingType = 'noMore';
  201. }
  202. uni.hideLoading();
  203. this.$set(navItem, 'loaded', true);
  204. })
  205. .catch(e => {
  206. console.log(e);
  207. });
  208. },
  209. //swiper 切换
  210. changeTab(e) {
  211. this.tabCurrentIndex = e.target.current;
  212. this.loadData('tabChange');
  213. },
  214. //顶部tab点击
  215. tabClick(index) {
  216. this.tabCurrentIndex = index;
  217. },
  218. toBack(e) {
  219. uni.switchTab({
  220. url: e
  221. })
  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: 20rpx;
  283. height: 37rpx;
  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: 90rpx;
  326. color: #ffffff;
  327. text-align: center;
  328. .money {
  329. font-size: 72rpx;
  330. font-family: PingFang SC;
  331. font-weight: bold;
  332. color: #ffffff;
  333. }
  334. .text {
  335. font-size: 30rpx;
  336. }
  337. }
  338. .money-btn {
  339. position: relative;
  340. z-index: 2;
  341. color: #ffffff;
  342. padding-right: 50rpx;
  343. text-align: right;
  344. font-size: 30rpx;
  345. font-family: PingFang SC;
  346. font-weight: bold;
  347. color: #FFFFFF;
  348. text {
  349. display: inline-block;
  350. padding-left: 10rpx;
  351. }
  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. .title {
  396. font-size: $font-lg;
  397. color: $font-color-base;
  398. }
  399. .time {
  400. font-size: $font-base;
  401. color: $font-color-light;
  402. }
  403. }
  404. .money {
  405. color: #fd5b23;
  406. font-size: $font-lg;
  407. text-align: right;
  408. .status {
  409. color: $font-color-light;
  410. }
  411. }
  412. }
  413. }
  414. .list-scroll-content {
  415. background: #ffffff;
  416. height: 100%;
  417. }
  418. .content {
  419. height: 100%;
  420. .empty-content {
  421. background-color: #ffffff;
  422. }
  423. }
  424. .btn-box {
  425. width: 674rpx;
  426. height: 88rpx;
  427. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  428. border-radius: 44rpx;
  429. font-size: 36rpx;
  430. font-family: PingFang SC;
  431. font-weight: 500;
  432. color: #ffffff;
  433. text-align: center;
  434. line-height: 88rpx;
  435. position: fixed;
  436. bottom: 48rpx;
  437. left: 0;
  438. right: 0;
  439. margin: 0 auto;
  440. }
  441. </style>