<template>
	<view style="padding: 20rpx;font-size: 30rpx;">


		<view class="tit">收件人</view>
		<input class="srk" placeholder="请输入收件人" v-model="data.xm" />
		
		<view class="tit">联系电话</view>
		<input class="srk" placeholder="请输入联系电话" v-model="data.sjh" />
		
		<view class="tit">收件地址</view>
		<input class="srk" placeholder="请输入收件地址" v-model="data.dz" />
		
		<view class="tit">交易密码</view>
		<input class="srk" placeholder="请输入交易密码" v-model="data.jymm"/>
		
	
		<button type="warn" style="margin-top: 40rpx;" @click="add">确认兑换</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: {
					'id': 0,
					'xm': '',
					'sjh':'',
					'dz':'',
					'jymm':''
				}
			}
		},
		methods: {
			add() {
				var data = this.data;
				if(!data.xm || !data.sjh || !data.dz  || !data.jymm){
					uni.showToast({
						title:"请输入完整信息后兑换",
						icon:"none"
					})
					return;
				}
				data.uid = this.userinfo.id;
				this.$api
					.MhGetModel(data, 'user/duihuan')
					.then(res => {
						if (res.data.code != 1) {
							uni.showToast({
								title: res.data.msg,
								icon: 'none'
							});
							this.getCode();
							return;
						} else {
							uni.showToast({
								title: res.data.msg,
								icon: 'none'
							});							
						}
					})
					.catch(err => {
						// console.log('request fail', JSON.stringify(err));
					});
				// console.log(333)
			}
		},
		onLoad(o) {
			var user = this.$api.getUserinfo();
			this.data.id=o.id
			this.userinfo = user;
		}
	}
</script>

<style>
	page {
		padding: 15rpx;
		background:   #98a737;
		background-attachment: fixed !important;
		background-repeat: no-repeat !important;
	}

	.srk {
		color: #000;
		height: 60rpx;
		line-height: 60rpx;
		background: #fff;
		border-radius: 10rpx;
		padding-left: 20rpx;
		font-size: 30rpx;
	}

	.tit {
		color: #fff;
		height: 60rpx;
		line-height: 60rpx;
		margin-top: 10rpx;
	}
</style>
