wallet.vue 9.4 KB

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