profit.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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 class="moneyTx" @click="navto('./withdrawal')">提现</view>
  10. <view class="flex buttom-box">
  11. <view class="buttom" @click="navto('/pages/money/recharge')">
  12. <view class="icon"><image src="/static/icon/i6.png" mode="aspectFill" class="icon-img"></image></view>
  13. <text>统计</text>
  14. </view>
  15. <view class="interval"></view>
  16. <view class="buttom" @click="navto('./withdrawal')">
  17. <view class="icon"><image src="/static/icon/i7.png" mode="aspectFill" class="icon-img"></image></view>
  18. <text>提现</text>
  19. </view>
  20. </view> -->
  21. </view>
  22. <view class="navbar">
  23. <view v-for="(item,index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index}" @click="tabClick(index)">{{ item.text }}</view>
  24. </view>
  25. <swiper :current="tabCurrentIndex" :style="{'height':maxheight+'px'}" class="swiper-box" duration="300" @change="changeTab">
  26. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  27. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  28. <!-- 空白页 -->
  29. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  30. <!-- 订单列表 -->
  31. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  32. <view class="title-box">
  33. <view class="title">
  34. <text>{{ item.title }}</text>
  35. </view>
  36. <view class="time">
  37. <text>{{ item.add_time }}</text>
  38. </view>
  39. </view>
  40. <view class="money">
  41. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  42. </view>
  43. </view>
  44. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  45. </scroll-view>
  46. </swiper-item>
  47. </swiper>
  48. </view>
  49. </template>
  50. <script>
  51. import { spreadCommission, userBalance } from '@/api/wallet.js';
  52. import { mapState, mapMutations } from 'vuex';
  53. import { getMoneyStyle } from '@/utils/rocessor.js';
  54. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  55. import empty from '@/components/empty';
  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. methods: {
  116. navto(e) {
  117. uni.navigateTo({
  118. url: e
  119. });
  120. },
  121. async loadData(source) {
  122. //这里时将订单挂载到tab列表下
  123. let index = this.tabCurrentIndex;
  124. let navItem = this.navList[index];
  125. let state = navItem.state+3;
  126. if (source === 'tabChange' && navItem.loaded === true) {
  127. //tab切换只有第一次需要加载数据
  128. return;
  129. }
  130. if (navItem.loadingType === 'loading') {
  131. //防止重复加载
  132. return;
  133. }
  134. //修改当前对象状态为加载中
  135. navItem.loadingType = 'loading';
  136. spreadCommission(
  137. {
  138. page: navItem.page,
  139. limit: navItem.limit
  140. },
  141. state
  142. )
  143. .then(({ data }) => {
  144. if(data.length > 0) {
  145. navItem.orderList = navItem.orderList.concat(data[0].list);
  146. console.log(navItem.orderList);
  147. navItem.page++;
  148. }
  149. //判断是否还有数据, 有改为more, 没有改为noMore
  150. if (navItem.limit == data.length) {
  151. navItem.loadingType = 'more';
  152. return;
  153. } else {
  154. navItem.loadingType = 'noMore';
  155. }
  156. uni.hideLoading();
  157. this.$set(navItem, 'loaded', true);
  158. })
  159. .catch(e => {
  160. console.log(e);
  161. });
  162. },
  163. //swiper 切换
  164. changeTab(e) {
  165. this.tabCurrentIndex = e.target.current;
  166. this.loadData('tabChange');
  167. },
  168. //顶部tab点击
  169. tabClick(index) {
  170. this.tabCurrentIndex = index;
  171. }
  172. }
  173. }
  174. </script>
  175. <style lang="scss">
  176. page {
  177. background: #000;
  178. height: 100%;
  179. }
  180. .content-money {
  181. padding-bottom: 30rpx;
  182. background: $page-color-base;
  183. position: relative;
  184. .bg{
  185. position: absolute;
  186. width: 100%;
  187. }
  188. .moneyTx{
  189. position: absolute;
  190. top: 150rpx;
  191. right: 0rpx;
  192. width: 150rpx;
  193. padding: 10rpx 30rpx;
  194. border: 2px solid #FFFFFF;
  195. border-top-left-radius: 99rpx;
  196. border-bottom-left-radius: 99rpx;
  197. color: #FFFFFF;
  198. line-height: 1;
  199. font-size: $font-base;
  200. }
  201. .buttom-box {
  202. background-color: #ffffff;
  203. text-align: center;
  204. margin: 0 30rpx;
  205. padding: 20rpx 0;
  206. border-radius: $border-radius-sm;
  207. margin-top: -60rpx;
  208. .buttom {
  209. font-size: $font-lg;
  210. flex-grow: 1;
  211. }
  212. .interval {
  213. width: 2px;
  214. height: 60rpx;
  215. background-color: #eeeeee;
  216. }
  217. .icon {
  218. height: 50rpx;
  219. width: 48rpx;
  220. margin: 0 auto;
  221. .icon-img {
  222. width: 100%;
  223. height: 100%;
  224. }
  225. }
  226. }
  227. }
  228. .money-box {
  229. // background-color: $base-color;
  230. padding-top: var(--status-bar-height);
  231. height: 368rpx;
  232. color: #FAD6B0;
  233. text-align: center;
  234. position: relative;
  235. .text {
  236. padding-top: 147rpx;
  237. font-size: $font-sm;
  238. }
  239. .money {
  240. font-size: 47px;
  241. font-family: PingFang SC;
  242. font-weight: bold;
  243. text {
  244. font-size: 24px;
  245. }
  246. }
  247. }
  248. .navbar {
  249. display: flex;
  250. height: 40px;
  251. padding: 0 5px;
  252. background: #000;
  253. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  254. position: relative;
  255. z-index: 10;
  256. .nav-item {
  257. flex: 1;
  258. display: flex;
  259. justify-content: center;
  260. align-items: center;
  261. height: 100%;
  262. font-size: 15px;
  263. color: #999999;
  264. position: relative;
  265. &.current {
  266. color: $base-color;
  267. &:after {
  268. content: '';
  269. position: absolute;
  270. left: 50%;
  271. bottom: 0;
  272. transform: translateX(-50%);
  273. width: 44px;
  274. height: 0;
  275. border-bottom: 2px solid $base-color;
  276. }
  277. }
  278. }
  279. }
  280. //列表
  281. .swiper-box {
  282. padding-top: 10rpx;
  283. .order-item {
  284. padding: 20rpx 30rpx;
  285. line-height: 1.5;
  286. .title-box {
  287. .title {
  288. font-size: $font-lg;
  289. color: $font-color-base;
  290. }
  291. .time {
  292. font-size: $font-base;
  293. color: $font-color-light;
  294. }
  295. }
  296. .money {
  297. color: #fd5b23;
  298. font-size: $font-lg;
  299. }
  300. }
  301. }
  302. .list-scroll-content {
  303. height: 100%;
  304. }
  305. .content {
  306. height: 100%;
  307. .empty-content {
  308. background-color: #ffffff;
  309. }
  310. }
  311. </style>