wallet.vue 9.3 KB

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