award.vue 7.2 KB

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