wallet.vue 10 KB

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