<template>
	<view class="plr30" v-if="istrue">
		<view class="mt40 bgwhite pt20 pb40 pr20"
			style="box-shadow: 0rpx 10rpx 16rpx 0rpx rgba(220,224,236,0.28);border-radius: 16rpx;">
			<view v-if="list.length!=0">
				<view v-for="(item,index) in list" :key="index" class="plr20 pb30 pos bgwhite mt30"
					style="box-shadow: 0rpx 10rpx 16rpx 0rpx rgba(220,224,236,0.28);border-radius: 16rpx;">
					<view class="flex_between flex_items">
						<text class="f26 bold" style="color: #333;">ID:</text>
						<text class="f24" style="color: #1F1057;">{{item.id}}</text>
					</view>
					<view class="flex_between flex_items mt30">
						<text class="f26 bold" style="color: #333;">手机号:</text>
						<text class="f24" style="color: #1F1057;">{{item.to_phone}}</text>
					</view>
					<view class="flex_between flex_items mt30">
						<text class="f26 bold" style="color: #333;">额度:</text>
						<text class="f24" style="color: #1F1057;">{{item.integral}}</text>
					</view>
					<view class="flex_between flex_items mt30">
						<text class="f26 bold" style="color: #333;">活动:</text>
						<view class="f24 one" style="color: #1F1057;">{{item.subject}}</view>
					</view>
					<view class="flex_between flex_items mt30">
						<text class="f26 bold" style="color: #333;">分发人:</text>
						<text class="f24" style="color: #1F1057;" v-if="item.state == 1">普通用户</text>
						<text class="f24" style="color: #1F1057;" v-else>管理员</text>
					</view>
					<view class="flex_between flex_items mt30">
						<text class="f26 bold" style="color: #333;">分发缘由:</text>
						<text class="f24" style="color: #1F1057;">{{item.subject}}</text>
					</view>
					<view class="flex_between flex_items mt30">
						<text class="f26 bold" style="color: #333;">创建时间:</text>
						<text class="f24" style="color: #1F1057;">{{item.create_time}}</text>
					</view>
				</view>
			</view>
			<view v-else class="ptb50 plr30 f26 f-center" style="color: #9a9a9a;margin-top: 80rpx;">--暂无数据--</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				buyimg: require('@/static/again.png'),
				istrue: false,
				form2: {
					page: 1,
					pageSize: 10,
					to_phone: "",
					type: 2
				},
				list: [],
			}
		},
		onLoad() {
			this.getrecored()
		},
		methods: {
			getrecored() {
				uni.showLoading({
					title: "加载中..."
				})
				this.api.getrecord(this.form2).then((res) => {
					console.log(res)
					if (res.data.code == 200) {
						uni.stopPullDownRefresh();
						if (res.data.data.data.length != 0) {
							res.data.data.data.forEach((item, index) => {
								this.list.push(item)
							})
							this.istrue = true
						} else {
							this.istrue = true
							uni.showToast({
								title: '暂无数据',
								icon: 'none'
							})
							return false
						}
					} else {
						this.istrue = true
						uni.hideLoading()
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}
				})
			},
			gofen(item) {
				uni.switchTab({
					url: "/pages/distribute/index"
				})
			},
			bufagain(idx) {
				uni.navigateTo({
					url: "/pages/product/detail?id=" + idx
				})
			}
		},
		onReachBottom() {
			uni.showLoading({
				title: "加载中..."
			})
			setTimeout(() => {
				this.form2.page += 1
				this.getrecored()
			}, 1000)
		},
		onPullDownRefresh() {
			this.form2.page = 1
			this.list = []
			this.form2.name = ""
			this.getrecored()
		}
	}
</script>

<style>
	page {
		background: #f5f5f5 !important;
	}

	.three {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		/* width: 200rpx; */
	}
</style>