award.vue 7.2 KB

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