profit.vue 6.5 KB

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