<template>
	<view class="page">
		<u-tabs active-color="#26c570" :list="list" :current="current" @change="change"></u-tabs>
		<view v-if="alllist.length == 0" style="text-align: center;margin-top: 50rpx;" class="tit1">暂无数据</view>
		<view style="padding: 0 20rpx;">
			<view v-for="(item,index) in alllist" :key="index"
				@click="gopath('/pages/orderList/aftersaledetails',item.afterId)"
				style="background: #fff;margin-top: 40rpx;padding: 30rpx;border-radius: 18rpx;">
				<view style="display: flex;line-height: 50rpx;">
					<view>
						售后单号：
					</view>
					<view class="t1">
						{{item.afterFormid}}
					</view>
				</view>
				<view style="display: flex;line-height: 50rpx;">
					<view>
						售后类型：
					</view>
					<view class="t1">
						<span v-if="item.afterType == 1">仅退款</span>
						<span v-if="item.afterType == 2">退货退款</span>
					</view>
				</view>
				<view style="display: flex;line-height: 50rpx;">
					<view>
						退款金额：
					</view>
					<view class="t1">
						{{item.price}}
					</view>
				</view>
				<view style="display: flex;line-height: 50rpx;">
					<view>
						售后状态：
					</view>
					<view class="t1">
						{{item.afterStateName}}
					</view>
				</view>
				<view style="display: flex;line-height: 50rpx;">
					<view>
						申请时间：
					</view>
					<view class="t1">
						{{item.createTime}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						type: '',
						name: '全部'
					},
					{
						type: '1',
						name: '待商家处理'
					},
					{
						type: '2',
						name: '待商家收货'
					},
				],
				current: 0,
				alllist: [],
				pageindex: {
					page: 1,
					pageSize: 10,
					type: '',
					searchType: "1"
				},
				imgurl: '',
				total: 0
			};
		},
		onLoad(optiong) {
			this.imgurl = this.$img
			if(uni.getStorageSync('shopId')) {
				this.getALL()
			} else {
				
			}
		},
		onReachBottom(e) {
			console.error(e)
			if (this.alllist.length < this.total) {
				this.pageindex.page++
				this.getALL()
			}
		},
		methods: {
			gopath(url, id) {
				uni.navigateTo({
					url: url + '?id=' + id
				})
			},
			getALL() {
				this.$http.sendRequest('/after/getAll', 'POST', this.pageindex, 2).then(res => {
					//成功回调	
					this.alllist = [...this.alllist, ...res.data.data.list]
					this.total = res.data.data.total
					console.error(this.alllist)
				})
			},
			change(index) {
				this.current = index;
				if (this.current == 0) {
					this.pageindex.type = ''
				} else {
					this.pageindex.type = this.list[this.current].type
				}
				this.pageindex.page = 1
				this.alllist = []
				this.getALL()
			}

		}
	}
</script>

<style scoped lang="scss">
	.page {}

	.t1 {
		font-size: 26rpx;
		color: #979797;
	}
</style>