wallet.vue 7.5 KB

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