award.vue 9.3 KB

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