award.vue 6.8 KB

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