<template>
	<view>
		<view v-for='item in dataInfo'>
			<view>
			买方{{item.compName}}
			</view>
			<view>
			卖方{{item.customerName}}
			</view>
			<view>{{item.paymentNo}}</view>
			<view>
				<view>{{item.goodsName}}{{item.netWeight}}</view>
				<view>单价{{item.tidalGrainPrice}}</view>
			</view>
			<view>
				<view>应付{{item.amountIngPayable}}</view>
				<view>单价{{item.amountEdPayable}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		name: "business",
		data() {
			return {
				pageSize:10,
				currentPage:1,
				isLoadMore:false,
				searchKeyWord:'',
				searchType:'',
				dataInfo:[]
			}
		},
		onShow() {
		},
		onLoad(options) {
			this.loadData();
		},
		computed: {
			...mapState(['hasLogin', 'userInfo']),
		},
		// onPageScroll(e) {
		// 	this.scrollTop = e.scrollTop;
		// },
		//下拉刷新
		onPullDownRefresh() {
			this.currentPage = 1
			this.isLoadMore = false
			this.loadStatus = 'loading'
			this.loadData()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() { //上拉触底函数
			if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
				this.isLoadMore = true
				this.currentPage += 1
				this.getIndexBuyData()
			}
		},
		methods: {
			top() { //回到顶部  
			　　　　uni.pageScrollTo({ 
			　　　　　　scrollTop: 0, duration: 300 
			　　　　}); 
			},
			naviageToPage(page) {
				page = page + this.TabCur
				uni.navigateTo({
					url: page,
					fail() {
						uni.switchTab({
							url: page
						})
					}
				})
			},
			locationChange(e) {
				console.log(e)
				this.location = this.locationType[e[0]]
				this.receivePrivate = this.locationType[e[0]]
				this.currentPage = 1
				this.loadData()
			},
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.category = this.TabCur
				this.currentPage = 1
				this.loadData()
			},
			//加载商品 ，带下拉刷新和上滑加载
			async loadData(type = 'add', loading) {
				if(!this.hasLogin){
					ni.showModal({
						title: '登录提示',
						content: '您尚未登录，是否立即登录？',
						showCancel: true,
						confirmText: '登录',
						success: (e) => {
							if (e.confirm) {
								uni.navigateTo({
									url: '/pages/public/login'
								})
							}
						},
						fail: () => {},
						complete: () => {}
					})
				}else{
					const that = this
				uni.showLoading({
					title: '正在加载'
				})
				var param1 = ''
				this.$api.doRequest('get', '/paymentManagement/selectPaymentManagement', {
						pageSize: this.pageSize,
						currentPage: this.currentPage,
						searchKeyWord: this.searchKeyWord,
						searchType: this.searchType,
						managementType:1,
						customerPhone:this.userInfo.phone,
						pcFlag:1
						// warehouseName:'',
					}).then(res => {
						uni.hideLoading()
						this.dataInfo = res.data.data.records
					})
					.catch(res => {
						uni.hideLoading()
						if (res.errmsg) {
							uni.showToast({
								title: res.errmsg,
								icon: 'none',
								duration: 2000
							})
						} else {
							uni.showToast({
								title: "系统异常，请联系管理员",
								icon: 'none',
								duration: 2000
							})
						}
					});
				}
				
			},
		}
	}
</script>

<style>
</style>
