balance.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="content-money">
  5. <!-- 这里是状态栏 -->
  6. <!-- <view class="status_bar"></view> -->
  7. <view class="body-title">
  8. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
  9. <view class="header">我的余额</view>
  10. </view>
  11. <view class="content-bg"><image src="../../static/img/userBg.png" mode=""></image></view>
  12. <view class="money-box">
  13. <view class="money">{{ userInfo.now_money || 0 }}</view>
  14. <view>余额</view>
  15. </view>
  16. <view class="moneybtn-box">
  17. <!-- <view class="money-btn" style="text-decoration: underline;" @click="navto('/pages/money/freeze')">冻结记录</view> -->
  18. <view class="money-btn" style="text-decoration: underline;"></view>
  19. <view class="money-btn" @click="navto('/pages/money/recharge')">
  20. 余额充值
  21. <image class="money-img" src="../../static/img/img45.png" mode=""></image>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="info-box flex">
  27. <!-- <view class="info-item">
  28. <view class="info-font">冻结中</view>
  29. <view class="info-num">111</view>
  30. </view> -->
  31. <view class="shu"></view>
  32. <view class="info-item">
  33. <view class="info-font">累计收入</view>
  34. <view class="info-num">{{ sr }}</view>
  35. </view>
  36. <view class="shu"></view>
  37. <view class="info-item">
  38. <view class="info-font">累计支出</view>
  39. <view class="info-num">{{ zc }}</view>
  40. </view>
  41. </view>
  42. <view class="navbar">
  43. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  44. </view>
  45. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  46. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  47. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  48. <!-- 空白页 -->
  49. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  50. <!-- 订单列表 -->
  51. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  52. <view class="title-box">
  53. <view class="title">
  54. <text>{{ item.mark }}</text>
  55. </view>
  56. <view class="time">
  57. <text>{{ item.add_time }}</text>
  58. </view>
  59. </view>
  60. <view class="money">
  61. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  62. </view>
  63. </view>
  64. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  65. </scroll-view>
  66. </swiper-item>
  67. </swiper>
  68. </view>
  69. </template>
  70. <script>
  71. import { moneyList, userBalance } from '@/api/wallet.js';
  72. import { mapState, mapMutations } from 'vuex';
  73. import { getMoneyStyle } from '@/utils/rocessor.js';
  74. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  75. import empty from '@/components/empty';
  76. import { getUserInfo } from '@/api/user.js';
  77. export default {
  78. filters: {
  79. getMoneyStyle
  80. },
  81. computed: {
  82. ...mapState('user', ['userInfo'])
  83. },
  84. components: {
  85. empty,
  86. uniLoadMore
  87. },
  88. onReady(res) {
  89. var _this = this;
  90. uni.getSystemInfo({
  91. success: resu => {
  92. const query = uni.createSelectorQuery();
  93. query.select('.swiper-box').boundingClientRect();
  94. query.exec(function(res) {
  95. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  96. console.log('打印页面的剩余高度', _this.maxheight);
  97. });
  98. },
  99. fail: res => {}
  100. });
  101. },
  102. data() {
  103. return {
  104. // 头部图高度
  105. maxheight: '',
  106. tabCurrentIndex: 0,
  107. sr: '',
  108. zc: '',
  109. navList: [
  110. {
  111. state: 1,
  112. text: '收入',
  113. loadingType: 'more',
  114. orderList: [],
  115. page: 1, //当前页面
  116. limit: 10 //每次信息条数
  117. },
  118. {
  119. state: 0,
  120. text: '支出',
  121. loadingType: 'more',
  122. orderList: [],
  123. page: 1, //当前页面
  124. limit: 10 //每次信息条数
  125. }
  126. ],
  127. money: ''
  128. };
  129. },
  130. onLoad(options) {},
  131. onShow() {
  132. this.getUserInfo();
  133. this.loadData();
  134. //获取用户余额
  135. // userBalance({}).then(({ data }) => {
  136. // this.money = data.commissionCount;
  137. // });
  138. },
  139. methods: {
  140. ...mapMutations('user', ['setUserInfo']),
  141. navto(e) {
  142. uni.navigateTo({
  143. url: e
  144. });
  145. },
  146. getUserInfo() {
  147. getUserInfo({}).then(({ data }) => {
  148. this.setUserInfo(data);
  149. });
  150. },
  151. async loadData(source) {
  152. const obj = this;
  153. //这里时将订单挂载到tab列表下
  154. let index = this.tabCurrentIndex;
  155. let navItem = this.navList[index];
  156. let state = navItem.state;
  157. if (source === 'tabChange' && navItem.loaded === true) {
  158. //tab切换只有第一次需要加载数据
  159. return;
  160. }
  161. if (navItem.loadingType === 'loading') {
  162. //防止重复加载
  163. return;
  164. }
  165. //修改当前对象状态为加载中
  166. navItem.loadingType = 'loading';
  167. moneyList({
  168. page: navItem.page,
  169. limit: navItem.limit,
  170. pm: state
  171. })
  172. .then(({ data }) => {
  173. console.log(data, '123456');
  174. obj.sr = data.sr;
  175. obj.zc = data.zc;
  176. if (data.list.length > 0) {
  177. navItem.orderList = navItem.orderList.concat(data.list);
  178. console.log(navItem.orderList);
  179. navItem.page++;
  180. }
  181. //判断是否还有数据, 有改为more, 没有改为noMore
  182. if (navItem.limit == data.list.length) {
  183. navItem.loadingType = 'more';
  184. return;
  185. } else {
  186. navItem.loadingType = 'noMore';
  187. }
  188. uni.hideLoading();
  189. this.$set(navItem, 'loaded', true);
  190. })
  191. .catch(e => {
  192. console.log(e);
  193. });
  194. },
  195. //swiper 切换
  196. changeTab(e) {
  197. this.tabCurrentIndex = e.target.current;
  198. this.loadData('tabChange');
  199. },
  200. //顶部tab点击
  201. tabClick(index) {
  202. this.tabCurrentIndex = index;
  203. },
  204. toBack() {
  205. uni.navigateBack();
  206. }
  207. }
  208. };
  209. </script>
  210. <style lang="scss">
  211. page {
  212. background: #f2f5f4;
  213. height: 100%;
  214. }
  215. .status_bar {
  216. height: var(--status-bar-height);
  217. width: 100%;
  218. }
  219. .content-money {
  220. position: relative;
  221. height: 480rpx;
  222. .content-bg {
  223. position: absolute;
  224. top: 0;
  225. left: 0;
  226. right: 0;
  227. width: 750rpx;
  228. height: 480rpx;
  229. image {
  230. width: 100%;
  231. height: 100%;
  232. }
  233. }
  234. .body-title {
  235. height: 80rpx;
  236. text-align: center;
  237. font-size: 35rpx;
  238. position: relative;
  239. .header {
  240. position: absolute;
  241. left: 0;
  242. top: 0;
  243. width: 100%;
  244. font-size: 36rpx;
  245. font-family: PingFang SC;
  246. font-weight: bold;
  247. color: #fffeff;
  248. height: 80rpx;
  249. font-size: 36rpx;
  250. font-weight: 700;
  251. z-index: 9;
  252. display: flex;
  253. justify-content: center;
  254. align-items: center;
  255. }
  256. .goback-box {
  257. position: absolute;
  258. left: 18rpx;
  259. top: 0;
  260. height: 80rpx;
  261. display: flex;
  262. align-items: center;
  263. }
  264. .goback {
  265. z-index: 100;
  266. width: 34rpx;
  267. height: 34rpx;
  268. }
  269. }
  270. }
  271. .money-box {
  272. position: relative;
  273. z-index: 2;
  274. padding-top: 70rpx;
  275. color: #ffffff;
  276. text-align: center;
  277. .money {
  278. font-size: 72rpx;
  279. font-family: PingFang SC;
  280. font-weight: bold;
  281. color: #ffffff;
  282. }
  283. .text {
  284. font-size: 30rpx;
  285. }
  286. }
  287. .moneybtn-box {
  288. display: flex;
  289. justify-content: space-between;
  290. position: relative;
  291. z-index: 2;
  292. color: #ffffff;
  293. padding: 20rpx 50rpx;
  294. font-size: 30rpx;
  295. font-family: PingFang SC;
  296. font-weight: bold;
  297. color: #ffffff;
  298. .money-btn {
  299. display: flex;
  300. align-items: center;
  301. .money-img {
  302. width: 26rpx;
  303. height: 26rpx;
  304. }
  305. }
  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 #24a17d;
  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>