<template>
	<ciy-header title="收款银行"></ciy-header>
	<form @submit="submit" class="char3">
		<view class="ciy-card">
			<view class="content char4">
				<view class="ciy-form">
					<label class="imp">账户名称</label>
					<view>
						<ciy-input name="bankaccount" v-model="me.bankaccount" type="text" bb></ciy-input>
					</view>
					<view class="flexnone" style="padding-left:1em" @tap="me.bankaccount=me.truename">
						{{me.truename}}
					</view>
				</view>
				<view class="ciy-form">
					<label class="imp">银行账号</label>
					<view>
						<ciy-input name="bankno" v-model="me.bankno" type="text" bb></ciy-input>
					</view>
				</view>
				<view class="ciy-form">
					<label class="imp">开户银行</label>
					<view>
						<ciy-input name="bankname" v-model="me.bankname" type="text" bb></ciy-input>
					</view>
				</view>
				<view class="ciy-form">
					<label>联行号</label>
					<view>
						<ciy-input name="bankcode" v-model="me.bankcode" type="text" bb></ciy-input>
					</view>
				</view>
				
				<view class="ciy-tip">实名认证人【{{me.truename}}】
					<br />姓名与实名不符，需为对公账户。
					<br />对公账户收款(含提现)，需开具发票。
					<br />个人银行账户收款，平台代缴个税。
				</view>
				<view class="ciy-form-bottom">
					<button class="btn lg cc" form-type="submit">更新收款信息</button>
				</view>
			</view>
		</view>
	</form>
</template>

<style>
</style>

<script>
	export default {
		data() {
			return {}
		},
		onLoad() {
			if (!this.me.truename) {
				this.alert('请先实名认证').then(() => {
					uni.redirectTo({
						url: 'me_real'
					});
				});
			}
		},
		methods: {
			async submit(e) {
				if (!e.detail.value.bankaccount)
					return this.toast('请输入账户名称');
				if (!e.detail.value.bankno)
					return this.toast('请输入银行账号');
				if (!e.detail.value.bankname)
					return this.toast('请输入开户银行');

				this._loading = true;
				var retjson = await this.callajax({
					func: 'me.me_bank_info_change',
					data: e.detail.value
				});
				this._loading = false;
				if (retjson.code != 1)
					return this.alert(retjson.errmsg);
				this.me.bankno = e.detail.value.bankno;
				this.me.bankname = e.detail.value.bankname;
				this.me.bankaccount = e.detail.value.bankaccount;
				this.me.bankcode = e.detail.value.bankcode;
				this.setstorage('me', this.me);
				await this.toast('修改成功');
				uni.navigateBack();
			}
		}
	}
</script>