award.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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="moneyTx" @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?type=brokerage_price')">立即提现</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. console.log(e);
  128. uni.navigateTo({
  129. url: e
  130. });
  131. },
  132. //返回上一页面
  133. toBack() {
  134. console.log(111);
  135. uni.navigateBack({});
  136. },
  137. //获取收入支出信息
  138. async loadData(source) {
  139. //这里是将订单挂载到tab列表下
  140. let index = this.tabCurrentIndex;
  141. let navItem = this.navList[index];
  142. let state = navItem.state + 3;
  143. if (source === 'tabChange' && navItem.loaded === true) {
  144. //tab切换只有第一次需要加载数据
  145. return;
  146. }
  147. if (navItem.loadingType === 'loading') {
  148. //防止重复加载
  149. return;
  150. }
  151. // 修改当前对象状态为加载中
  152. navItem.loadingType = 'loading';
  153. spreadCommission(
  154. {
  155. page: navItem.page,
  156. limit: navItem.limit
  157. },
  158. state
  159. )
  160. .then(({ data }) => {
  161. if (data.length > 0) {
  162. navItem.orderList = navItem.orderList.concat(data[0].list);
  163. console.log(navItem.orderList);
  164. navItem.page++;
  165. }
  166. if (navItem.limit == data.length) {
  167. //判断是否还有数据, 有改为 more, 没有改为noMore
  168. navItem.loadingType = 'more';
  169. return;
  170. } else {
  171. //判断是否还有数据, 有改为 more, 没有改为noMore
  172. navItem.loadingType = 'noMore';
  173. }
  174. uni.hideLoading();
  175. this.$set(navItem, 'loaded', true);
  176. })
  177. .catch(e => {
  178. console.log(e);
  179. });
  180. },
  181. //swiper 切换
  182. changeTab(e) {
  183. this.tabCurrentIndex = e.target.current;
  184. this.loadData('tabChange');
  185. },
  186. //顶部tab点击
  187. tabClick(index) {
  188. this.tabCurrentIndex = index;
  189. }
  190. }
  191. };
  192. </script>
  193. <style lang="scss">
  194. page {
  195. background: #ffffff;
  196. height: 100%;
  197. }
  198. .content-money {
  199. padding-bottom: 30rpx;
  200. background: $page-color-base;
  201. .moneyTx {
  202. position: absolute;
  203. z-index: 10;
  204. top: 150rpx;
  205. right: 0rpx;
  206. width: 160rpx;
  207. padding: 10rpx 30rpx;
  208. border: 2px solid #ffffff;
  209. border-top-left-radius: 99rpx;
  210. border-bottom-left-radius: 99rpx;
  211. color: #ffffff;
  212. line-height: 1;
  213. font-size: $font-base;
  214. }
  215. }
  216. .money-box {
  217. background-color: $base-color;
  218. padding-top: var(--status-bar-height);
  219. height: 468rpx;
  220. color: #ffffff;
  221. text-align: center;
  222. justify-content: center;
  223. position: relative;
  224. .body-title {
  225. height: 80rpx;
  226. text-align: center;
  227. font-size: 35rpx;
  228. position: relative;
  229. .header {
  230. position: absolute;
  231. left: 0;
  232. top: 0;
  233. width: 100%;
  234. font-size: 36rpx;
  235. font-family: PingFang SC;
  236. font-weight: bold;
  237. color: #fffeff;
  238. height: 80rpx;
  239. font-size: 32rpx;
  240. font-weight: 700;
  241. z-index: 9;
  242. display: flex;
  243. justify-content: center;
  244. align-items: center;
  245. }
  246. .goback-box {
  247. position: absolute;
  248. z-index: 10;
  249. left: 24rpx;
  250. top: 0;
  251. height: 80rpx;
  252. display: flex;
  253. align-items: center;
  254. }
  255. .goback {
  256. width: 30rpx;
  257. height: 36rpx;
  258. }
  259. }
  260. .bg {
  261. position: absolute;
  262. top: 0;
  263. left: 0;
  264. width: 100%;
  265. height: 100%;
  266. image {
  267. width: 100%;
  268. height: 100%;
  269. }
  270. }
  271. .money {
  272. position: relative;
  273. z-index: 10;
  274. font-size: 56rpx;
  275. height: 388rpx;
  276. line-height: 288rpx;
  277. }
  278. }
  279. .navbar {
  280. display: flex;
  281. height: 40px;
  282. padding: 0 5px;
  283. background: #fff;
  284. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  285. position: relative;
  286. z-index: 10;
  287. .nav-item {
  288. flex: 1;
  289. display: flex;
  290. justify-content: center;
  291. align-items: center;
  292. height: 100%;
  293. font-size: 15px;
  294. color: $font-color-dark;
  295. position: relative;
  296. &.current {
  297. color: $base-color;
  298. &:after {
  299. content: '';
  300. position: absolute;
  301. left: 50%;
  302. bottom: 0;
  303. transform: translateX(-50%);
  304. width: 44px;
  305. height: 0;
  306. border-bottom: 2px solid $base-color;
  307. }
  308. }
  309. }
  310. }
  311. // 列表
  312. .swiper-box {
  313. padding-top: 10rpx;
  314. .order-item {
  315. padding: 20rpx 30rpx;
  316. line-height: 1.5;
  317. .title-box {
  318. .title {
  319. font-size: $font-lg;
  320. color: $font-color-base;
  321. }
  322. .time {
  323. font-size: $font-base;
  324. color: $font-color-light;
  325. }
  326. }
  327. .money {
  328. color: #fd5b23;
  329. font-size: $font-lg;
  330. }
  331. }
  332. }
  333. .list-scroll-content {
  334. height: 100%;
  335. }
  336. .content {
  337. height: 100%;
  338. .empty-content {
  339. background-color: #ffffff;
  340. }
  341. }
  342. .btn {
  343. position: fixed;
  344. bottom: 40rpx;
  345. left: 50%;
  346. width: 674rpx;
  347. height: 88rpx;
  348. background: #52c696;
  349. border-radius: 44rpx;
  350. margin-left: -337rpx;
  351. font-size: 36rpx;
  352. font-family: PingFang SC;
  353. font-weight: bold;
  354. text-align: center;
  355. line-height: 88rpx;
  356. color: #ffffff;
  357. }
  358. </style>