<template>
	<view class="content">
		<view class="box">
			<view class="wx">
				<text>姓名</text>
				<input type="text" v-model="name" value="" placeholder="请输入姓名" />
			</view>
			<view class="wx">
				<text>微信号</text>
				<input type="text" v-model="code" value="" placeholder="请输入微信号" />
			</view>
			<view class="wx">
				<text>手机号</text>
				<input type="text" v-model="phone" value="" placeholder="请输入手机号" />
			</view>
			<view class="erweima">
				<text>微信收款码</text>
				<view class="img" @click="uploads()">
					<image src="../../static/user/erweima.png" mode="" v-if="image == ''"></image>
					<image :src="image" mode="" v-else></image>
				</view>
			</view>
		</view>
		<view class="button" @click="confirm()">
			确认
		</view>
	</view>
</template>

<script>
	import { upload } from '@/api/order.js'
	import { auction,pay_list } from '@/api/wallet.js';
	export default {
		data() {
			return {
				code:'',
				name:'',
				image:'',
				phone:''
			};
		},
		onLoad() {
			pay_list().then(({data}) =>{
				if(data.wx != ''){
					this.name = data.wx.name
					this.code = data.wx.payment
					this.image = data.wx.image
					this.phone = data.wx.phone
				}
			})
		},
		methods: {
			uploads(){
				upload({
					filename: ''
				}).then(data => {
					this.image = data[0].url;
				})
			},
			confirm() {
				let obj = this;
				if (!obj.name) {
					return this.$api.msg('请输入提款人姓名');
				}
				if (!obj.code) {
					return this.$api.msg('请输入微信账号');
				}
				if (!obj.image) {
					return this.$api.msg('请上传微信二维码');
				}
				if (!obj.phone) {
					return this.$api.msg('请输入手机号码');
				}
				auction({
					type:1,
					name: obj.name,
					payment: obj.code,
					image: obj.image,
					phone: obj.phone,
				})
					.then(e => {
						obj.$api.msg('修改成功');
					})
					.catch(e => {
						console.log(e);
					});
			},
		}
	}
</script>

<style lang="scss">
page , .content{
	height: 100%;
	margin: 0;
	padding: 0;
	
}
.box{
	margin:20rpx 0  100rpx 0;
	width: 100%;
	background: #FFFFFF;
	
	.wx{
		border-bottom: #F0F0F0 solid 1rpx;
		padding: 20rpx 0 30rpx 0;
		display: flex;
		text{
			width: 150rpx;
			margin: 0 30rpx;
		}
		input {
			height: 100rpx;
			display: inline-block;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #999999;
			line-height: 100rpx;
		}
	}
	.erweima{
		padding: 30rpx 0;
		display: flex;
		text{
			margin: 0 30rpx;
			width: 150rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #333333;
			
		}
		.img{
			width: 160rpx;
			height: 160rpx;
			image{
				width: 100%;
				height: 100%;
			}
		}
	}
}
.button{
	margin: 0 auto;
	width: 560rpx;
	height: 80rpx;
	background: #FD3B39;
	border-radius: 40rpx;
	font-size: 30rpx;
	font-family: PingFangSC;
	font-weight: 500;
	color: #FFFFFF;
	line-height: 80rpx;
	text-align: center;
}
</style>
