gerenxinxi.vue 6.1 KB
<template>
	<view class="gereninfo">
		<view class="gerenbox">
			<view class="gerenitem">
				<view class="gerenleft">
					头像
				</view>
				<view class="gerenright">
					<view class="touimg">
						<image :src="avatar"></image>
					</view>
					<view class="rowright">
						<image src="/static/img/rowright.png"></image>
					</view>
				</view>


			</view>

			<view class="gerenitem">
				<view class="gerenleft">
					姓名
				</view>
				<view class="gerenright">
					<view class="toutext">
						<input type="text" placeholder="请输入姓名" :value="name" @blur="entername" />
					</view>
					<view class="rowright">
						<image src="/static/img/rowright.png"></image>
					</view>
				</view>
			</view>

			<view class="gerenitem">
				<view class="gerenleft">
					推荐人
				</view>
				<view class="gerenright">
					<view class="toutext" v-if="bangdingpeople==''"  @click="bangding">
						绑定推荐人
					</view>
					<view class="toutext" v-else @click="bangding">
						{{bangdingpeople}}
					</view>
					<view class="rowright">
						<image src="/static/img/rowright.png"></image>
					</view>
				</view>


			</view>
		</view>
		<view class="register" v-if="showbang">
			<view class="registerwrap">

				<view class="bangtitle">绑定推荐人</view>
				<view class="tuiphone">
					<input placeholder='请输入推荐人手机号' placeholder-class='tuishouji' :value="phone" @input="entrphone" type="number" />
				</view>
				<view class="tuiwarn" v-if="showfalse">
					{{errmsg}}
					<!-- 该推荐人不存在,请重新输入 -->
					</view>
				<!-- <view class="tuiwarn">{{content}}</view> -->
				<view class="tuifoot">
					<view class="tuifootleft" @click="hideshowbang">取消</view>
					<view class="tuifootright" @click="quding">确定</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import app from "../../App.vue"
	export default {
		data() {
			return {
				showbang: false,
				name: '',
				peopleinfo: '',
				phone: '',
				changename: '',
				showfalse:false,
				avatar:'',
				errmsg:'',
				bangdingpeople:''

			}
		},
		methods: {
			bangding() {
				if(this.bangdingpeople != '') {
					uni.showToast({
						title: '已绑定推荐人,无法修改',
						icon: 'none',
					})
				} else {
					this.showbang = true
				}
			},
			hideshowbang() {
				this.showbang = false
			},
			// 输入姓名
			entername(e) {
				this.changename = e.detail.value
				let param = {
					username: this.changename
				}
				app.post("api/person/updateInfo", param, 'post')
					.then(res => {
						console.log(res);
						uni.showToast({
							title: '修改成功',
							icon: 'none',
						})


					})
					.catch(err => {
						console.log(err)
						uni.showToast({
							title: err.msg,
							icon: 'none',
						})
					});
			},
			// 输入手机号
			entrphone(e) {
				this.phone = e.detail.value;
				console.log(this.phone)
				if(this.phone==''){
					this.showfalse=false
				}
				console.log(e)
			},

			quding() {

				let phone = this.phone;

				var reg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
				if (!reg.test(phone)) {
					uni.showToast({
						title: "请输入正确的手机号",
						icon: 'none',
					})

					return false
				}
				let param = {
					mobile: this.phone
				}
				app.post("api/person/bindPerson", param, 'get')
					.then(res => {
						console.log(res);
						uni.showToast({
							title: '绑定成功',
							icon: 'none',
						})
						setTimeout(function(){
							uni.navigateBack({
								checked:true
							})
							// this.showfalse=false
						},1500)


					})
					.catch(err => {
						console.log(err)
						// uni.showToast({
						// 	title: err.msg,
						// 	icon: 'none',
						// })
						this.errmsg=err.msg
						this.showfalse=true
					});
			}
		},
		onLoad(options) {
			console.log(options)
			let peopleinfo = JSON.parse(options.peopleinfo)
			this.peopleinfo = peopleinfo
			this.name = peopleinfo.username;
			this.avatar=peopleinfo.avatar;
			this.bangdingpeople=peopleinfo.recommender
			console.log(this.bangdingpeople)

		},
		onUnload: function() {

		},

	}
</script>

<style>
	.gereninfo {
		background: #F5F5F5;

	}

	.gerenbox {
		width: 686rpx;
		margin: 26rpx auto 0;
	}

	.gerenitem {
		padding: 40rpx 32rpx;
		box-sizing: border-box;

	}

	.gerenleft {
		color: #0A0808;
		font-size: 30rpx;
	}

	.touimg {
		width: 60rpx;
		height: 60rpx;
		font-size: 0;
		border-radius: 50%;
	}

	.touimg image {
		width: 100%;
		height: 100%;
		border-radius: 50%;
	}

	.rowright {
		width: 48rpx;
		height: 48rpx;
		font-size: 0;
		margin-left: 20rpx;
	}

	.rowright image {
		width: 100%;
		height: 100%;
	}

	.gerenitem {
		display: flex;
		align-items: center;
		justify-content: space-between;
		background: #fff;
	}

	.gerenright {
		display: flex;
		align-items: center;
	}

	.toutext {
		color: #7F8389;
		font-size: 24rpx;
	}

	.toutext input {
		text-align: right;
	}

	.registerwrap {
		width: 686rpx;
		height: 654rpx;
		background: rgba(255, 255, 255, 1);
		opacity: 1;
		border-radius: 10rpx;
		background: #fff;
		position: absolute;
		top: 50%;
		left: 50%;
		right: 50%;
		transform: translate(-50%, -50%);
		padding: 58rpx 40rpx;
		box-sizing: border-box;
	}

	.bangtitle {
		color: #06121E;
		font-size: 44rpx;
		font-weight: bold;
	}

	.tuiphone {
		width: 550rpx;
		border-bottom: 1rpx solid #EBEBEB;
		padding: 36rpx 0;
		box-sizing: border-box;
		margin-top: 80rpx;

	}

	.tuiphone input {
		color: #D2D2D2;
		font-size: 32rpx;
		text-align: center
	}

	.tuishouji {
		color: #D2D2D2;
		font-size: 32rpx;
	}

	.tuiwarn {
		color: #CE1500;
		font-size: 26rpx;
		margin-top: 20rpx;
	}

	.tuifoot {
		margin-top: 110rpx;
		display: flex;
		justify-content: space-between;
		align-items: center
	}

	.tuifootleft {
		width: 254rpx;
		height: 100rpx;
		border: 2rpx solid rgba(243, 152, 0, 1);
		opacity: 1;
		border-radius: 10rpx;
		color: #F39800;
		font-size: 32rpx;
		text-align: center;
		line-height: 100rpx;
	}

	.tuifootright {
		width: 254rpx;
		height: 100rpx;
		background: rgba(243, 152, 0, 1);
		box-shadow: 0rpx 4rpx 18rpx rgba(0, 0, 0, 0.04);
		opacity: 1;
		border-radius: 10rpx;
		color: #fff;
		font-size: 32rpx;
		text-align: center;
		line-height: 100rpx;
	}
</style>