<template>
	<view>
		<view class="main">
			<view class="message _error" v-if="!item.phone">
				<text class="icon">&#xec72;</text>
				<text>需要完善结算信息才能接包。</text>
			</view>
			<view class="form_group">
				<view class="lable re">手机号</view>
				<input type="text" v-model="item.phone" placeholder="请输入手机号" />
			</view>
			<view class="form_group">
				<view class="lable re">支付宝</view>
				<input type="text" v-model="item.alipay" placeholder="请输入支付宝账号" />
			</view>
			<view class="form_group">
				<view class="lable re">开户行</view>
				<input type="text" v-model="item.bankName" placeholder="请输入开户行" />
			</view>
			<view class="form_group">
				<view class="lable re">银行卡号</view>
				<input type="text" v-model="item.bankAccount" placeholder="请输入银行卡号" />
			</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: '请输入支付宝账号' },
				{ 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>
