tradeList.vue 9.1 KB

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