<template>
	<view class="min-page bg-gray u-font-28">
		<view class="block bg-fff border-r-18 default-box-padding">
			<view>
				<view>中奖用户手机号</view>
				<view class="border u-m-t-24 u-p-l-24" style="margin-bottom: 20rpx;">
					<u-input v-model="datas.query.phone" type="number" maxlength="11"
						placeholder="请输入中奖用户手机号"></u-input>
				</view>
				<view>收货地址</view>
				<view class="border u-m-t-24 u-p-l-24" style="margin-bottom: 20rpx;">
					<u-input v-model="datas.query.address" type="text" placeholder="请输入收货地址"></u-input>
				</view>
				<view>备注</view>
				<view class="border u-m-t-24 u-p-l-24">
					<u-input v-model="datas.query.remark" type="text" placeholder="请输入备注"></u-input>
				</view>
			</view>

			<view class="u-m-t-48">
				<view>兑换事项</view>
				<view class="u-m-t-16 color-999">
					请认真核实兑换账号，一但兑换成功后，不予退换。
				</view>
			</view>
		</view>
		<view class="u-flex u-row-center">
			<view class="btn-circle duihuan" @click="exchange">确认兑换</view>
		</view>
	</view>
</template>

<script setup>
	import {
		reactive
	} from 'vue'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		userPrizeExchangeexchange
	} from '@/api/index/index.js'
	let datas = reactive({
		query: {
			foreignId: null,
			foreignType: 'spinning',
			phone: "",
			address: "",
			remark: "",
		}
	})

	onLoad(options => {
		if (options.id) {
			datas.query.foreignId = options.id
		}
		if (options.foreignType) {
			datas.query.foreignType = options.foreignType
		}

	})

	async function exchange() {
		let url = ""
		if (!datas.query.phone) {
			uni.showToast({
				title: '请输入中奖用户手机号',
				icon: 'none'
			});
			return;
		}
		if (!datas.query.address) {
			uni.showToast({
				title: '请输入中奖用户地址',
				icon: 'none'
			});
			return;
		}
		let res = await userPrizeExchangeexchange(datas.query)
		uni.showToast({
			title: '兑换成功',
			icon: 'none'
		});
		setTimeout(() => {
			uni.navigateBack()
		}, 1200)
	}
</script>

<style lang="scss" scoped>
	.border {
		border: 1px solid #999999;
		border-radius: 12rpx 12rpx 12rpx 12rpx;
	}

	.duihuan {
		background: #ED838A;
		width: 556rpx;
		padding: 18rpx 0;
		text-align: center;
		font-size: 32rpx;
		font-weight: bold;
		color: #fff;
		margin-top: 84rpx;
	}

	.min-page {
		padding: 32rpx 20rpx;
	}
</style>