<template>
	<view class="container bgimg">
		<!-- <view class="">
			<image src="../../../static/my/tb.png" style="width: 100%;" mode=""></image>
		</view> -->
		<view class="main" style="margin-top: 20px;position: relative;">
			<view class="" style="padding: 0 15px;color: #000;font-size: 36rpx;">
				注:请填写清楚收货地址,避免影响邮寄派送
			</view>
			<view class="addbank"
				style="background-color: #fff;margin: 20px auto 0;;width: 95%;padding: 15px 0 5px;box-sizing: border-box;border-radius: 15px;">

				<view class="content">
					<view class="item">
						<text>收件人姓名</text>
						<input class="inp" v-model="receiver" type="text" placeholder="请输入您的姓名" style=""
							:disabled="exist">
					</view>
					<view class="item">
						<text>收件人手机号</text>
						<input class="inp" v-model="mobile" type="text" placeholder="请输入您的手机号" style=""
							:disabled="exist">
					</view>

					<textarea id="story" v-model="address" name="story" rows="5" cols="39" placeholder="详细地址"
						:disabled="exist"
						style="background-color: #fff; text-indent: 15px;margin-top: 10px;width: 100%;height: 90px;border-radius: 6px;padding-top: 8px;border: 1px solid #ccc;"></textarea>

				</view>
				<view class="add" style="width: 95%;margin: 60px auto 20px;" v-if="!exist">
					<button class="cnbtn"
						style="background-image: linear-gradient(120deg, #feebd4 0%, #eec89c 100%);color: #000;"
						@click="submit">确认添加</button>
				</view>
				<view class="add" style="width: 95%;margin: 60px auto 20px;" v-else>
					<button class="cnbtn"
						style="background-image: linear-gradient(120deg, #feebd4 0%, #eec89c 100%);color: #000;"
						@click="xg">修改</button>
				</view>

			</view>


		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				list1: [],
				ydh: '',
				content: [],
				isshow: false,
				idi: null,
				productName: "需缴纳送货上门快递费",
				urls: '/ops/daybook',
				show: false,
				exist: false,
				receiver: '',
				address: "",
				mobile: "",
				id: "",
				list: [],
				pageNum: "1",
				pageSize: "35",
				pay7: false,
				emptyTipsShow: true,
				total: "",
				touzilist: "",
				exist: false,
				receiver: '',
				address: "",
				mobile: "",
				id: "",
			}
		},
		onLoad(options) {
    // 接收传入的参数
    console.log("页面传入的参数:", options);

    // 保存传入的数据到 data 里
    this.rewardEntryRecordId = options.rewardEntryRecordId;
    this.entryName = options.entryName;
    this.rewardEntryId = options.rewardEntryId;
    
    // 可以调用接口初始化其他数据
    this.$request("/system/address/list", {}, 'get').then((res) => {
        if (res.data.rows.length > 0) {
            this.exist = true
            this.receiver = res.data.rows[res.data.rows.length - 1].receiver
            this.address = res.data.rows[res.data.rows.length - 1].address
            this.mobile = res.data.rows[res.data.rows.length - 1].mobile
            this.id = res.data.rows[res.data.rows.length - 1].id
        }
    });
}
,
		onShow() {

			this.$request("/system/user/", {}, "get").then(res => {
				this.pay7 = res.data.pay_7
				this.ydh = "SF" + res.data.remark.slice(3)
				console.log(this.ydh);
			})



		},
		methods: {
			xg() {
				this.exist = false
				uni.showToast({
					title: '请重新填写您的信息',
					icon: 'none'
				})
			},
			bb() {
				uni.navigateTo({
					url: `/components/my/tixian/zfym2/pay3`
				})


			},
			isclose() {
				this.isshow = false
			},

			lodding() {
				if (this.list.length > 0) {
					this.emptyTipsShow = false;
				} else {
					this.emptyTipsShow = true;
				}
			},
			submit() {
    if (this.receiver === '' || this.mobile === '' || this.address === '') {
        uni.showToast({
            title: '内容不能为空!',
            icon: 'none'
        });
        return;
    }

    // 准备提交的数据,包括接收到的参数
    let data = {
        receiver: this.receiver,
        mobile: this.mobile,
        address: this.address,
        updateMan: 1,
        id: this.id,
        rewardEntryRecordId: this.rewardEntryRecordId, // 将传入的参数传递到后端
        rewardEntryId: this.rewardEntryId,
        entryName: this.entryName
    };

    // 调用接口提交数据
    this.$request("/system/address", data, "post").then((res) => {
        if (res.data.code == 200) {
            console.log(res);
            uni.showToast({
                title: '添加成功',
                icon: 'none'
            });
            this.exist = false;
            let timer20 = setTimeout(() => {
                uni.reLaunch({
                    url: '/pages/my/my',
                });
                clearTimeout(timer20); // 在回调中清除定时器
            }, 1000);
        } else {
            this.exist = false;
            uni.showToast({
                title: res.data.msg,
                icon: 'none'
            });
        }
    });
}
,
		},
		onReachBottom() {
			if (this.isshow == true && this.pageNum < Math.ceil(this.total / this.pageSize)) {
				this.pageNum++
				let data = {
					pageNum: this.pageNum,
					pageSize: this.pageSize,
				}
				this.$request("/system/lotteryRecord/list", data, "get").then((res) => {
					let zz = res.data.rows.filter(item => {

						return item.status == 1 && item.createMan == 2
					})

					this.list = [...this.list, ...res.data.rows]
					this.list = this.list.filter(item => {

						return item.status == 1 && item.createMan == 2
					})
					// console.log(this.list, 666);

					// console.log(this.list);
					if (zz.length < this.pageSize) {
						this.isshow = false
						return
					}
					// console.log("1111", this.list);
					this.lodding()
				})
				// console.log('页面触底了')
			}

			// 在此处进行数据加载
		}



	}
</script>

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

	.container {
    font-family: pingfang;
		background: linear-gradient(180deg, #FFFFFF 20%, #FED0D0 100%);
		min-height: 100vh;
	}

	.tc {
		width: 100%;
		height: 1100rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		.gs {

			border-radius: 15px;
			margin: 0rpx auto;
			width: 700rpx;
			height: 1100rpx;
			box-sizing: border-box;
			padding: 60rpx 36rpx 100rpx;
			overflow-x: hidden;
			overflow-y: scroll;
		}
	}

	.top {
		display: flex;
		text-align: center;
		justify-content: space-around;
		padding: 20rpx 40rpx;
		background-color: #fff;

		.tops {
			width: 40%;
			// background-color: red;
		}
	}

	.list {
		display: flex;
		text-align: center;
		justify-content: space-around;
		padding: 20rpx 40rpx;
		box-sizing: border-box;
		background-color: #fff;
		border-bottom: 1px solid rgba(235, 236, 237, 1);

		.name {
			font-size: 12px;
			font-weight: 400;
			letter-spacing: 0px;
			line-height: 35rpx;
			color: rgba(222, 31, 38, 1);
			width: 45%;
			// background-color: blue;
			text-align: center;
		}

		.time {
			// background-color: rebeccapurple;
			// height: 60px;
			font-size: 12px;
			// background-color: blue;
			font-weight: 400;
			letter-spacing: 0px;
			line-height: 28rpx;
			color: rgba(51, 51, 51, 1);
			width: 40%;
			text-align: center;
		}


	}

	.empty-tips {
		color: #999;
		text-align: center;
		padding-top: 400rpx;
		font-size: 34rpx;
	}

	.content {
		margin: 10px auto 0;
		// height: 390px;
		width: 95%;
		// background-color: red;
		font-size: 18px;
		box-sizing: border-box;
		padding-top: 20px;


		.item {
			display: flex;
			height: 50px;
			align-items: center;
			// justify-content: space-around;
			color: #000;
			margin: 0 auto;
			width: 90%;

			.inp {
				font-size: 18px;
				margin-left: 8px;
				flex: 1;
				text-align: right;
				border-radius: 6px;
				height: 40px;
				text-indent: 20px;
				color: #000;
			}
		}
	}
</style>