yue.vue 9.4 KB

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