<template>
	<view class="xkl-com-bg">
		<view style="height: 20rpx;"></view>
		<view style="background-color: #ffffff;padding: 30rpx;">
			<u--form labelPosition="top" :model="form" :rules="rules" ref="uForm" labelWidth="200rpx">
				<u-form-item label="真实姓名" prop="realname" borderBottom>
					<u-input v-model="form.realname" placeholder="请输入" border="none" />
				</u-form-item>
				<u-form-item label="身份证号" prop="idcard" borderBottom>
					<u-input v-model="form.idcard" placeholder="请输入" border="none" />
				</u-form-item>
				<u-form-item label="银行卡号" prop="num" borderBottom>
					<u-input v-model="form.num" placeholder="请输入" border="none" />
				</u-form-item>
				<u-form-item label="预留手机号" prop="mobile" borderBottom>
					<u-input v-model="form.mobile" placeholder="请输入" border="none" />
				</u-form-item>
			</u--form>
			<view style="height: 50rpx;"></view>
			<view>
				<view style="font-size: 28rpx;color: coral;">请仔细核对信息，填写错误会导致提现失败。</view>
			</view>
			<view style="height: 50rpx;"></view>
			<u-button type="primary" @click="submit">提交</u-button>
			<view style="height: 50rpx;"></view>
		</view>
	</view>
</template>

<script>
	let self;
	export default {
		data() {
			return {
				rules: {
					idcard: [{
						required: true,
						message: '请输入',
						trigger: ['blur', 'change']
					}],
					realname: [{
						required: true,
						message: '请输入',
						trigger: ['blur', 'change']
					}],
					num: [{
						required: true,
						message: '请输入',
						trigger: ['blur', 'change']
					}],
					mobile: [{
						required: true,
						message: '请输入',
						trigger: ['blur', 'change']
					}],
				},
				form: {
					id: '',
					type: 3,
					role: 1,
					subname: '',
					realname: '',
					idcard: '',
					num: '',
					mobile: '',
				},

			}
		},
		mounted() {

		},
		onLoad(option) {
			self = this;
			if (option && option.item) {
				self.form = JSON.parse(decodeURIComponent(option.item));
			}
		},
		onShow() {

		},
		onReady() {
			//如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
			self.$refs.uForm.setRules(self.rules)
		},
		methods: {
			submit() {
				this.$refs.uForm.validate().then(res => {
					if (self.form.id) {
						self.$http.post('/shop/v10/account/update', self.form).then(({
							data,
							success
						}) => {
							if (success) {
								uni.navigateBack();
							}
						})
					} else {
						self.$http.post('/shop/v10/account/create', self.form).then(({
							data,
							success
						}) => {
							if (success) {
								uni.navigateBack();
							}
						})
					}
				}).catch(errors => {

				})
			},
		}
	}
</script>

<style lang="scss">

</style>