wallet.vue 9.3 KB

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