wallet.vue 7.7 KB

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