wallet.vue 11 KB

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