award.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <view class="bg"><image src="../../static/img/yong.png" mode=""></image></view>
  6. <view class="body-title">
  7. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
  8. <view class="header">我的佣金</view>
  9. </view>
  10. <view>
  11. <view class="money">{{ money | getMoneyStyle }}</view>
  12. </view>
  13. </view>
  14. <!-- <view class="moneyTx" @click="navto('./withdrawal')">提现</view> -->
  15. <!-- <view class="moneyTxs" @click="navto('./withdmoenys')" >转余额</view> -->
  16. <!-- <view class="flex buttom-box">
  17. <view class="buttom" @click="navto('./withdrawal')">
  18. <view class="icon"><image class="icon-img" src="/static/icon/i6.png" mode="aspectFit"></image></view>
  19. <text class="font-size-sm">提现</text>
  20. </view>
  21. <view class="interval"></view>
  22. <view class="buttom" @click="navto('./withdmoenys')">
  23. <view class="icon"><image class="icon-img" src="/static/icon/i7.png" mode="aspectFit"></image></view>
  24. <text class="font-size-sm">转余额</text>
  25. </view>
  26. </view> -->
  27. </view>
  28. <view class="navbar">
  29. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  30. </view>
  31. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'px' }" class="swiper-box" duration="300" @change="changeTab">
  32. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  33. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  34. <!-- 空白页 -->
  35. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  36. <!-- 订单列表 -->
  37. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  38. <view class="title-box">
  39. <view class="title">
  40. <text>{{ item.title }}</text>
  41. </view>
  42. <view class="time">
  43. <text>{{ item.add_time }}</text>
  44. </view>
  45. </view>
  46. <view class="money">
  47. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  48. </view>
  49. </view>
  50. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  51. </scroll-view>
  52. </swiper-item>
  53. </swiper>
  54. <view class="btn" @click="navto('/pages/award/withdrawal')">立即提现</view>
  55. </view>
  56. </template>
  57. <script>
  58. import { spreadCommission, extractBank } from '@/api/wallet.js';
  59. import { mapState, mapMutations } from 'vuex';
  60. import { getMoneyStyle } from '@/utils/rocessor.js';
  61. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  62. import empty from '@/components/empty';
  63. export default {
  64. filters: {
  65. getMoneyStyle
  66. },
  67. components: {
  68. empty,
  69. uniLoadMore
  70. },
  71. onReady() {
  72. // 初始化获取页面宽度
  73. uni.createSelectorQuery()
  74. .select('.content')
  75. .fields(
  76. {
  77. size: true
  78. },
  79. data => {
  80. // 保存头部高度
  81. this.maxheight = data.height - Math.floor((data.width / 750) * 570);
  82. console.log(this.maxheight);
  83. }
  84. )
  85. .exec();
  86. },
  87. data() {
  88. return {
  89. // 头部图高度
  90. maxheight: '',
  91. tabCurrentIndex: 0,
  92. navList: [
  93. {
  94. state: 0,
  95. text: '收入',
  96. loadingType: 'more',
  97. orderList: [],
  98. page: 1, //当前页数
  99. limit: 10 //每次信息条数
  100. },
  101. {
  102. state: 1,
  103. text: '支出',
  104. loadingType: 'more',
  105. orderList: [],
  106. page: 1, //当前页数
  107. limit: 10 //每次信息条数
  108. }
  109. ],
  110. money: '', //可提现佣金
  111. freezeMoney: '' //冻结中的佣金
  112. };
  113. },
  114. onLoad(options) {},
  115. onShow() {
  116. this.loadData();
  117. // 获取用户余额
  118. extractBank({}).then(({ data }) => {
  119. this.money = data.brokerage_price;
  120. // 冻结佣金
  121. this.freezeMoney = data.freezePrice;
  122. });
  123. },
  124. methods: {
  125. // 页面跳转
  126. navto(e) {
  127. uni.navigateTo({
  128. url: e
  129. });
  130. },
  131. //返回上一页面
  132. toBack() {
  133. console.log(111);
  134. uni.navigateBack({});
  135. },
  136. //获取收入支出信息
  137. async loadData(source) {
  138. //这里是将订单挂载到tab列表下
  139. let index = this.tabCurrentIndex;
  140. let navItem = this.navList[index];
  141. let state = navItem.state + 3;
  142. if (source === 'tabChange' && navItem.loaded === true) {
  143. //tab切换只有第一次需要加载数据
  144. return;
  145. }
  146. if (navItem.loadingType === 'loading') {
  147. //防止重复加载
  148. return;
  149. }
  150. // 修改当前对象状态为加载中
  151. navItem.loadingType = 'loading';
  152. spreadCommission(
  153. {
  154. page: navItem.page,
  155. limit: navItem.limit
  156. },
  157. state
  158. )
  159. .then(({ data }) => {
  160. if (data.length > 0) {
  161. navItem.orderList = navItem.orderList.concat(data[0].list);
  162. console.log(navItem.orderList);
  163. navItem.page++;
  164. }
  165. if (navItem.limit == data.length) {
  166. //判断是否还有数据, 有改为 more, 没有改为noMore
  167. navItem.loadingType = 'more';
  168. return;
  169. } else {
  170. //判断是否还有数据, 有改为 more, 没有改为noMore
  171. navItem.loadingType = 'noMore';
  172. }
  173. uni.hideLoading();
  174. this.$set(navItem, 'loaded', true);
  175. })
  176. .catch(e => {
  177. console.log(e);
  178. });
  179. },
  180. //swiper 切换
  181. changeTab(e) {
  182. this.tabCurrentIndex = e.target.current;
  183. this.loadData('tabChange');
  184. },
  185. //顶部tab点击
  186. tabClick(index) {
  187. this.tabCurrentIndex = index;
  188. }
  189. }
  190. };
  191. </script>
  192. <style lang="scss">
  193. page {
  194. background: #ffffff;
  195. height: 100%;
  196. }
  197. .content-money {
  198. padding-bottom: 30rpx;
  199. background: $page-color-base;
  200. }
  201. .money-box {
  202. background-color: $base-color;
  203. padding-top: var(--status-bar-height);
  204. height: 468rpx;
  205. color: #ffffff;
  206. text-align: center;
  207. justify-content: center;
  208. position: relative;
  209. .body-title {
  210. height: 80rpx;
  211. text-align: center;
  212. font-size: 35rpx;
  213. position: relative;
  214. .header {
  215. position: absolute;
  216. left: 0;
  217. top: 0;
  218. width: 100%;
  219. font-size: 36rpx;
  220. font-family: PingFang SC;
  221. font-weight: bold;
  222. color: #fffeff;
  223. height: 80rpx;
  224. font-size: 32rpx;
  225. font-weight: 700;
  226. z-index: 9;
  227. display: flex;
  228. justify-content: center;
  229. align-items: center;
  230. }
  231. .goback-box {
  232. position: absolute;
  233. z-index: 10;
  234. left: 24rpx;
  235. top: 0;
  236. height: 80rpx;
  237. display: flex;
  238. align-items: center;
  239. }
  240. .goback {
  241. width: 30rpx;
  242. height: 36rpx;
  243. }
  244. }
  245. .bg {
  246. position: absolute;
  247. top: 0;
  248. left: 0;
  249. width: 100%;
  250. height: 100%;
  251. image {
  252. width: 100%;
  253. height: 100%;
  254. }
  255. }
  256. .money {
  257. position: relative;
  258. z-index: 10;
  259. font-size: 56rpx;
  260. height: 388rpx;
  261. line-height: 288rpx;
  262. }
  263. }
  264. .navbar {
  265. display: flex;
  266. height: 40px;
  267. padding: 0 5px;
  268. background: #fff;
  269. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  270. position: relative;
  271. z-index: 10;
  272. .nav-item {
  273. flex: 1;
  274. display: flex;
  275. justify-content: center;
  276. align-items: center;
  277. height: 100%;
  278. font-size: 15px;
  279. color: $font-color-dark;
  280. position: relative;
  281. &.current {
  282. color: $base-color;
  283. &:after {
  284. content: '';
  285. position: absolute;
  286. left: 50%;
  287. bottom: 0;
  288. transform: translateX(-50%);
  289. width: 44px;
  290. height: 0;
  291. border-bottom: 2px solid $base-color;
  292. }
  293. }
  294. }
  295. }
  296. // 列表
  297. .swiper-box {
  298. padding-top: 10rpx;
  299. .order-item {
  300. padding: 20rpx 30rpx;
  301. line-height: 1.5;
  302. .title-box {
  303. .title {
  304. font-size: $font-lg;
  305. color: $font-color-base;
  306. }
  307. .time {
  308. font-size: $font-base;
  309. color: $font-color-light;
  310. }
  311. }
  312. .money {
  313. color: #fd5b23;
  314. font-size: $font-lg;
  315. }
  316. }
  317. }
  318. .list-scroll-content {
  319. height: 100%;
  320. }
  321. .content {
  322. height: 100%;
  323. .empty-content {
  324. background-color: #ffffff;
  325. }
  326. }
  327. .btn {
  328. position: fixed;
  329. bottom: 40rpx;
  330. left: 50%;
  331. width: 674rpx;
  332. height: 88rpx;
  333. background: #52c696;
  334. border-radius: 44rpx;
  335. margin-left: -337rpx;
  336. font-size: 36rpx;
  337. font-family: PingFang SC;
  338. font-weight: bold;
  339. text-align: center;
  340. line-height: 88rpx;
  341. color: #ffffff;
  342. }
  343. </style>