yue.vue 9.4 KB

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