wallet.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="status_bar"><!-- 这里是状态栏 --></view>
  5. <view class="body-title">
  6. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
  7. <view class="header">我的佣金</view>
  8. </view>
  9. <view class="content-bg"><image src="../../static/img/myYong.png" mode=""></image></view>
  10. <view class="money-box">
  11. <view class="money">
  12. <text>¥</text>
  13. {{ userInfo.brokerage_price }}
  14. </view>
  15. </view>
  16. </view>
  17. <view class="navbar">
  18. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  19. </view>
  20. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  21. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  22. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  23. <!-- 空白页 -->
  24. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  25. <!-- 订单列表 -->
  26. <view>
  27. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  28. <view class="title-box">
  29. <view class="title">
  30. <text>{{ item.title }}</text>
  31. </view>
  32. <view class="time">
  33. <text>{{ item.add_time }}</text>
  34. </view>
  35. </view>
  36. <view class="money">
  37. <view>{{ (item.pm == 0 ? '-' : '+') + item.number }}</view>
  38. <view v-if="item.status == 0" class="status">待发放</view>
  39. </view>
  40. </view>
  41. </view>
  42. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  43. </scroll-view>
  44. </swiper-item>
  45. </swiper>
  46. <view class="btn-box" @click="navto('/pages/money/withdrawal')">立即提现</view>
  47. </view>
  48. </template>
  49. <script>
  50. import { spreadCommission, userBalance } from '@/api/wallet.js';
  51. import { getMoneyStyle } from '@/utils/rocessor.js';
  52. import { mapState, mapMutations } from 'vuex';
  53. import uniLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue';
  54. import empty from '@/uview-ui/components/u-empty/u-empty.vue';
  55. export default {
  56. filters: {
  57. getMoneyStyle
  58. },
  59. computed: {
  60. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  61. },
  62. components: {
  63. empty,
  64. uniLoadMore
  65. },
  66. onReady(res) {
  67. var _this = this;
  68. uni.getSystemInfo({
  69. success: resu => {
  70. const query = uni.createSelectorQuery();
  71. query.select('.swiper-box').boundingClientRect();
  72. query.exec(function(res) {
  73. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  74. console.log('打印页面的剩余高度', _this.height);
  75. });
  76. },
  77. fail: res => {}
  78. });
  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. methods: {
  111. // 页面跳转
  112. navto(e) {
  113. uni.navigateTo({
  114. url: e
  115. });
  116. },
  117. // 点击返回 我的页面
  118. toBack() {
  119. uni.navigateBack({});
  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. if (navItem.limit == data.length) {
  151. //判断是否还有数据, 有改为 more, 没有改为noMore
  152. navItem.loadingType = 'more';
  153. return;
  154. } else {
  155. //判断是否还有数据, 有改为 more, 没有改为noMore
  156. navItem.loadingType = 'noMore';
  157. }
  158. uni.hideLoading();
  159. this.$set(navItem, 'loaded', true);
  160. })
  161. .catch(e => {
  162. console.log(e);
  163. });
  164. },
  165. //swiper 切换
  166. changeTab(e) {
  167. this.tabCurrentIndex = e.target.current;
  168. this.loadData('tabChange');
  169. },
  170. //顶部tab点击
  171. tabClick(index) {
  172. this.tabCurrentIndex = index;
  173. }
  174. }
  175. };
  176. </script>
  177. <style lang="scss">
  178. page {
  179. background: #f1f1f1;
  180. height: 100%;
  181. }
  182. .status_bar {
  183. height: var(--status-bar-height);
  184. width: 100%;
  185. }
  186. .content-money {
  187. padding-bottom: 30rpx;
  188. position: relative;
  189. height: 480rpx;
  190. .content-bg {
  191. position: absolute;
  192. top: 0;
  193. left: 0;
  194. right: 0;
  195. width: 750rpx;
  196. height: 480rpx;
  197. image {
  198. width: 100%;
  199. height: 100%;
  200. }
  201. }
  202. .body-title {
  203. height: 80rpx;
  204. text-align: center;
  205. font-size: 35rpx;
  206. position: relative;
  207. .header {
  208. position: absolute;
  209. left: 0;
  210. top: 0;
  211. width: 100%;
  212. font-size: 36rpx;
  213. font-family: PingFang SC;
  214. font-weight: bold;
  215. color: #fffeff;
  216. height: 80rpx;
  217. font-size: 36rpx;
  218. font-weight: 700;
  219. z-index: 9;
  220. display: flex;
  221. justify-content: center;
  222. align-items: center;
  223. }
  224. .goback-box {
  225. position: absolute;
  226. left: 18rpx;
  227. top: 0;
  228. height: 80rpx;
  229. display: flex;
  230. align-items: center;
  231. }
  232. .goback {
  233. z-index: 100;
  234. width: 34rpx;
  235. height: 34rpx;
  236. }
  237. }
  238. }
  239. .money-box {
  240. position: relative;
  241. z-index: 100;
  242. padding-top: 80rpx;
  243. color: #ffffff;
  244. text-align: center;
  245. .money {
  246. font-size: 86rpx;
  247. font-family: PingFang SC;
  248. font-weight: bold;
  249. color: #ffffff;
  250. text {
  251. font-size: 42rpx;
  252. }
  253. }
  254. }
  255. .navbar {
  256. margin-top: 20rpx;
  257. display: flex;
  258. height: 88rpx;
  259. padding: 0 5px;
  260. background: #fff;
  261. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  262. position: relative;
  263. z-index: 10;
  264. .nav-item {
  265. flex: 1;
  266. display: flex;
  267. justify-content: center;
  268. align-items: center;
  269. height: 100%;
  270. font-size: 15px;
  271. color: $font-color-dark;
  272. position: relative;
  273. &.current {
  274. color: $base-color;
  275. &:after {
  276. content: '';
  277. position: absolute;
  278. left: 50%;
  279. bottom: 0;
  280. transform: translateX(-50%);
  281. width: 44px;
  282. height: 0;
  283. border-bottom: 2px solid $base-color;
  284. }
  285. }
  286. }
  287. }
  288. //列表
  289. .swiper-box {
  290. .order-item:last-child {
  291. margin-bottom: 60rpx;
  292. }
  293. .order-item {
  294. padding: 20rpx 30rpx;
  295. line-height: 1.5;
  296. .title-box {
  297. .title {
  298. font-size: $font-lg;
  299. color: $font-color-base;
  300. }
  301. .time {
  302. font-size: $font-base;
  303. color: $font-color-light;
  304. }
  305. }
  306. .money {
  307. color: #fd5b23;
  308. font-size: $font-lg;
  309. text-align: right;
  310. .status {
  311. color: $font-color-light;
  312. color: $font-color-light - 2rpx;
  313. }
  314. }
  315. }
  316. }
  317. .list-scroll-content {
  318. background: #ffffff;
  319. height: 100%;
  320. }
  321. .content {
  322. height: 100%;
  323. .empty-content {
  324. background-color: #ffffff;
  325. }
  326. }
  327. .btn-box {
  328. width: 674rpx;
  329. height: 88rpx;
  330. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  331. border-radius: 44rpx;
  332. font-size: 36rpx;
  333. font-family: PingFang SC;
  334. font-weight: 500;
  335. color: #ffffff;
  336. text-align: center;
  337. line-height: 88rpx;
  338. position: fixed;
  339. bottom: 48rpx;
  340. left: 0;
  341. right: 0;
  342. margin: 0 auto;
  343. }
  344. </style>