award.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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 } 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. userBalance({}).then(({ data }) => {
  111. this.money = data.commissionCount;
  112. });
  113. },
  114. methods: {
  115. navto(e) {
  116. uni.navigateTo({
  117. url: e
  118. });
  119. },
  120. async loadData(source) {
  121. //这里时将订单挂载到tab列表下
  122. let index = this.tabCurrentIndex;
  123. let navItem = this.navList[index];
  124. let state = navItem.state+3;
  125. if (source === 'tabChange' && navItem.loaded === true) {
  126. //tab切换只有第一次需要加载数据
  127. return;
  128. }
  129. if (navItem.loadingType === 'loading') {
  130. //防止重复加载
  131. return;
  132. }
  133. //修改当前对象状态为加载中
  134. navItem.loadingType = 'loading';
  135. spreadCommission(
  136. {
  137. page: navItem.page,
  138. limit: navItem.limit
  139. },
  140. state
  141. )
  142. .then(({ data }) => {
  143. if(data.length > 0) {
  144. navItem.orderList = navItem.orderList.concat(data[0].list);
  145. console.log(navItem.orderList);
  146. navItem.page++;
  147. }
  148. //判断是否还有数据, 有改为more, 没有改为noMore
  149. if (navItem.limit == data.length) {
  150. navItem.loadingType = 'more';
  151. return;
  152. } else {
  153. navItem.loadingType = 'noMore';
  154. }
  155. uni.hideLoading();
  156. this.$set(navItem, 'loaded', true);
  157. })
  158. .catch(e => {
  159. console.log(e);
  160. });
  161. },
  162. //swiper 切换
  163. changeTab(e) {
  164. this.tabCurrentIndex = e.target.current;
  165. this.loadData('tabChange');
  166. },
  167. //顶部tab点击
  168. tabClick(index) {
  169. this.tabCurrentIndex = index;
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss">
  175. page {
  176. background: #ffffff;
  177. height: 100%;
  178. }
  179. .content-money {
  180. padding-bottom: 30rpx;
  181. background: $page-color-base;
  182. .moneyTx{
  183. position: absolute;
  184. top: 150rpx;
  185. right: 0rpx;
  186. width: 150rpx;
  187. padding: 10rpx 30rpx;
  188. border: 2px solid #FFFFFF;
  189. border-top-left-radius: 99rpx;
  190. border-bottom-left-radius: 99rpx;
  191. color: #FFFFFF;
  192. line-height: 1;
  193. font-size: $font-base;
  194. }
  195. .buttom-box {
  196. background-color: #ffffff;
  197. text-align: center;
  198. margin: 0 30rpx;
  199. padding: 20rpx 0;
  200. border-radius: $border-radius-sm;
  201. margin-top: -60rpx;
  202. .buttom {
  203. font-size: $font-lg;
  204. flex-grow: 1;
  205. }
  206. .interval {
  207. width: 2px;
  208. height: 60rpx;
  209. background-color: #eeeeee;
  210. }
  211. .icon {
  212. height: 50rpx;
  213. width: 48rpx;
  214. margin: 0 auto;
  215. .icon-img {
  216. width: 100%;
  217. height: 100%;
  218. }
  219. }
  220. }
  221. }
  222. .money-box {
  223. background-color: $base-color;
  224. padding-top: var(--status-bar-height);
  225. height: 368rpx;
  226. color: #ffffff;
  227. text-align: center;
  228. .text {
  229. padding-top: 147rpx;
  230. font-size: $font-sm;
  231. }
  232. .money {
  233. font-size: 56rpx;
  234. }
  235. }
  236. .navbar {
  237. display: flex;
  238. height: 40px;
  239. padding: 0 5px;
  240. background: #fff;
  241. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  242. position: relative;
  243. z-index: 10;
  244. .nav-item {
  245. flex: 1;
  246. display: flex;
  247. justify-content: center;
  248. align-items: center;
  249. height: 100%;
  250. font-size: 15px;
  251. color: $font-color-dark;
  252. position: relative;
  253. &.current {
  254. color: $base-color;
  255. &:after {
  256. content: '';
  257. position: absolute;
  258. left: 50%;
  259. bottom: 0;
  260. transform: translateX(-50%);
  261. width: 44px;
  262. height: 0;
  263. border-bottom: 2px solid $base-color;
  264. }
  265. }
  266. }
  267. }
  268. //列表
  269. .swiper-box {
  270. padding-top: 10rpx;
  271. .order-item {
  272. padding: 20rpx 30rpx;
  273. line-height: 1.5;
  274. .title-box {
  275. .title {
  276. font-size: $font-lg;
  277. color: $font-color-base;
  278. }
  279. .time {
  280. font-size: $font-base;
  281. color: $font-color-light;
  282. }
  283. }
  284. .money {
  285. color: #fd5b23;
  286. font-size: $font-lg;
  287. }
  288. }
  289. }
  290. .list-scroll-content {
  291. height: 100%;
  292. }
  293. .content {
  294. height: 100%;
  295. .empty-content {
  296. background-color: #ffffff;
  297. }
  298. }
  299. </style>