wallet.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <view class="content">
  3. <view class="status_bar"><!-- 这里是状态栏 --></view>
  4. <view class="content-money">
  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/user-award.png" mode=""></image></view>
  10. <view class="money-box">
  11. <view class="money"><text>¥</text>{{ brokerage_price }}</view>
  12. </view>
  13. </view>
  14. <view class="navbar">
  15. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  16. </view>
  17. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  18. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  19. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  20. <!-- 空白页 -->
  21. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  22. <!-- 订单列表 -->
  23. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  24. <view class="title-box">
  25. <view class="title">
  26. <text>{{ item.title }}</text>
  27. </view>
  28. <view class="time">
  29. <text>{{ item.add_time }}</text>
  30. </view>
  31. </view>
  32. <view class="money">
  33. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  34. </view>
  35. </view>
  36. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  37. </scroll-view>
  38. </swiper-item>
  39. </swiper>
  40. <view class="btn-box" @click="navto('/pages/money/withdrawal')">
  41. 立即提现
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import { spreadCommission, userBalance } from '@/api/wallet.js';
  47. import { getMoneyStyle } from '@/utils/rocessor.js';
  48. import uniLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue';
  49. import empty from '@/uview-ui/components/u-empty/u-empty.vue';
  50. export default {
  51. filters: {
  52. getMoneyStyle
  53. },
  54. components: {
  55. empty,
  56. uniLoadMore
  57. },
  58. onReady(res) {
  59. var _this = this;
  60. uni.getSystemInfo({
  61. success: resu => {
  62. const query = uni.createSelectorQuery();
  63. query.select('.swiper-box').boundingClientRect();
  64. query.exec(function(res) {
  65. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  66. console.log('打印页面的剩余高度', _this.height);
  67. });
  68. },
  69. fail: res => {}
  70. });
  71. },
  72. computed: {
  73. //佣金
  74. brokerage_price() {
  75. return this.$store.state.user.userInfo.brokerage_price
  76. }
  77. },
  78. data() {
  79. return {
  80. // 头部图高度
  81. maxheight:'',
  82. tabCurrentIndex: 0,
  83. navList: [
  84. {
  85. state: 1,
  86. text: '支出',
  87. loadingType: 'more',
  88. orderList: [],
  89. page: 1, //当前页数
  90. limit: 10 //每次信息条数
  91. },
  92. {
  93. state: 2,
  94. text: '收入',
  95. loadingType: 'more',
  96. orderList: [],
  97. page: 1, //当前页数
  98. limit: 10 //每次信息条数
  99. }
  100. ],
  101. money: ''
  102. };
  103. },
  104. onLoad(options) {},
  105. onShow() {
  106. this.loadData();
  107. // 获取用户余额
  108. userBalance({}).then(({ data }) => {
  109. this.money = data.now_money;
  110. });
  111. },
  112. methods: {
  113. // 页面跳转
  114. navto(e) {
  115. uni.navigateTo({
  116. url: e
  117. });
  118. },
  119. // 点击返回 我的页面
  120. toBack() {
  121. uni.navigateBack({
  122. })
  123. },
  124. //获取收入支出信息
  125. async loadData(source) {
  126. //这里是将订单挂载到tab列表下
  127. let index = this.tabCurrentIndex;
  128. let navItem = this.navList[index];
  129. let state = navItem.state;
  130. if (source === 'tabChange' && navItem.loaded === true) {
  131. //tab切换只有第一次需要加载数据
  132. return;
  133. }
  134. if (navItem.loadingType === 'loading') {
  135. //防止重复加载
  136. return;
  137. }
  138. // 修改当前对象状态为加载中
  139. navItem.loadingType = 'loading';
  140. spreadCommission(
  141. {
  142. page: navItem.page,
  143. limit: navItem.limit
  144. },
  145. state
  146. )
  147. .then(({ data }) => {
  148. if (data.length > 0) {
  149. navItem.orderList = navItem.orderList.concat(data[0].list);
  150. console.log(navItem.orderList);
  151. navItem.page++;
  152. }
  153. if (navItem.limit == data.length) {
  154. //判断是否还有数据, 有改为 more, 没有改为noMore
  155. navItem.loadingType = 'more';
  156. return;
  157. } else {
  158. //判断是否还有数据, 有改为 more, 没有改为noMore
  159. navItem.loadingType = 'noMore';
  160. }
  161. uni.hideLoading();
  162. this.$set(navItem, 'loaded', true);
  163. })
  164. .catch(e => {
  165. console.log(e);
  166. });
  167. },
  168. //swiper 切换
  169. changeTab(e) {
  170. this.tabCurrentIndex = e.target.current;
  171. this.loadData('tabChange');
  172. },
  173. //顶部tab点击
  174. tabClick(index) {
  175. this.tabCurrentIndex = index;
  176. }
  177. }
  178. };
  179. </script>
  180. <style lang="scss">
  181. page {
  182. background: #f1f1f1;
  183. height: 100%;
  184. }
  185. .status_bar {
  186. height: var(--status-bar-height);
  187. width: 100%;
  188. }
  189. .content-money {
  190. padding-bottom: 30rpx;
  191. position: relative;
  192. height: 400rpx;
  193. .content-bg {
  194. position: absolute;
  195. top: 0;
  196. left: 0;
  197. right: 0;
  198. width: 750rpx;
  199. height: 400rpx;
  200. image {
  201. width: 100%;
  202. height: 100%;
  203. }
  204. }
  205. .body-title {
  206. height: 80rpx;
  207. text-align: center;
  208. font-size: 35rpx;
  209. position: relative;
  210. .header {
  211. position: absolute;
  212. left: 0;
  213. top: 0;
  214. width: 100%;
  215. font-size: 36rpx;
  216. font-family: PingFang SC;
  217. font-weight: bold;
  218. color: #fffeff;
  219. height: 80rpx;
  220. font-size: 36rpx;
  221. font-weight: 700;
  222. z-index: 9;
  223. display: flex;
  224. justify-content: center;
  225. align-items: center;
  226. }
  227. .goback-box {
  228. position: absolute;
  229. left: 18rpx;
  230. top: 0;
  231. height: 80rpx;
  232. display: flex;
  233. align-items: center;
  234. }
  235. .goback {
  236. z-index: 100;
  237. width: 34rpx;
  238. height: 34rpx;
  239. }
  240. }
  241. }
  242. .money-box {
  243. position: relative;
  244. z-index: 100;
  245. padding-top: 150rpx;
  246. color: #ffffff;
  247. text-align: center;
  248. .money {
  249. font-size: 86rpx;
  250. font-family: PingFang SC;
  251. font-weight: bold;
  252. color: #FFFFFF;
  253. text{
  254. font-size: 42rpx;
  255. }
  256. }
  257. }
  258. .navbar {
  259. margin-top: 20rpx;
  260. display: flex;
  261. height: 88rpx;
  262. padding: 0 5px;
  263. background: #fff;
  264. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  265. position: relative;
  266. z-index: 10;
  267. .nav-item {
  268. flex: 1;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. height: 100%;
  273. font-size: 15px;
  274. color: $font-color-dark;
  275. position: relative;
  276. &.current {
  277. color: $base-color;
  278. &:after {
  279. content: '';
  280. position: absolute;
  281. left: 50%;
  282. bottom: 0;
  283. transform: translateX(-50%);
  284. width: 44px;
  285. height: 0;
  286. border-bottom: 2px solid $base-color;
  287. }
  288. }
  289. }
  290. }
  291. //列表
  292. .swiper-box {
  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. }
  310. }
  311. }
  312. .list-scroll-content {
  313. background: #ffffff;
  314. height: 100%;
  315. }
  316. .content {
  317. height: 100%;
  318. .empty-content {
  319. background-color: #ffffff;
  320. }
  321. }
  322. .btn-box {
  323. width: 674rpx;
  324. height: 88rpx;
  325. background: linear-gradient(0deg, #2E58FF, #32C6FF);
  326. border-radius: 44rpx;
  327. font-size: 36rpx;
  328. font-family: PingFang SC;
  329. font-weight: 500;
  330. color: #FFFFFF;
  331. text-align: center;
  332. line-height: 88rpx;
  333. position: fixed;
  334. bottom: 48rpx;
  335. left: 0;
  336. right: 0;
  337. margin: 0 auto;
  338. }
  339. </style>