award.vue 7.0 KB

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