award.vue 9.4 KB

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