wallet.vue 7.3 KB

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