<template>
	<view class="body">
		<view class="header">
			<u-image height="120" width="120" style="margin: 0 auto;margin-top: 30rpx;margin-bottom: 30rpx;" src="https://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/icon_alipay.png"></u-image>
			<view class="container">
				<view class="icon" style="margin-top: 25rpx;display: flex;align-items: center;justify-content: center;"></view>
				<view class="title">支付宝收款账号绑定</view>
			</view>
		</view>
		<view class="line"></view>

		<view class="content">
			<u-form :model="form" :rules="rules" ref="uForm">
				<u-form-item label-width="300" :label-position="labelPosition" label="支付宝姓名:" prop="bank_name">
					<u-input :border="border" placeholder="请输入支付宝账号姓名" v-model="form.alipay_realname"></u-input>
				</u-form-item>
				<u-form-item label-width="300" :label-position="labelPosition" label="支付宝手机号:" prop="bank_no">
					<u-input :border="border" placeholder="请输入支付宝手机号" v-model="form.alipay_account"></u-input>
				</u-form-item>
				<u-form-item label-width="300" :label-position="labelPosition" label="确认支付宝手机号:" prop="bank_no">
					<u-input :border="border" placeholder="请再次输入支付宝手机号" v-model="form.alipay_account2"></u-input>
				</u-form-item>
			</u-form>
		</view>

		<view style="margin-top: 60rpx;"><u-button :disabled="false" class="button" @click="submit">保 存</u-button></view>
	</view>
</template>

<script>
	let that = {}
	export default {
		data() {
			return {
				showInfo: false,
				form: {
					payType: '提现到银行',
					payTypeValue: 2,
				},
				bankImgUp: 'http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/bank_card_setting/take_photo.png',// 银行卡照片OCR
				openAutoPay: true,
				border: 'none',
				showPayType: false,
				labelPosition: 'left',
				rules: {
					bank_name: [
						{
							required: true,
							message: '请输入姓名',
							trigger: 'blur',
						},
						{
							min: 3,
							max: 5,
							message: '姓名长度在3到5个字符',
							trigger: ['change', 'blur'],
						},
						{
							// 此为同步验证，可以直接返回true或者false，如果是异步验证，稍微不同，见下方说明
							validator: (rule, value, callback) => {
								return this.$u.test.chinese(value);
							},
							message: '姓名必须为中文',
							trigger: ['change', 'blur'],
						},
					]
				}
			};
		},
		onLoad: function () {
			that = this
			// that.init();
		},
		methods: {
			init() {
				getApp().globalData.util.request({
					s: 'Merch.Mershop_Alipay.get'
				}).then(res => {
					that.form = res.data.data
					that.form.alipay_account2 = res.data.data.alipay_account
				})
			},
			submit() {
				if (that.form.alipay_account2 !== that.form.alipay_account) {
					uni.showModal({
						title: '提示',
						content: '两次输入的手机号不一致'
					});
					return
				}
				getApp().globalData.util.request({
					s: 'Merch.Mershop_Alipay.update',
					alipay_account: that.form.alipay_account,
					alipay_realname: that.form.alipay_realname
				}).then(res => {
					uni.showModal({
						title: '提示',
						content: res.data.data.res_msg,
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
							}
						}
					})
				})
			},
			selectColor(items) {
				if (items[0].value == 'no') {
					that.openAutoPay = false
				} else {
					that.openAutoPay = true
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
@import './alipay.scss';
</style>
