<template>
	<view>
		<view class="item-wrapper">
			<view class="ulList">
				<ul>
					<li v-for="(item,index ) in companyList" :key="index">
						<uni-card :title="'店铺名称:'+item.shopName" :sub-title="'扣减金额：'+ item.companyFixedAmount ">
							<view class="uni-body">
								<text class="cardText">扣减后余额：{{item.companyAfterDepoBal}}</text>
							</view>
							<view class="uni-body">
								<text class="cardText">扣减时间：</text>
								<text class="priceText">{{item.createTime}}</text>
							</view>
						</uni-card>
					</li>
				</ul>
			</view>
			<u-loadmore :status="status" />
		</view>
	</view>
</template>

<script>
	import tui from '../../common/httpRequest.js'
import { onLoad } from '../../uni_modules/uview-ui/libs/mixin/mpShare.js'

	export default {
		data() {
			return {
				companyList: [],
				transCompany:'',
				pageNum:1,
				pages:1,
				totalPages:0,
				status: 'loadmore',
			}
		},
		onReachBottom() {
			if (this.pages >= this.totalPages) return;
			this.status = 'loading';
			this.pages = ++this.pages;
			this.getList();
		},
		onLoad(){
			this.transCompany = uni.getStorageSync('transCompany')
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				uni.request({
					url: this.tui.interfaceUrl() + '/app/deductlog/getCompanyLogById',
					data: {
						companyId:this.transCompany,
						pageNum:this.pageNum,
						pageSize:10

					},
					header: {
						'content-type': 'application/json',
						'appWLToken': this.tui.getToken()
					},
					method: 'POST',
					dataType: 'json',
					success: (res) => {
						this.status = 'nomore';
						if (res.data.code == 200) {
							if (this.pages == 1) {
								this.companyList = res.data.result.records
							} else {
								this.companyList = [...this.companyList, ...res.data.result.records]
							}
							this.totalPages = res.data.result.pages
							
						}
					},
					fail: (res) => {
						this.tui.toast("网络不给力，请稍后再试~")
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.item-wrapper {
		background-color: #fff;
		overflow: hidden;
	}
</style>