yue.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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 uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  83. import empty from '@/components/empty';
  84. import {
  85. getUserInfo
  86. } from '@/api/user.js';
  87. export default {
  88. filters: {
  89. getMoneyStyle
  90. },
  91. components: {
  92. empty,
  93. uniLoadMore
  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.maxheight = resu.windowHeight - res[0].top + 'px';
  103. console.log('打印页面的剩余高度', _this.maxheight);
  104. });
  105. },
  106. fail: res => {}
  107. });
  108. },
  109. data() {
  110. return {
  111. userInfo: {},
  112. // 头部图高度
  113. maxheight: '',
  114. tabCurrentIndex: 0,
  115. sr: '',
  116. zc: '',
  117. navList: [{
  118. state: 2,
  119. text: '收入',
  120. loadingType: 'more',
  121. orderList: [],
  122. page: 1, //当前页面
  123. limit: 10 //每次信息条数
  124. },
  125. {
  126. state: 1,
  127. text: '支出',
  128. loadingType: 'more',
  129. orderList: [],
  130. page: 1, //当前页面
  131. limit: 10 //每次信息条数
  132. }
  133. ],
  134. money: ''
  135. };
  136. },
  137. onLoad(options) {},
  138. onShow() {
  139. this.getUserInfo();
  140. this.loadData();
  141. //获取用户余额
  142. // userBalance({}).then(({ data }) => {
  143. // this.money = data.commissionCount;
  144. // });
  145. },
  146. methods: {
  147. ...mapMutations('user', ['setUserInfo']),
  148. navto(e) {
  149. uni.navigateTo({
  150. url: e
  151. });
  152. },
  153. getUserInfo() {
  154. getUserInfo({}).then(({
  155. data
  156. }) => {
  157. this.userInfo = data
  158. });
  159. },
  160. async loadData(source) {
  161. const obj = this;
  162. //这里时将订单挂载到tab列表下
  163. let index = this.tabCurrentIndex;
  164. let navItem = this.navList[index];
  165. let state = navItem.state;
  166. if (source === 'tabChange' && navItem.loaded === true) {
  167. //tab切换只有第一次需要加载数据
  168. return;
  169. }
  170. if (navItem.loadingType === 'loading') {
  171. //防止重复加载
  172. return;
  173. }
  174. //修改当前对象状态为加载中
  175. navItem.loadingType = 'loading';
  176. spreadCommission({
  177. page: navItem.page,
  178. limit: navItem.limit,
  179. }, state)
  180. .then(({
  181. data
  182. }) => {
  183. if (data.length > 0) {
  184. navItem.orderList = navItem.orderList.concat(data[0].list);
  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. background: linear-gradient(-84deg, #235144 0%, #3a8a74 100%);
  257. -webkit-background-clip: text;
  258. -webkit-text-fill-color: transparent;
  259. height: 80rpx;
  260. font-size: 36rpx;
  261. font-weight: 700;
  262. z-index: 9;
  263. display: flex;
  264. justify-content: center;
  265. align-items: center;
  266. }
  267. .goback-box {
  268. position: absolute;
  269. left: 18rpx;
  270. top: 0;
  271. height: 80rpx;
  272. display: flex;
  273. align-items: center;
  274. }
  275. .goback {
  276. z-index: 100;
  277. width: 34rpx;
  278. height: 34rpx;
  279. }
  280. }
  281. }
  282. .money-box {
  283. position: relative;
  284. z-index: 2;
  285. padding-top: 70rpx;
  286. color: #ffffff;
  287. background: linear-gradient(-84deg, #235144 0%, #3a8a74 100%);
  288. -webkit-background-clip: text;
  289. -webkit-text-fill-color: transparent;
  290. text-align: center;
  291. .money {
  292. font-size: 72rpx;
  293. font-family: PingFang SC;
  294. font-weight: bold;
  295. color: #ffffff;
  296. }
  297. .text {
  298. font-size: 30rpx;
  299. }
  300. }
  301. .moneybtn-box {
  302. display: flex;
  303. justify-content: space-between;
  304. position: relative;
  305. z-index: 2;
  306. color: #ffffff;
  307. background: linear-gradient(-84deg, #235144 0%, #3a8a74 100%);
  308. -webkit-background-clip: text;
  309. -webkit-text-fill-color: transparent;
  310. padding: 20rpx 50rpx;
  311. font-size: 30rpx;
  312. font-family: PingFang SC;
  313. font-weight: bold;
  314. color: #ffffff;
  315. }
  316. .navbar {
  317. margin-top: 25rpx;
  318. display: flex;
  319. height: 40px;
  320. padding: 0 5px;
  321. background: #fff;
  322. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  323. position: relative;
  324. z-index: 10;
  325. .nav-item {
  326. flex: 1;
  327. display: flex;
  328. justify-content: center;
  329. align-items: center;
  330. height: 100%;
  331. font-size: 15px;
  332. color: $font-color-dark;
  333. position: relative;
  334. &.current {
  335. color: #000;
  336. font-weight: bold;
  337. &:after {
  338. content: '';
  339. position: absolute;
  340. left: 50%;
  341. bottom: 0;
  342. transform: translateX(-50%);
  343. width: 44px;
  344. height: 0;
  345. border-bottom: 2px solid #418C78;
  346. }
  347. }
  348. }
  349. }
  350. //列表
  351. .swiper-box {
  352. .order-item {
  353. padding: 20rpx 30rpx;
  354. line-height: 1.5;
  355. .title-box {
  356. .title {
  357. font-size: $font-lg;
  358. color: $font-color-base;
  359. }
  360. .time {
  361. font-size: $font-base;
  362. color: $font-color-light;
  363. }
  364. }
  365. .money {
  366. color: rgba(239, 58, 85, 1);
  367. font-size: $font-lg;
  368. }
  369. }
  370. }
  371. .info-box {
  372. width: 670rpx;
  373. height: 186rpx;
  374. background: #ffffff;
  375. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  376. border-radius: 20rpx;
  377. margin: -100rpx auto 0;
  378. position: relative;
  379. z-index: 2;
  380. .info-item {
  381. width: 50%;
  382. display: flex;
  383. flex-direction: column;
  384. align-items: center;
  385. line-height: 1;
  386. .info-font {
  387. font-size: 30rpx;
  388. font-family: PingFang SC;
  389. font-weight: bold;
  390. color: #999999;
  391. }
  392. .info-num {
  393. margin-top: 30rpx;
  394. font-size: 30rpx;
  395. font-family: PingFang SC;
  396. font-weight: bold;
  397. color: #181818;
  398. }
  399. }
  400. .shu {
  401. width: 2rpx;
  402. height: 74rpx;
  403. background: #dcdfe6;
  404. }
  405. }
  406. .list-scroll-content {
  407. background-color: #ffffff;
  408. height: 100%;
  409. }
  410. .content {
  411. height: 100%;
  412. .empty-content {
  413. background-color: #ffffff;
  414. }
  415. }
  416. .btm-wrap {
  417. height: 140rpx;
  418. width: 750rpx;
  419. position: fixed;
  420. bottom: 0;
  421. left: 0;
  422. background-color: #fff;
  423. .btn {
  424. width: 674rpx;
  425. height: 88rpx;
  426. line-height: 88rpx;
  427. margin: auto;
  428. background: linear-gradient(-22deg, #9a5e19, #9a5e19);
  429. border-radius: 44rpx;
  430. text-align: center;
  431. font-size: 36rpx;
  432. font-family: PingFang SC;
  433. font-weight: 500;
  434. color: #ffffff;
  435. }
  436. }
  437. </style>