<template> <view class="content"> <view class="navbar"> <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view> </view> <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab"> <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex"> <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="getList()"> <!-- 空白页 --> <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty> <!-- 订单列表 --> <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index"> <view class="title-box"> <view class="title"> <text>{{ item.mark }}</text> </view> <view class="time"> <text>{{ item.add_time }}</text> </view> </view> <view class="money"> <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text> </view> </view> <uni-load-more :status="tabItem.loadingType"></uni-load-more> </scroll-view> </swiper-item> </swiper> </view> </template> <script> import empty from '@/components/empty'; import { spreadCommission,getIntegralList } from '@/api/wallet.js'; export default { components: { empty }, data() { return { maxheight: '', tabCurrentIndex: 0, navList: [ { loaded: false, state: 1, text: '收入', loadingType: 'more', orderList: [], page: 1, //当前页面 limit: 10 //每次信息条数 }, { loaded: false, state: 0, text: '支出', loadingType: 'more', orderList: [], page: 1, //当前页面 limit: 10 //每次信息条数 } ], type: 0,//1-复投积分 2-佣金 3-分红额度 4-消费积分 } }, onLoad(opt) { this.type = opt.type }, onShow() { this.getList() }, onReady(res) { var _this = this; uni.getSystemInfo({ success: resu => { const query = uni.createSelectorQuery(); query.select('.swiper-box').boundingClientRect(); query.exec(function(res) { _this.maxheight = resu.windowHeight - res[0].top + 'px'; console.log('打印页面的剩余高度', _this.maxheight); }); }, fail: res => {} }); }, methods:{ //顶部tab点击 tabClick(index) { this.tabCurrentIndex = index; }, changeTab(res) { console.log(res); let that = this that.tabCurrentIndex = res.detail.current that.getList('tab') }, getList(type) { let that = this let item = that.navList[that.tabCurrentIndex] let status = 0 let qdata = { page: item.page, limit: item.limit, pm: item.state } if(type == 'tab' && item.loaded) { return } if(item.loadingType == 'noMore' || item.loadingType == 'loading') { return } item.loadingType = 'loading' getIntegralList(qdata).then(res => { // console.log(res) let arr = res.data item.orderList = item.orderList.concat(arr) if(item.limit == arr.length) { item.loadingType = 'more' }else { item.loadingType = 'noMore' } item.loaded = true }) } } } </script> <style lang="scss" scoped> .navbar { display: flex; height: 40px; padding: 0 5px; background: #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06); position: relative; z-index: 10; .nav-item { flex: 1; display: flex; justify-content: center; align-items: center; height: 100%; font-size: 15px; color: $font-color-dark; position: relative; &.current { color: #000; font-weight: bold; &:after { content: ''; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 44px; height: 0; border-bottom: 2px solid #FF4C4C; } } } } .swiper-box { .order-item { padding: 20rpx 30rpx; line-height: 1.5; .title-box { .title { font-size: $font-lg; color: $font-color-base; } .time { font-size: $font-base; color: $font-color-light; } } .money { color: rgba(239, 58, 85, 1); font-size: $font-lg; } } } .list-scroll-content { background-color: #ffffff; height: 100%; } </style>