wallet.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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/anchor12.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. background-color: pink;
  224. .header {
  225. position: absolute;
  226. left: 0;
  227. top: 0;
  228. width: 100%;
  229. height: 80rpx;
  230. font-size: 32rpx;
  231. font-weight: 700;
  232. z-index: 99;
  233. display: flex;
  234. justify-content: center;
  235. align-items: center;
  236. }
  237. .goback-box {
  238. position: absolute;
  239. left: 18rpx;
  240. top: 0;
  241. height: 80rpx;
  242. display: flex;
  243. align-items: center;
  244. }
  245. .goback {
  246. z-index: 100;
  247. width: 34rpx;
  248. height: 34rpx;
  249. }
  250. .money_bg {
  251. width: 100%;
  252. height: 400rpx;
  253. display: block;
  254. }
  255. .text {
  256. padding-top: 80rpx;
  257. font-size: $font-lg;
  258. }
  259. .money {
  260. position: absolute;
  261. top: 0;
  262. width: 100%;
  263. padding-top: 186rpx;
  264. font-size: 72rpx;
  265. font-weight: bold;
  266. }
  267. }
  268. .navbar {
  269. display: flex;
  270. height: 40px;
  271. padding: 0 5px;
  272. background: #fff;
  273. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  274. position: relative;
  275. z-index: 10;
  276. .nav-item {
  277. flex: 1;
  278. display: flex;
  279. justify-content: center;
  280. align-items: center;
  281. height: 100%;
  282. font-size: 15px;
  283. color: #999999;
  284. position: relative;
  285. &.current {
  286. color: #000000;
  287. &:after {
  288. content: '';
  289. position: absolute;
  290. left: 50%;
  291. bottom: 0;
  292. transform: translateX(-50%);
  293. width: 44px;
  294. height: 0;
  295. border-bottom: 2px solid #FF4C4C;
  296. }
  297. }
  298. }
  299. }
  300. // 列表
  301. .swiper-box {
  302. padding-top: 10rpx;
  303. .order-item {
  304. padding: 20rpx 30rpx;
  305. line-height: 1.5;
  306. .title-box {
  307. .title {
  308. font-size: $font-lg;
  309. color: $font-color-base;
  310. }
  311. .time {
  312. font-size: $font-base;
  313. color: $font-color-light;
  314. }
  315. }
  316. .money {
  317. color: #ff0000;
  318. font-size: $font-lg;
  319. }
  320. }
  321. }
  322. .list-scroll-content {
  323. height: 100%;
  324. padding-bottom: 130rpx;
  325. }
  326. .wallet-btn {
  327. width: 674rpx;
  328. height: 88rpx;
  329. background: #FF4C4C;
  330. border-radius: 44rpx;
  331. font-size: $font-lg;
  332. font-family: PingFang SC;
  333. font-weight: 500;
  334. color: #ffffff;
  335. display: flex;
  336. align-items: center;
  337. justify-content: center;
  338. position: fixed;
  339. left: 38rpx;
  340. bottom: 50rpx;
  341. }
  342. .content {
  343. height: 100%;
  344. .empty-content {
  345. background-color: #ffffff;
  346. }
  347. }
  348. </style>