index.vue 10 KB

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