wallet.vue 9.1 KB

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