myLq.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="body-title">
  5. <view class="goback-box" @click="toBack">
  6. <image class="goback" src="../../static/icon/fanhui.png" mode=""></image>
  7. </view>
  8. <view class="header">我的余额</view>
  9. </view>
  10. <view class="content-bg">
  11. <image src="../../static/img/myLq.png" mode=""></image>
  12. </view>
  13. <view class="money-box">
  14. <view class="money">{{ userInfo.brokerage_price | getMoneyStyle }}</view>
  15. <view>当前余额</view>
  16. </view>
  17. <view class="moneybtn-box">
  18. <view class="money-btn"></view>
  19. <!-- <view class="money-btn" v-if="userInfo.is_promoter != 0" @click="navto('/pages/money/withdrawal')">佣金提现</view> -->
  20. </view>
  21. </view>
  22. <view class="navbar">
  23. <view v-for="(item, index) in navList" :key="index" class="nav-item"
  24. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  25. </view>
  26. <swiper :current="tabCurrentIndex" :style="{ height: height }" class="swiper-box" duration="300"
  27. @change="changeTab">
  28. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  29. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  30. <!-- 空白页 -->
  31. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  32. <!-- 订单列表 -->
  33. <view>
  34. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  35. <view class="title-box">
  36. <view class="title" v-if="tabCurrentIndex == 0">
  37. <text>{{ item.mark }}</text>
  38. </view>
  39. <view class="title" v-if="tabCurrentIndex == 1"><text>佣金提现</text></view>
  40. <view class="time">
  41. <text>{{ item.add_time }}</text>
  42. </view>
  43. </view>
  44. <view class="money" v-if="tabCurrentIndex == 0">
  45. <view>{{ (item.pm == 0 ? '-' : '+') + item.number }}</view>
  46. <view class="">{{ item.status == 0 ? '未发放' : '已发放' }}</view>
  47. </view>
  48. <view class="money" v-if="tabCurrentIndex == 1">
  49. <view style="width: 100%;">{{ (item.pm == 0 ? '-' : '+') + item.extract_price }}</view>
  50. <view style="width: 100%;" class="">{{ item.status == 0 ? '提现中' : '已发放' }}</view>
  51. </view>
  52. </view>
  53. </view>
  54. <uni-load-more :status="tabItem.loadingType"
  55. v-if="!(tabItem.orderList.length == 0 && tabItem.loaded)"></uni-load-more>
  56. </scroll-view>
  57. </swiper-item>
  58. </swiper>
  59. </view>
  60. </template>
  61. <script>
  62. import {
  63. mapState,
  64. mapMutations
  65. } from 'vuex';
  66. import {
  67. moneyList,
  68. getUserInfo
  69. } from '@/api/user.js';
  70. import {
  71. spreadCommission,
  72. userBalance,
  73. extract
  74. } from '@/api/wallet.js';
  75. import {
  76. getMoneyStyle,
  77. getTime
  78. } from '@/utils/rocessor.js';
  79. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  80. import empty from '@/components/empty';
  81. export default {
  82. filters: {
  83. getMoneyStyle
  84. },
  85. components: {
  86. empty,
  87. uniLoadMore
  88. },
  89. onReady(res) {
  90. var _this = this;
  91. uni.getSystemInfo({
  92. success: resu => {
  93. const query = uni.createSelectorQuery();
  94. query.select('.swiper-box').boundingClientRect();
  95. query.exec(function(res) {
  96. _this.height = resu.windowHeight - res[0].top + 'px';
  97. console.log('打印页面的剩余高度', _this.height);
  98. });
  99. },
  100. fail: res => {}
  101. });
  102. },
  103. data() {
  104. return {
  105. height: '',
  106. // 头部图高度
  107. maxheight: '',
  108. tabCurrentIndex: 0,
  109. orderStatusSum: 0,
  110. recharge: 0,
  111. navList: [{
  112. state: 0,
  113. text: '收入',
  114. loadingType: 'more',
  115. orderList: [],
  116. page: 1, //当前页数
  117. limit: 10 //每次信息条数
  118. },
  119. {
  120. state: 1,
  121. text: '支出',
  122. loadingType: 'more',
  123. orderList: [],
  124. page: 1, //当前页数
  125. limit: 10 //每次信息条数
  126. }
  127. ],
  128. money: ''
  129. };
  130. },
  131. onLoad(options) {},
  132. onShow() {
  133. this.loadData();
  134. // 获取用户余额
  135. getUserInfo({}).then(({
  136. data
  137. }) => {
  138. this.money = data.now_money;
  139. this.setUserInfo(data);
  140. });
  141. },
  142. computed: {
  143. ...mapState('user', ['userInfo'])
  144. },
  145. methods: {
  146. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  147. toBack() {
  148. uni.navigateBack({});
  149. },
  150. // 页面跳转
  151. navto(e) {
  152. uni.navigateTo({
  153. url: e
  154. });
  155. },
  156. //获取收入支出信息
  157. async loadData(source) {
  158. let obj = this;
  159. //这里是将订单挂载到tab列表下
  160. let index = this.tabCurrentIndex;
  161. let navItem = this.navList[index];
  162. let state = navItem.state + 3;
  163. if (source === 'tabChange' && navItem.loaded === true) {
  164. //tab切换只有第一次需要加载数据
  165. return;
  166. }
  167. if (navItem.loadingType === 'loading') {
  168. //防止重复加载
  169. return;
  170. }
  171. // 修改当前对象状态为加载中
  172. navItem.loadingType = 'loading';
  173. if (index == 0) {
  174. spreadCommission({
  175. page: navItem.page,
  176. limit: navItem.limit
  177. },
  178. state
  179. )
  180. .then(({
  181. data
  182. }) => {
  183. if (data.length != 0) {
  184. navItem.orderList = navItem.orderList.concat(data);
  185. navItem.page++;
  186. if (navItem.limit == data.length) {
  187. navItem.loadingType = 'more';
  188. } else {
  189. navItem.loadingType = 'noMore';
  190. }
  191. this.$set(navItem, 'loaded', true);
  192. } else {
  193. navItem.loadingType = 'noMore';
  194. this.$set(navItem, 'loaded', true);
  195. }
  196. })
  197. .catch(e => {
  198. console.log(e);
  199. });
  200. }
  201. if (index == 1) {
  202. extract({
  203. page: navItem.page,
  204. limit: navItem.limit
  205. })
  206. .then(({
  207. data
  208. }) => {
  209. console.log(data, '111');
  210. if (data.list.length != 0) {
  211. data.list.forEach(e => {
  212. e.add_time = getTime(e.add_time);
  213. });
  214. navItem.orderList = navItem.orderList.concat(data.list);
  215. navItem.page++;
  216. if (navItem.limit == data.list.length) {
  217. navItem.loadingType = 'more';
  218. } else {
  219. navItem.loadingType = 'noMore';
  220. }
  221. this.$set(navItem, 'loaded', true);
  222. } else {
  223. navItem.loadingType = 'noMore';
  224. this.$set(navItem, 'loaded', true);
  225. }
  226. })
  227. .catch(e => {
  228. console.log(e);
  229. });
  230. }
  231. },
  232. //swiper 切换
  233. changeTab(e) {
  234. this.tabCurrentIndex = e.target.current;
  235. this.loadData('tabChange');
  236. },
  237. //顶部tab点击
  238. tabClick(index) {
  239. this.tabCurrentIndex = index;
  240. }
  241. }
  242. };
  243. </script>
  244. <style lang="scss">
  245. page {
  246. background: #f1f1f1;
  247. height: 100%;
  248. }
  249. .status_bar {
  250. height: var(--status-bar-height);
  251. width: 100%;
  252. }
  253. .content-money {
  254. position: relative;
  255. height: 480rpx;
  256. .content-bg {
  257. position: absolute;
  258. top: 0;
  259. left: 0;
  260. right: 0;
  261. width: 750rpx;
  262. height: 480rpx;
  263. image {
  264. width: 100%;
  265. height: 100%;
  266. }
  267. }
  268. .body-title {
  269. height: 80rpx;
  270. text-align: center;
  271. font-size: 35rpx;
  272. position: relative;
  273. .header {
  274. position: absolute;
  275. left: 0;
  276. top: 0;
  277. width: 100%;
  278. font-size: 36rpx;
  279. font-family: PingFang SC;
  280. font-weight: bold;
  281. color: #fffeff;
  282. height: 80rpx;
  283. font-size: 36rpx;
  284. font-weight: 700;
  285. z-index: 9;
  286. display: flex;
  287. justify-content: center;
  288. align-items: center;
  289. }
  290. .goback-box {
  291. position: absolute;
  292. left: 18rpx;
  293. top: 0;
  294. height: 80rpx;
  295. display: flex;
  296. align-items: center;
  297. }
  298. .goback {
  299. z-index: 100;
  300. width: 34rpx;
  301. height: 34rpx;
  302. }
  303. }
  304. }
  305. .info-box {
  306. width: 670rpx;
  307. height: 186rpx;
  308. background: #ffffff;
  309. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  310. border-radius: 20rpx;
  311. margin: -100rpx auto 0;
  312. position: relative;
  313. z-index: 2;
  314. .info-item {
  315. width: 50%;
  316. display: flex;
  317. flex-direction: column;
  318. align-items: center;
  319. line-height: 1;
  320. .info-font {
  321. font-size: 30rpx;
  322. font-family: PingFang SC;
  323. font-weight: bold;
  324. color: #999999;
  325. }
  326. .info-num {
  327. margin-top: 30rpx;
  328. font-size: 30rpx;
  329. font-family: PingFang SC;
  330. font-weight: bold;
  331. color: #181818;
  332. }
  333. }
  334. .shu {
  335. width: 2rpx;
  336. height: 74rpx;
  337. background: #dcdfe6;
  338. }
  339. }
  340. .money-box {
  341. position: relative;
  342. z-index: 2;
  343. padding-top: 70rpx;
  344. color: #ffffff;
  345. text-align: center;
  346. /* #ifdef APP-PLUS */
  347. padding-top: 30rpx;
  348. /* #endif */
  349. .money {
  350. font-size: 72rpx;
  351. font-family: PingFang SC;
  352. font-weight: bold;
  353. color: #ffffff;
  354. }
  355. .text {
  356. font-size: 30rpx;
  357. }
  358. }
  359. .moneybtn-box {
  360. display: flex;
  361. justify-content: space-between;
  362. position: relative;
  363. z-index: 2;
  364. color: #ffffff;
  365. padding: 20rpx 50rpx;
  366. font-size: 30rpx;
  367. font-family: PingFang SC;
  368. font-weight: bold;
  369. color: #ffffff;
  370. }
  371. .navbar {
  372. margin-top: 20rpx;
  373. display: flex;
  374. height: 88rpx;
  375. padding: 0 5px;
  376. background: #fff;
  377. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  378. position: relative;
  379. z-index: 10;
  380. .nav-item {
  381. flex: 1;
  382. display: flex;
  383. justify-content: center;
  384. align-items: center;
  385. height: 100%;
  386. font-size: 15px;
  387. color: #999999;
  388. position: relative;
  389. &.current {
  390. color: #000;
  391. &:after {
  392. content: '';
  393. position: absolute;
  394. left: 50%;
  395. bottom: 0;
  396. transform: translateX(-50%);
  397. width: 44px;
  398. height: 0;
  399. border-bottom: 2px solid #fe5b38;
  400. }
  401. }
  402. }
  403. }
  404. //列表
  405. .swiper-box {
  406. .order-item:last-child {
  407. margin-bottom: 60rpx;
  408. }
  409. .order-item {
  410. padding: 20rpx 30rpx;
  411. line-height: 1.5;
  412. .title-box {
  413. .title {
  414. font-size: $font-lg;
  415. color: $font-color-base;
  416. }
  417. .time {
  418. font-size: $font-base;
  419. color: $font-color-light;
  420. }
  421. }
  422. .money {
  423. color: #fd5b23;
  424. font-size: $font-lg;
  425. text-align: right;
  426. flex-shrink: 0;
  427. // min-width: 100rpx;
  428. .status {
  429. color: $font-color-light;
  430. }
  431. }
  432. }
  433. }
  434. .list-scroll-content {
  435. background: #ffffff;
  436. height: 100%;
  437. }
  438. .content {
  439. height: 100%;
  440. .empty-content {
  441. background-color: #ffffff;
  442. }
  443. }
  444. .btn-box {
  445. width: 674rpx;
  446. height: 88rpx;
  447. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  448. border-radius: 44rpx;
  449. font-size: 36rpx;
  450. font-family: PingFang SC;
  451. font-weight: 500;
  452. color: #ffffff;
  453. text-align: center;
  454. line-height: 88rpx;
  455. position: fixed;
  456. bottom: 48rpx;
  457. left: 0;
  458. right: 0;
  459. margin: 0 auto;
  460. }
  461. </style>