uniapp下拉加载更多

代码如下(示例):

<template>
	<view class="boxes">
		<view class="zhuangtai"></view>
		<!-- <Back title="订单列表"></Back> -->
		<!-- #ifdef H5 -->
		<view class="title">
			<view class="backs" @click="goBack">
				<uni-icons type="back" size="16" color="#fff"></uni-icons>
			</view>
			<view class="titleText">历史账单</view>
		</view>
		<!-- #endif -->
		<!-- <Back title="历史账单"></Back> -->
		<view class="box-container">
			<!--  cards  -->
			<view class="total-box">
				<view class="total-title">
					<view>缴费总金额</view>
					<view class="money-box">{{ totalMoney  | numberToCurrency}}</view>
				</view>
				<view class="line"></view>
				<view class="total-title">
					<view>缴费总笔数</view>
					<view class="money-box">{{billNum}}</view>
				</view>
			</view>
			<!--  筛选  -->
			<view class="root">
				<zb-dropdown-menu style="width: 100%" active-color="#006b5b">
					<zb-dropdown-item name="first" :options="optionDate" v-model="dateDrop" @change="dateChange">
					</zb-dropdown-item>
					<zb-dropdown-item name="two" :options="optionSubject" v-model="subjectDrop" @change="ed">
					</zb-dropdown-item>
				</zb-dropdown-menu>
				<!-- <ren-dropdown-filter :from="historyPay" :filterData='options' :defaultIndex='defaultIndex' @ed='ed'>
				</ren-dropdown-filter> -->
			</view>
			<view class="nodata" v-if="records.length == 0">
				<view class="pic">
					<image
						src="http://whsle-hopdata-dev.oss-cn-hangzhou.aliyuncs.com/upload/20230227/0d348b94eda04578710f322e6a6cae48.png" />
					<view style="color: #aaa;">暂无数据</view>
				</view>
			</view>
			<scroll-view v-else class="scrollBox" scroll-y @scrolltolower='Scroll()'>
				<view class="card" v-for="(item) in records" :key="item.index">
					<view class="money-con">
						<view>实付:<text style="color: #E58D00;">{{item.actualAmount | numberToCurrency}}</text></view>
						<view>应付:<text style="color: #E58D00;">{{item.money | numberToCurrency}}</text></view>
					</view>
					<view class="time-box dushu" v-if="item.type == 6 || item.type ==  7">
						<view>用量:{{item.dosage}}</view>
					</view>
					<view class="time-box dushu" v-if="item.type == 6 || item.type ==  7">
						<view>上期读数:{{item.beforeMeterValue}}</view>
						<view>本期读数:{{item.presentMeterValue}}</view>
					</view>
					<!-- <view v-if="item.feeStartTime != '' && item.feeEndTime != ''" class="time-box">
						费用周期:{{ item.feeStartTime.substring(0,10) }}{{ item.feeEndTime.substring(0,10) }}
					</view> -->
					<view v-if="item.feeDesc!==''" class="time-box">
						{{ item.feeDesc}}
					</view>
					<view class="time-box">创建时间:{{ item.createTime }}</view>
					<view class="time-box">支付时间:{{item.payEndTime}}</view>
				</view>
			</scroll-view>

			<!-- <view class="bottom-box">
				<span>{{records.length}}条记录</span>
				<span>共计:{{ totalMoney  | money}}</span>
			</view> -->
		</view>
	</view>
</template>

<script>
	import ZbDropdownMenu from '../../components/zb-dropdown-menu/zb-dropdown-menu.vue'
	import ZbDropdownItem from '../../components/zb-dropdown-item/zb-dropdown-item.vue'
	import {
		getList,
		getTotal,
		getFeeSubject
	} from "@/api/shop/paymentManagement";
	import {
		shopDetail
	} from '@/api/mine/shopManagement/shopDetail';
	import Back from "@/components/back";

	export default {
		name: "historyPayment",
		props: {},
		components: {
			Back,
			ZbDropdownMenu,
			ZbDropdownItem
		},
		data() {
			return {
				historyPay: 'historyPay',
				defaultIndex: [0, 0],
				startDates: '',
				endDates: '',
				optionDate: [{
						text: "本月",
						value: "1",
					},
					{
						text: "近3个月",
						value: "2",
					},
					{
						text: "近6个月",
						value: "3",
					}, {
						text: "本年",
						value: "4",
					}
				],
				optionSubject: [{
					text: "全部",
					value: "",
				}],
				dateDrop:'1',
				subjectDrop:'',
				options: [
					[{
							text: "本月",
							value: "1",
						},
						{
							text: "近3个月",
							value: "2",
						},
						{
							text: "近6个月",
							value: "3",
						}, {
							text: "本年",
							value: "4",
						}
					],
					[{
						text: "全部",
						value: "",
					}]
				],
				texts: "全部时间",
				single: "2021-04-3",
				showPicker: true,
				value1: "",
				status: "",
				records: [],
				current: 1,
				size: 10,
				loading: false,
				finished: false,
				flag: false,
				total: 0,
				totalMoney: 0,
				merchantId: '',
				tPageJump: 1,
				tRecInpage: 10,
				loading: false,
				finished: false,
				merchantName: '',
				merchantPhone: '',
				storeName: '',
				storeCode: '',
				flag: false,
				timeType: '1',
				billNum:'',
			}
		},
		onLoad() {
			this.getShopDetail()
		},
		onShow() {
			this.records = []
			this.options = [
				[{
						text: "本月",
						value: "1",
					},
					{
						text: "近3个月",
						value: "2",
					},
					{
						text: "近6个月",
						value: "3",
					}, {
						text: "本年",
						value: "4",
					}
				],
				[{
					text: "全部",
					value: "",
				}]
			]
			this.optionDate= [{
					text: "本月",
					value: "1",
				},
				{
					text: "近3个月",
					value: "2",
				},
				{
					text: "近6个月",
					value: "3",
				}, {
					text: "本年",
					value: "4",
				}
			]
			this.optionSubject = [{
				text: "全部",
				value: "",
			}]
			this.billNum = ''
			this.getFeeSubjectAndAccountInfo()
		},
		methods: {
			getFeeSubjectAndAccountInfo() {
				getFeeSubject().then(res => {
					console.log(res, '费用科目')
					if (res.code == 200) {
						res.data.forEach(item => {
							item.text = item.subjectName
							item.value = item.id
							this.optionSubject.push(item)
						})
					}
				})
			},
			getTotal() {
				getTotal({
					merchantId: this.merchantId,
					merchantName: this.merchantName,
					merchantPhone: this.merchantPhone,
					status: [1, 2, 9],
					subjectId: this.status,
					timeType: this.timeType,
				}).then(res => {
					console.log(res, 'get total')
					this.totalMoney = res.data.totalMoney
					this.billNum = res.data.billNum
				})
			},
			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			change(e) {
				this.single = e;
				console.log("-change事件:", e);
			},
			ed(e) {
				console.log(e, 'eee204')
				this.status = e.subjectId
				// this.timeType = e[0][0].value
				// this.endDates = this.$moment(new Date()).format("YYYY-MM-DD")
				// if(e[0][0].value == 1){
				// 	// 本月
				// 	this.startDates = this.$moment().startOf('month').format('YYYY-MM-DD')
				// }else if(e[0][0].value == 2){
				// 	// 近3月
				// 	this.startDates = this.$moment().subtract(3, 'month').format('YYYY-MM-DD')
				// }else if(e[0][0].value == 3){
				// 	// 近6月
				// 	this.startDates = this.$moment().subtract(6, 'month').format('YYYY-MM-DD')
				// }else if(e[0][0].value == 4){
				// 	// 本年
				// 	this.startDates = this.$moment().startOf('year').format('YYYY-MM-DD')
				// }
				// console.log(this.startDates,'开始日期')
				// console.log(this.endDates,'结束日期')
				this.search()

			},
			dateChange(e) {
				console.log(e,'eeee')
				this.timeType = e.value
				// if (e == '全部时间') {
				// 	this.createTime = ''
				// } else {
				// 	this.createTime = e
				// }
				this.search()
			},
			//点击查询按钮
			search() {
				this.tPageJump = 1;
				this.records = [];
				this.finished = false;
				this.getHistory();
				this.getTotal()
			},
			getShopDetail() {
				shopDetail().then(res => {
					this.merchantId = res.data.merchantId
					this.merchantName = res.data.merchantName
					this.merchantPhone = res.data.merchantPhone
					this.storeName = res.data.storeName
					this.getHistory()
					this.getTotal()
				})
			},
			//滚动加载更多
			Scroll() {
				if (this.flag === false && this.finished === false) {
					//避免多次请求 加锁 该次请求完成 才能再次发起请求
					this.flag = true;
					this.tPageJump++;
					this.getHistory()
				}
			},
			getHistory() {
				// "订单状态 0-待付款 1-已付款 2-支付中 4-未完全支付 5-逾期 6-免租 7-往期 8-支付失败 9-取消"
				getList({
					merchantName: this.merchantName,
					// startDate: this.createTime ? this.createTime + ' 00:00:00' : '',
					subjectId: this.status,
					pageNum: this.tPageJump,
					phone: this.merchantPhone,
					pageSize: this.tRecInpage,
					status: [1, 2, 9],
					timeType: this.timeType,
					// merchantId: this.merchantId,
					// date: this.createTime,
					// billType: this.status,
				}).then(res => {
					console.log(res, 'res 179')
					// this.totalPage = res.data.commonPageOutVo.totalPage;
					if (this.tPageJump >= res.data.totalPage) {
						this.finished = true;
						this.more = 'noMore'
					}
					this.flag = false;
					this.records = [...this.records, ...res.data.result];
					// console.log(res, 'ressss')
					// this.records = res.data.data
					// this.total = res.data.totalSize
					// this.totalMoney = res.data.totalMoney
				})
			},
			//日历确认按钮
			setToggle() {
				this.$refs.item.toggle();
				this.texts = "全部时间";
				this.createTime = "";
				this.getHistory()
			},
			setCurrent(val) {
				this.$refs.item.toggle();
				this.texts = this.$moment(val).format("YYYY/MM");
				this.createTime = this.$moment(val).format("YYYY-MM");
				this.getHistory()
			},
		},
	}
</script>

<style scoped>
	.boxes {
		height: 100vh;
		overflow: scroll;
	}

	.box-container {
		/* margin-top: 88rpx; */
	}

	.dropdown {
		/* margin-top: 88rpx; */
	}

	.dropdown>>>.van-dropdown-menu__bar {
		height: 90rpx;
		line-height: 90rpx;
		background-color: #fafafa;
		box-shadow: none;
		/*border-bottom: 1rpx solid #eee;*/
	}

	.dropdown>>>.van-dropdown-menu__title {
		font-size: 32rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		height: 90rpx;
		line-height: 90rpx;
	}

	/* #ifdef H5 */
	.cards {
		max-height: calc(100vh - 240rpx);
		overflow: auto;
		padding: 70rpx 0;
	}

	/* #endif */


	.card {
		width: 640rpx;
		background: #ffffff;
		box-shadow: 0rpx 2rpx 30rpx 0rpx rgba(0, 0, 0, 0.06);
		border-radius: 10rpx;
		margin: 24rpx auto 0;
		padding: 32rpx 24rpx 32rpx;
		/*height: 247rpx;*/
		font-size: 32rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		position: relative;
	}

	.feiyong-box {
		display: flex;
		justify-content: space-between;
		margin-bottom: 24rpx;
		margin-top: 24rpx;
	}

	.time-box {
		margin-top: 24rpx;
	}

	.bottom-box {
		position: absolute;
		bottom: 0;
		width: 100%;
		height: 77rpx;
		background: #EDEDED;
		font-size: 32rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}

	.title {
		height: 88rpx;
		line-height: 88rpx;
		padding: 0rpx 40rpx;
		box-sizing: border-box;
		text-align: left;
		/* margin-bottom: 24rpx; */
		font-size: 36rpx;
		color: #fff;
		background-color: #11b690;
	}

	.backs uni-icons {
		width: 26rpx;
		height: 26rpx;
		color: #333333;
		vertical-align: middle;
		margin-left: -2rpx;
	}

	.backs {
		display: inline-block;
		margin-right: 4rpx;
		line-height: 80rpx;
		vertical-align: middle;
	}

	.backs .t-icon {
		width: 26rpx;
		height: 26rpx;
		color: #333333;
		vertical-align: middle;
	}

	.titleText {
		height: 100%;
		font-size: 36rpx;
		display: inline-block;
		vertical-align: middle;
		line-height: 90rpx;
	}

	.pic {
		text-align: center;
	}

	.nodata {
		padding-top: 88rpx;
		font-size: 28rpx;
	}

	/* #ifdef MP-WEIXIN */
	.scrollBox {
		height: calc(100vh - 280rpx);
		/* margin-top: 70rpx; */
		/* padding-top: 80rpx; */
		/* background-color: pink; */
	}

	/* #endif */

	/* #ifdef H5 */
	.scrollBox {
		height: calc(100vh - 370rpx);
		/* margin-top: 70rpx; */
		/* padding-top: 80rpx; */
		/* background-color: pink; */
	}

	/* #endif */

	.money-con {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.total-box {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		background: #11B690;
		padding: 24rpx 44rpx 48rpx;
		box-sizing: border-box;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(255, 255, 255, 0.8);
		text-align: center;
	}

	.line {
		width: 2rpx;
		height: 100rpx;
		background: rgba(255, 255, 255, 0.8);
	}

	.money-box {
		font-size: 40rpx;
		font-family: DINAlternate-Bold, DINAlternate;
		font-weight: 500;
		color: #FFFFFF;
		margin-top: 16rpx;
		text-align: center;
	}

	.total-title {
		text-align: center;
		flex: 1;
	}

	.dushu {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 24rpx;
	}
</style>

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值