<template>
	<view>
		<view class="usable-hint receive-user">
			<text>接收用户</text>
		</view>
		<u-form class="form-box" :model="form" ref="uForm" label-width="156">
			<u-form-item class="usable-input" label="手机号">
				<u-input v-model="form.phone" placeholder="请输入手机号"  :clearable="false" @blur="getMobilemapname" />
			</u-form-item>
			<u-form-item class="usable-input" label="真实姓名">
				<u-input disabled v-model="form.name" placeholder="" />
			</u-form-item>
		</u-form>
	</view>
</template>

<script>
	import {
		mobilemapname
	} from "@/api/personal-center.js"
	export default {
		name: "mobilemapname",
		data() {
			return {
				form: {
					phone: '',
					name: '',
					user_obj_id: ''
				}
			};
		},
		created() {
			// this.getMobilemapname()
		},
		methods: {
			getMobilemapname() {
				if (!this.form.phone) {
					this.$mUtil.toast("请输入手机号")
					return false
				}
				if (!(this.form.phone.match(this.$mConfig.telRegex))) {
					this.$mUtil.toast("请输入正确的手机号")
					return false
				}
				// return false
				this.$http.post(`${mobilemapname}/${this.form.phone}`).then(res => {
					this.form.name = res.data.accept_real_name
					this.form.user_obj_id = res.data.user_obj_id
				})
			},
			// 获取需要转赠对象的ID
			getObjUserId() {
				return new Promise((resolve, reject) => {
					if (this.form.user_obj_id) {
						resolve(this.form)
					} else {
						this.$mUtil.toast("请先确认接收用户");
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.receive-user {
		margin-top: 84rpx;
	}

	.usable-hint {
		color: #333333;
		font-size: 32rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;

		.service-charge {
			font-weight: 400;
		}
	}
</style>
