分页以及tab栏切换,动态传类型

html 复制代码
				<view class="disTitle">
				<view class="disName">
					账户明细
				</view>
				<view class="nav">
					<u-tabs lineWidth="0" :activeStyle="{color: '#FD893F' }" :list="navList" @change="tabsChange"
						:scrollable="false" :current="tabsCurrent"></u-tabs>
				</view>
			</view>
			<view v-if="tabsCurrent === 0">
				<view class="content">
					<view class="conItem" v-for="item in list" :key="item.id">
						<view class="left">
							<view class="">
								{{item.sourceName}}
							</view>
							<view class="">
								{{dataFormat(item.sourceTime)}}
							</view>
						</view>
						<view class="right" v-if="item.type===1" style="color: #F75038;">
							+{{item.money}}
						</view>
						<view class="right" v-else-if="item.type===2">
							-{{item.money}}
						</view>
					</view>
				</view>
			</view>
			<view v-if="tabsCurrent === 1">
				<view class="content">
					<view class="conItem" v-for="item in list" :key="item.id">
						<view class="left">
							<view class="">
								{{item.sourceName}}
							</view>
							<view class="">
								{{dataFormat(item.sourceTime)}}
							</view>
						</view>
						<view class="right" v-if="item.type===1" style="color: #F75038;">
							+{{item.money}}
						</view>
						<view class="right" v-else-if="item.type===2">
							-{{item.money}}
						</view>
					</view>
				</view>
			</view>
			<view v-if="tabsCurrent === 2">
				<view class="content">
					<view class="conItem" v-for="item in list" :key="item.id">
						<view class="left">
							<view class="">
								{{item.sourceName}}
							</view>
							<view class="">
								{{dataFormat(item.sourceTime)}}
							</view>
						</view>
						<view class="right" v-if="item.type===1" style="color: #F75038;">
							+{{item.money}}
						</view>
						<view class="right" v-else-if="item.type===2">
							-{{item.money}}
						</view>

					</view>
				</view>
			</view>
			<view v-if="list.length<=0">
				<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"></u-empty>
			</view>
javascript 复制代码
	tabsCurrent: 0,
	navList: [{
		name: '全部',
	}, {
		name: '收入',
	}, {
		name: '支出'
	}],
	list: [],
	type: '',
	page: 1,
	pageSize: 10,
	onReachBottom() {
			if (this.list.length < this.total) {
				this.getBonusRollover(); // 加载下一页  
			}
		},
	methods:{
	//点击tab栏掉接口
	tabsChange(e) {
			this.tabsCurrent = e.index;
			this.page = 1 //充值为第一页
			this.list = []//清空列表
			if (this.tabsCurrent === 0) {
				this.type = ''//类型
				this.getBonusRollover()
			} else if (this.tabsCurrent === 1) {
				this.type = 1//类型
				this.getBonusRollover()
			} else if (this.tabsCurrent === 2) {
				this.type = 2//类型
				this.getBonusRollover()
			}
		},
		getBonusRollover() {
				let that = this
				let params = {
					statementType: 1, // 1 余额 2 优惠金
					source: '',
					type: that.type, //全部'' 收入1 支出2 动态复制type类型,在切换的时候,默认传空
					pageNo: that.page,
					pageSize: that.pageSize
				}
				bonusRollover(params).then(res => {
					that.total = res.data.data.total
					that.page = that.page + 1;
					that.list =that.list.concat(res.data.data.list) 
				})
			},
		}
相关推荐
夏碧笔1 天前
uni-app跨端地图实战:用第三方LBS替代微信平台收费服务
uni-app
m0_526119406 天前
iconfont我修改好颜色,但是在小程序项目是黑色的
小程序
用户6990304848756 天前
try catch使用场景 处理同步代码错误兼容用的
javascript·uni-app
ITKEY_6 天前
uniapp微信开发者工具 更改AppID失败 touristappid
uni-app
2601_956743686 天前
2026 上海小程序开发甄选:源码、云函数、跨端兼容技术评判
小程序·开发经验·上海
IT_张三6 天前
CSDN-项目分享-暑期备考小程序
小程序
IsJunJianXin6 天前
pdd小程序 cdp 保存响应体
linux·服务器·小程序·pdd小程序·拼多多响应体解密·小程序cdp·拼多多rpc取响应体
Geek_Vison6 天前
APP瘦身实战:从80MB+砍到15MB——基于小程序容器技术剥离APP非核心业务的实践分享
小程序·uni-app·mpaas
weikecms6 天前
聚合返利CPS小程序快速搭建教程
人工智能·微信·小程序
CHB7 天前
HDC2026 演讲实录|AI 驱动的跨端进化:利用 uni-agent 快速构建高性能鸿蒙应用
uni-app·harmonyos