award.vue 9.3 KB

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