<template>
	<view>
		<view class="main">
			<view class="form">
				<view class="form_group">
					<view class="lable">手机号</view>
					<input type="text" v-model="item.phone" placeholder="请输入手机号" />
				</view>
				<view class="form_group">
					<view class="lable">支付宝</view>
					<input type="text" v-model="item.alipay" placeholder="请输入支付宝账号" />
				</view>
			</view>
			<view class="form" style="margin-top: 10px;">
				<view class="form_group">
					<view class="lable">开户行</view>
					<input type="text" v-model="item.bankName" placeholder="请输入开户行" />
				</view>
				<view class="form_group">
					<view class="lable">银行卡号</view>
					<input type="text" v-model="item.bankAccount" placeholder="请输入银行卡号" />
				</view>
			</view>
			<button class="btn" @click="save()">确定</button>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			item: {}
		};
	},
	onLoad() {
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: '/app/user/info',
				data: this.item,
				success: (res) => {
					this.item = res.data.data;
				}
			});
		},
		save() {
			let rule = [
				{ name: 'phone', checkType: 'phone', errorMsg: '请请输入手机号' },
				{ name: 'alipay', checkType: 'notnull', errorMsg: '请输入支付宝账号' }
			];
			if (!this.verify.check(this.item, rule)) {
				uni.showModal({ content: this.verify.error, showCancel: false });
				return false;
			}
			this.http.request({
				url: '/app/user/edit',
				data: this.item,
				method: 'POST',
				success: (res) => {
					uni.showModal({
						title: '提示',
						content: '编辑成功。',
						showCancel: false,
						success: (res) => {
							uni.navigateBack();
						}
					});
				}
			});
		}
	}
};
</script>

<style lang="scss">
.btn {
	margin-top: 30px;
}
</style>